/* ================================================
   LOGISTICS MODULE - Premium Dark Design
   ================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --log-primary: #4F46E5;
    --log-primary-light: #818CF8;
    --log-accent: #06B6D4;
    --log-success: #10B981;
    --log-warning: #F59E0B;
    --log-danger: #EF4444;
    --log-dark: #0F172A;
    --log-dark-card: #1E293B;
    --log-dark-border: rgba(255,255,255,0.08);
    --log-text: #F8FAFC;
    --log-text-muted: #94A3B8;
    --log-input-bg: #0F172A;
    --log-shadow: 0 25px 60px rgba(0,0,0,0.5);
    --log-radius: 12px;
}

/* ─── Overlay ─── */
#logistics-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    z-index: 9998;
    display: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.35s ease;
}
#logistics-overlay.open {
    display: block;
    opacity: 1;
}

/* ─── Drawer Container ─── */
#logistics-drawer {
    position: fixed;
    top: 0;
    right: -520px;
    width: 480px;
    height: 100vh;
    background: #0F172A;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: var(--log-shadow);
    overflow: hidden;
}
#logistics-drawer.open {
    right: 0;
}

/* ─── Header ─── */
.logistics-header {
    background: linear-gradient(135deg, #4F46E5 0%, #0EA5E9 50%, #06B6D4 100%);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.logistics-header::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 160px;
    height: 160px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}
.logistics-header::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: -20px;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}
.logistics-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}
.logistics-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logistics-header-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    backdrop-filter: blur(4px);
    animation: truckPulse 2.5s ease-in-out infinite;
}
@keyframes truckPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0.3); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(255,255,255,0); }
}
.logistics-header-title {
    color: white;
}
.logistics-header-title h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.logistics-header-title p {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.75);
    font-weight: 400;
}
.logistics-close-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}
.logistics-close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

/* Conversation badge in header */
.logistics-conv-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 4px 12px;
    margin-top: 12px;
    width: fit-content;
    position: relative;
    z-index: 1;
}
.logistics-conv-badge span {
    color: rgba(255,255,255,0.9);
    font-size: 0.72rem;
    font-weight: 500;
}
.logistics-conv-badge .pulse-dot {
    width: 7px;
    height: 7px;
    background: #10B981;
    border-radius: 50%;
    animation: pulseDot 1.8s ease-in-out infinite;
}
@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.8); }
}

/* ─── Stepper ─── */
.logistics-stepper {
    background: #1E293B;
    padding: 20px 24px;
    border-bottom: 1px solid var(--log-dark-border);
    flex-shrink: 0;
}
.stepper-label-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.stepper-label-row span {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--log-text-muted);
    width: 25%;
    text-align: center;
}
.stepper-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    gap: 0;
}
.stepper-track {
    position: absolute;
    top: 50%;
    left: 12.5%;
    right: 12.5%;
    height: 3px;
    background: #334155;
    border-radius: 2px;
    transform: translateY(-50%);
    z-index: 0;
}
.stepper-track-fill {
    height: 100%;
    background: linear-gradient(90deg, #4F46E5, #06B6D4);
    border-radius: 2px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.step-node {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    cursor: pointer;
}
.step-node-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #334155;
    border: 2px solid #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #64748B;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
.step-node.active .step-node-circle {
    background: linear-gradient(135deg, #4F46E5, #818CF8);
    border-color: #4F46E5;
    color: white;
    transform: scale(1.18);
    box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.25), 0 4px 12px rgba(79, 70, 229, 0.4);
}
.step-node.completed .step-node-circle {
    background: linear-gradient(135deg, #059669, #10B981);
    border-color: #10B981;
    color: white;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}
.step-node.active .step-node-circle::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(79, 70, 229, 0.4);
    animation: ripple 1.8s ease-out infinite;
}
@keyframes ripple {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* ─── Body / Forms ─── */
.logistics-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
    background: #0F172A;
}
.logistics-body::-webkit-scrollbar { width: 5px; }
.logistics-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.logistics-body::-webkit-scrollbar-track { background: transparent; }

/* Stage section title */
.stage-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--log-dark-border);
}
.stage-section-title .icon-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}
.stage-section-title h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--log-text);
}
.stage-section-title p {
    margin: 2px 0 0;
    font-size: 0.72rem;
    color: var(--log-text-muted);
}

.logistics-stage-form {
    display: none;
    animation: stageFadeIn 0.35s ease;
}
.logistics-stage-form.active { display: block; }

@keyframes stageFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form groups */
#logistics-drawer .form-group {
    margin-bottom: 14px;
}
#logistics-drawer .form-group label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--log-text-muted);
    margin-bottom: 5px;
}
#logistics-drawer .form-group input[type="text"],
#logistics-drawer .form-group input[type="date"],
#logistics-drawer .form-group input[type="number"],
#logistics-drawer .form-group select,
#logistics-drawer .form-group textarea {
    width: 100%;
    background: #1E293B;
    border: 1px solid #334155;
    color: var(--log-text);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
    box-sizing: border-box;
}
#logistics-drawer .form-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}
#logistics-drawer .form-group input:focus,
#logistics-drawer .form-group select:focus,
#logistics-drawer .form-group textarea:focus {
    border-color: #4F46E5;
    background: #1a2744;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
#logistics-drawer .form-group textarea {
    resize: vertical;
    min-height: 72px;
}

/* Two-col grid for short fields */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Checkbox cards */
#logistics-drawer .form-group.checkbox-group {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
#logistics-drawer .form-group.checkbox-group:hover {
    border-color: #4F46E5;
    background: #1a2744;
}
#logistics-drawer .form-group.checkbox-group label {
    font-size: 0.78rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--log-text);
    font-weight: 500;
    cursor: pointer;
    margin: 0;
}
/* Toggle switch for checkboxes */
#logistics-drawer .form-group.checkbox-group input[type="checkbox"] {
    width: 0;
    height: 0;
    opacity: 0;
    position: absolute;
}
.toggle-switch {
    width: 36px;
    height: 20px;
    background: #334155;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: left 0.3s;
}
#logistics-drawer .form-group.checkbox-group.is-checked .toggle-switch {
    background: #4F46E5;
}
#logistics-drawer .form-group.checkbox-group.is-checked .toggle-switch::after {
    left: 19px;
}

/* ─── Footer / Action button ─── */
.logistics-footer {
    padding: 16px 24px;
    background: #1E293B;
    border-top: 1px solid var(--log-dark-border);
    flex-shrink: 0;
}
.btn-logistics-primary {
    width: 100%;
    padding: 13px 20px;
    background: linear-gradient(135deg, #4F46E5 0%, #0EA5E9 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.25s;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
    letter-spacing: 0.01em;
}
.btn-logistics-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(79, 70, 229, 0.5);
}
.btn-logistics-primary:active {
    transform: translateY(0);
}
.btn-logistics-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.btn-logistics-primary.success {
    background: linear-gradient(135deg, #059669 0%, #10B981 100%);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

/* ─── Chat button ─── */
.logistics-btn-chat {
    background: linear-gradient(135deg, #4F46E5 0%, #0EA5E9 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.4);
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}
.logistics-btn-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(79, 70, 229, 0.5);
}

/* ================================================
   LOGISTICS FOOTER ACTIONS (Kanban button)
   ================================================ */
.logistics-footer-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.logistics-footer-actions .btn-logistics-primary {
    flex: 1;
}
.btn-kanban-view {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 13px 16px;
    background: rgba(79, 70, 229, 0.15);
    border: 1px solid rgba(79, 70, 229, 0.4);
    color: #818CF8;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-kanban-view:hover {
    background: rgba(79, 70, 229, 0.3);
    border-color: #818CF8;
    color: white;
    transform: translateY(-1px);
}

/* ================================================
   KANBAN OVERLAY
   ================================================ */
#kanban-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10009;
    backdrop-filter: blur(4px);
}
#kanban-overlay.open { display: block; }

/* ================================================
   KANBAN MODAL
   ================================================ */
#kanban-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: min(96vw, 1200px);
    height: min(90vh, 780px);
    background: #0F172A;
    border-radius: 16px;
    z-index: 10010;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.08);
    overflow: hidden;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s;
}
#kanban-modal.open {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* ── Kanban Header ── */
.kanban-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(135deg, #1e1b4b 0%, #0c1a3a 100%);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.kanban-header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.kanban-header-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 10px rgba(79,70,229,0.7));
}
.kanban-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    font-family: 'Inter', sans-serif;
}
.kanban-modal-header p {
    font-size: 0.78rem;
    color: #64748B;
    margin: 2px 0 0;
    font-family: 'Inter', sans-serif;
}
.kanban-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-kanban-config {
    padding: 7px 14px;
    background: rgba(245,158,11,0.15);
    border: 1px solid rgba(245,158,11,0.4);
    color: #F59E0B;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.btn-kanban-config:hover {
    background: rgba(245,158,11,0.3);
    border-color: #F59E0B;
}
.btn-kanban-refresh {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94A3B8;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.5s, background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.btn-kanban-refresh:hover { background: rgba(255,255,255,0.12); }
.kanban-close-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #EF4444;
    font-size: 1rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.kanban-close-btn:hover {
    background: rgba(239,68,68,0.25);
    transform: scale(1.05);
}

/* ── Kanban Board ── */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.kanban-column {
    background: #1E293B;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    min-height: 200px;
    overflow: hidden;
}
.kanban-col-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 3px solid;
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.kanban-col-icon { font-size: 1rem; }
.kanban-col-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #F8FAFC;
    font-family: 'Inter', sans-serif;
    flex: 1;
}
.kanban-col-count {
    background: rgba(255,255,255,0.1);
    color: #94A3B8;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
}
.kanban-cards {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

/* ── Kanban Card ── */
.kanban-card {
    background: #0F172A;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.07);
    border-left: 4px solid;
    padding: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    animation: cardIn 0.3s ease;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.kanban-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.kanban-card-op {
    font-size: 0.78rem;
    font-weight: 700;
    color: #818CF8;
    font-family: 'Inter', sans-serif;
}
.kanban-card-fecha {
    font-size: 0.7rem;
    color: #64748B;
    font-family: 'Inter', sans-serif;
}
.kanban-card-client {
    font-size: 0.85rem;
    font-weight: 600;
    color: #F1F5F9;
    font-family: 'Inter', sans-serif;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kanban-card-pedido {
    font-size: 0.75rem;
    color: #94A3B8;
    font-family: 'Inter', sans-serif;
    margin-bottom: 8px;
}
.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 6px;
}
.kanban-card-asesor {
    font-size: 0.72rem;
    color: #64748B;
    font-family: 'Inter', sans-serif;
}
.kanban-loading, .kanban-empty {
    text-align: center;
    color: #475569;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    padding: 24px 12px;
    font-style: italic;
}

/* ================================================
   ROUTING CONFIG MODAL
   ================================================ */
#routing-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: min(92vw, 500px);
    background: #0F172A;
    border-radius: 16px;
    z-index: 10020;
    box-shadow: 0 30px 80px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.08);
    overflow: hidden;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s;
}
#routing-modal.open {
    display: block;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}
.routing-modal-inner { padding: 24px; }
.routing-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: #F8FAFC;
    font-family: 'Inter', sans-serif;
}
.routing-subtitle {
    font-size: 0.8rem;
    color: #64748B;
    font-family: 'Inter', sans-serif;
    margin-bottom: 20px;
    line-height: 1.5;
}
.routing-form { display: flex; flex-direction: column; gap: 12px; }
.routing-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1E293B;
    border-radius: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.06);
}
.routing-stage-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #F1F5F9;
    font-family: 'Inter', sans-serif;
    flex: 1;
    border-left: 3px solid;
    padding-left: 10px;
}
.routing-stage-icon { font-size: 1rem; }
.routing-select {
    background: #0F172A;
    border: 1px solid #334155;
    color: #F8FAFC;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    min-width: 160px;
    outline: none;
    transition: border-color 0.2s;
}
.routing-select:focus { border-color: #4F46E5; }

@media (max-width: 768px) {
    .kanban-board { grid-template-columns: repeat(2, 1fr); }
    #kanban-modal { height: min(95vh, 780px); }
    .routing-row { flex-direction: column; align-items: flex-start; }
    .routing-select { width: 100%; }
}
@media (max-width: 480px) {
    .kanban-board { grid-template-columns: 1fr; }
}



