/* ==========================================================================
   theme.css - Sistema de Gestión de Transportes
   Design Tokens, Animaciones y Componentes Modernos
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* --- Paleta de Colores Base (Dark Slate & Neon Accents) --- */
    --bg-app: #0b1320;
    --bg-surface: #131d2e;
    --bg-surface-elevated: #1a273b;
    --bg-surface-hover: #22334c;
    
    /* Bordes y Divisiones */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.16);
    --border-accent: rgba(16, 185, 129, 0.4);
    
    /* Acentos Principales */
    --emerald-500: #10b981;
    --emerald-400: #34d399;
    --emerald-glow: rgba(16, 185, 129, 0.35);
    
    --cyan-500: #06b6d4;
    --cyan-400: #22d3ee;
    --cyan-glow: rgba(6, 182, 212, 0.35);

    --blue-500: #3b82f6;
    --blue-400: #60a5fa;

    --amber-500: #f59e0b;
    --amber-glow: rgba(245, 158, 11, 0.3);

    --rose-500: #f43f5e;
    --rose-glow: rgba(244, 63, 94, 0.3);

    /* Textos */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0b1320;

    /* Sombras y Luces */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-glow-emerald: 0 0 20px rgba(16, 185, 129, 0.35);
    --shadow-glow-cyan: 0 0 20px rgba(6, 182, 212, 0.35);

    /* Radio de bordes */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Tipografía */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset y Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    background-color: var(--bg-app);
    min-height: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar Moderno */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
    background: #283950;
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: #3b506e;
}

/* ==========================================================================
   Keyframes y Animaciones
   ========================================================================== */

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulseHighlight {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes shimmerSweep {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.92);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   Botones Interactivos y Microinteracciones
   ========================================================================== */

.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-modern:active {
    transform: scale(0.97);
}

/* Botón Destacado con Shimmer & Glow */
.btn-primary-glow {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--emerald-glow);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-primary-glow:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5), 0 0 12px var(--emerald-400);
    transform: translateY(-2px);
    color: #ffffff;
}

/* Botón Acción Peligro / Borrar / Bajas */
.btn-danger-modern {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 12px var(--rose-glow);
}
.btn-danger-modern:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45);
    transform: translateY(-2px);
}

/* Botón Neutro / Cancelar / Volver */
.btn-secondary-modern {
    background: var(--bg-surface-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.btn-secondary-modern:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

/* ==========================================================================
   Tarjetas e Interfaces Modernas
   ========================================================================== */

.card-modern {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card-modern:hover {
    border-color: var(--border-highlight);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Inputs y Formularios
   ========================================================================== */

.input-modern,
select.input-modern,
textarea.input-modern {
    width: 100%;
    background-color: #101927;
    border: 1px solid #283950;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 11px 14px;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all var(--transition-normal);
    outline: none;
    box-sizing: border-box;
}

.input-modern:hover,
select.input-modern:hover,
textarea.input-modern:hover {
    border-color: #3e5675;
}

.input-modern:focus,
select.input-modern:focus,
textarea.input-modern:focus {
    border-color: var(--emerald-400);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    background-color: #0c1421;
}

/* Normalización universal para selectores de fecha/calendario (date, month, week, time) */
input[type="date"],
input[type="month"],
input[type="week"],
input[type="time"],
input[type="datetime-local"] {
    box-sizing: border-box !important;
    max-width: 100% !important;
    width: 100% !important;
    -webkit-appearance: none;
    appearance: none;
    display: block;
    outline: none;
    background-color: #101927;
    color: var(--text-primary);
    border: 1px solid #283950;
    border-radius: var(--radius-md);
    padding: 11px 14px;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    text-align: center !important;
    transition: all var(--transition-normal);
}

input[type="date"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus {
    border-color: var(--cyan-400);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
    background-color: #0c1421;
}

/* Indicadores de WebKit (Safari / Chrome / iOS) */
input[type="date"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value,
input[type="week"]::-webkit-date-and-time-value {
    text-align: center !important;
    min-height: 1.4em;
}

input[type="date"]::-webkit-datetime-edit,
input[type="month"]::-webkit-datetime-edit,
input[type="week"]::-webkit-datetime-edit {
    text-align: center;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.8);
    opacity: 0.85;
    padding: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover,
input[type="week"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* ==========================================================================
   Insignias y Etiquetas (Badges)
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-emerald {
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald-400);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue-400);
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-amber {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber-500);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-rose {
    background: rgba(244, 63, 94, 0.15);
    color: var(--rose-500);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

/* ==========================================================================
   Modales con Glassmorphism
   ========================================================================== */

.modal-backdrop-modern {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 11, 20, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-backdrop-modern.visible {
    display: flex;
}

.modal-box-modern {
    background: linear-gradient(160deg, #182335 0%, #111a28 100%);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(16, 185, 129, 0.1);
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Utilidades Globales de Diseño Móvil-First
   ========================================================================== */

body.sidebar-bloqueada {
    overflow: hidden !important;
}

@media (max-width: 768px) {
    /* Normalización de inputs táctiles (16px para evitar auto-zoom en iOS Safari) */
    .input-modern,
    select.input-modern,
    textarea.input-modern,
    input[type="text"],
    input[type="date"],
    input[type="week"],
    input[type="month"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    select {
        font-size: 16px !important;
        min-height: 46px !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        width: 100% !important;
        -webkit-appearance: none;
        appearance: none;
    }

    .btn-modern,
    .btn-guardar,
    .btn-volver {
        min-height: 46px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .modal-backdrop-modern {
        padding: 14px;
    }

    .modal-box-modern {
        padding: 22px 18px;
        max-width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Transformación universal de tablas a tarjetas para dispositivos móviles */
    .tabla-responsive-cards {
        border: none !important;
        background: transparent !important;
        overflow-x: visible !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    .tabla-responsive-cards table,
    .tabla-responsive-cards thead,
    .tabla-responsive-cards tbody,
    .tabla-responsive-cards th,
    .tabla-responsive-cards td,
    .tabla-responsive-cards tr {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .tabla-responsive-cards thead {
        display: none !important;
    }
    .tabla-responsive-cards tbody tr {
        background: linear-gradient(160deg, #162235 0%, #101927 100%);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-lg);
        padding: 16px 18px;
        margin-bottom: 14px;
        box-shadow: var(--shadow-sm);
        transition: transform var(--transition-fast), border-color var(--transition-fast);
        box-sizing: border-box;
    }
    .tabla-responsive-cards tbody tr:hover {
        border-color: var(--border-highlight);
    }
    .tabla-responsive-cards td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
        font-size: 13.5px !important;
        text-align: right !important;
        min-height: 38px;
        box-sizing: border-box;
        word-break: break-word;
    }
    .tabla-responsive-cards td::before {
        content: attr(data-label);
        font-size: 11.5px;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--text-secondary);
        letter-spacing: 0.5px;
        text-align: left;
        margin-right: 14px;
        flex-shrink: 0;
    }
    .tabla-responsive-cards td:last-child {
        border-bottom: none !important;
        padding-top: 12px !important;
        padding-bottom: 4px !important;
        display: flex !important;
        justify-content: flex-end !important;
    }
    .tabla-responsive-cards td.td-acciones-full {
        display: block !important;
    }
    .tabla-responsive-cards td.td-acciones-full::before {
        display: block;
        margin-bottom: 8px;
    }
    .tabla-responsive-cards td.td-acciones-full .acciones-fila {
        width: 100%;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .tabla-responsive-cards td.td-acciones-full .acciones-fila > * {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        min-height: 42px;
        padding: 10px 12px;
    }
}
