/* css/main.css - MinoristaPro UI v2 */

/* 1. FUENTES — se cargan via <link> en el HTML, no duplicar aquí */

/* 2. VARIABLES DEL SISTEMA (Design Tokens) */
:root {
    /* ── Paleta Viajes Scape ── */
    --primary:       #0098CE;
    --primary-hover: #007faf;
    --primary-soft:  #e6f7fd;
    --navy:          #000A8B;
    --navy-light:    #0d1fa0;
    --gray-brand:    #7C7C81;

    --text-main:  #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --bg-body: #f5f7fa;
    --bg-card: #ffffff;

    --border-color: #e2e8f0;
    --border-focus: #0098CE;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 52px;
    --sidebar-transition: 200ms ease;

    /* Layout */
    --topbar-height: 56px;
    --bottom-nav-height: 60px;

    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;

    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

/* 3. RESET Y BASE */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: none;
    font-size: 0.925rem;
}

::selection {
    background-color: var(--primary-soft);
    color: var(--primary);
}

/* 4. SCROLLBARS */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ==========================================================================
   5. SIDEBAR COLAPSABLE
   ========================================================================== */

aside#appSidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid #eaecf0;
    box-shadow: none;
    flex-shrink: 0;
    transition: width var(--sidebar-transition);
    overflow: hidden;
}

aside#appSidebar.sidebar-collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 14px;
    border-bottom: 1px solid #eaecf0;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    min-width: 0;
    flex: 1;
}

.sidebar-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #e6f7fd;
    color: #0098CE;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid #cceefb;
}

#sidebarToggleBtn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9ca3af;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform var(--sidebar-transition);
}

#sidebarToggleBtn:hover {
    background: #f0f9ff;
    color: #0098CE;
}

aside#appSidebar.sidebar-collapsed #sidebarToggleBtn {
    transform: rotate(180deg);
}

aside#appSidebar.sidebar-collapsed .nav-label,
aside#appSidebar.sidebar-collapsed .nav-section-wrap {
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    margin: 1px 6px;
    border-radius: var(--radius-md);
    color: #374151;
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, padding var(--sidebar-transition);
    border: 1px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    cursor: pointer;
}

.nav-link:hover {
    background-color: #f0f9ff;
    color: #0098CE;
}

.nav-link svg {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    opacity: 0.7;
    transition: opacity 0.15s;
    margin-right: 0.75rem;
}

aside#appSidebar.sidebar-collapsed .nav-link {
    padding: 0.6rem;
    margin: 1px auto;
    width: 40px;
    justify-content: center;
}

aside#appSidebar.sidebar-collapsed .nav-link svg {
    margin-right: 0;
}

.nav-link.active-link {
    background-color: #e6f7fd !important;
    color: #0098CE !important;
    font-weight: 600;
    border-color: #99ddf7;
    border-left: 3px solid #0098CE !important;
    padding-left: calc(0.75rem - 3px) !important;
}

.nav-link.active-link svg {
    opacity: 1;
    color: #0098CE;
}

.nav-section-wrap {
    padding: 0 10px;
    margin-top: 1.25rem;
    margin-bottom: 0.375rem;
    overflow: hidden;
    white-space: nowrap;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
}

.sidebar-user-area {
    border-top: 1px solid #eaecf0;
    padding: 10px 8px;
    flex-shrink: 0;
}

.sidebar-user-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: padding var(--sidebar-transition);
}

.sidebar-user-inner:hover {
    background: #f0f9ff;
}

.sidebar-user-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
}

.sidebar-user-logout {
    flex-shrink: 0;
    transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
}

aside#appSidebar.sidebar-collapsed .sidebar-user-inner {
    padding: 8px 4px;
    justify-content: center;
}

aside#appSidebar.sidebar-collapsed .sidebar-user-text,
aside#appSidebar.sidebar-collapsed .sidebar-user-logout {
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    pointer-events: none;
}

aside#appSidebar.sidebar-collapsed .nav-link {
    position: relative;
}

aside#appSidebar.sidebar-collapsed .nav-link::after {
    content: attr(data-tooltip);
    position: fixed;
    left: calc(var(--sidebar-width-collapsed) + 8px);
    background: #1e293b;
    color: #f8fafc;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

aside#appSidebar.sidebar-collapsed .nav-link:hover::after {
    opacity: 1;
}

/* ==========================================================================
   6. TOPBAR
   ========================================================================== */

.app-topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 0.75rem;
    flex-shrink: 0;
    z-index: 30;
}

#topbarSectionTitle {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

/* ==========================================================================
   7. BOTTOM NAVIGATION (Mobile)
   ========================================================================== */

#bottomNav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-around;
    padding: 0 4px 4px;
    z-index: 40;
}

.bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-size: 0.625rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    transition: color 0.15s;
    min-width: 52px;
    -webkit-tap-highlight-color: transparent;
}

.bnav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.bnav-item.active-link {
    color: var(--primary);
}

#mobile-menu {
    position: fixed;
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
    border-radius: 16px 16px 0 0;
    z-index: 45;
    padding: 8px 12px 16px;
    max-height: 60vh;
    overflow-y: auto;
}

#mobile-menu::before {
    content: '';
    display: block;
    width: 32px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 4px auto 12px;
}

/* ==========================================================================
   8. FAB (Mobile)
   ========================================================================== */

#mobileFab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 14px);
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,152,206,0.45);
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 42;
}

#mobileFab:active {
    transform: scale(0.93);
    box-shadow: 0 2px 8px rgba(0,152,206,0.3);
}

/* ==========================================================================
   9. RESPONSIVE — Mobile adjustments
   ========================================================================== */

@media (max-width: 767px) {

    #bottomNav {
        display: flex;
    }

    #mobileFab {
        display: flex;
    }

    #mainContentArea {
        padding: 1rem 1rem calc(var(--bottom-nav-height) + 1rem) !important;
    }

    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }

    tbody td,
    thead th {
        padding: 0.75rem 0.875rem !important;
    }

    .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .btn-edit,
    .btn-confirm,
    .btn-delete,
    .btn-pay {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    aside#appSidebar {
        width: var(--sidebar-width-collapsed);
    }
}

/* ==========================================================================
   10. TARJETAS Y CONTENEDORES
   ========================================================================== */

.bg-white.shadow, .bg-white.shadow-lg, .bg-white.shadow-sm, .card-pro {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card) !important;
    border-radius: var(--radius-lg) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid > .bg-white:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover) !important;
    border-color: #cbd5e1;
}

.text-3xl {
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

.text-gray-500.uppercase {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   11. TABLAS
   ========================================================================== */

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

thead th {
    background-color: #f8fafc !important;
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1.25rem !important;
    border-bottom: 1px solid var(--border-color);
}

tbody td {
    padding: 0.875rem 1.25rem !important;
    border-bottom: 1px solid var(--bg-body);
    color: var(--text-main);
    font-size: 0.875rem;
    vertical-align: middle;
    transition: background-color 0.12s;
}

tbody tr:last-child td { border-bottom: none; }

/*
 * ZEBRA STRIPING — Guía visual para filas en monitores anchos.
 * Filas pares: fondo slate-50 muy sutil.
 * Hover: tinte primario suave para indicar fila activa.
 * Anti-fatiga: el contraste es mínimo a propósito.
 */
tbody tr:nth-child(odd) td {
    background-color: #ffffff;
}

tbody tr:nth-child(even) td {
    background-color: #f8fafc;
}

tbody tr:hover td {
    background-color: #e6f7fd !important;
}

/*
 * TABULAR NUMBERS — Alineación vertical de dígitos en columnas financieras.
 * font-variant-numeric: tabular-nums garantiza que cada dígito ocupa el mismo
 * ancho horizontal, permitiendo auditoría visual de montos sin zigzaguear.
 * Se aplica a: celdas font-mono, inputs numéricos, y clase utilitaria .tabular-nums
 */
.tabular-nums,
td.font-mono,
td .font-mono,
input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   12. FORMULARIOS
   ========================================================================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    /*
     * FIX BUG $ — El padding vertical se fuerza con !important para consistencia
     * visual, pero el padding HORIZONTAL NO usa !important. Esto permite que las
     * clases de Tailwind pl-7, pl-8, pl-9 (usadas en campos con prefijo $ o ícono)
     * funcionen correctamente sin que el símbolo tape el primer dígito.
     *
     * Antes: padding: 0.575rem 0.875rem !important  ← bloqueaba pl-* de Tailwind
     * Ahora: solo vertical con !important, horizontal sin !important
     */
    padding-top: 0.575rem !important;
    padding-bottom: 0.575rem !important;
    padding-left: 0.875rem;
    padding-right: 0.875rem;
    /*
     * FIX MOBILE — iOS Safari auto-zoom en inputs.
     * font-size < 16px provoca zoom automático al enfocar en iOS.
     */
    font-size: 1rem !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03) !important;
    transition: all 0.2s ease;
    background-color: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(0,152,206,0.18) !important;
}

label {
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    color: var(--text-muted) !important;
    margin-bottom: 0.3rem !important;
    display: block;
}

/*
 * FIX MOBILE — Double-tap zoom y delay de 300ms en botones.
 */
button,
a,
[role="button"],
input[type="submit"],
input[type="button"] {
    touch-action: manipulation;
}

button.bg-primary-600, button.bg-blue-600, button.bg-green-600 {
    background-color: var(--primary) !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 6px rgba(0,152,206,0.25) !important;
    transition: all 0.2s;
    border: none !important;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

button.bg-primary-600:hover, button.bg-blue-600:hover {
    background-color: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 10px rgba(0,152,206,0.3) !important;
}

button.bg-primary-600:active { transform: translateY(0); }

/* ==========================================================================
   13. MODALES
   ========================================================================== */

#messageModal > div, .modal-content {
    border-radius: 1rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid rgba(255,255,255,0.8);
}

.bg-opacity-50, .backdrop-blur-sm {
    backdrop-filter: blur(8px);
    background-color: rgba(15, 23, 42, 0.65) !important;
}

/* ==========================================================================
   14. ANIMACIONES Y UTILIDADES
   ========================================================================== */

.fade-in { animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

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

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

.animate-pulse-soft { animation: pulse-soft 2s infinite; }

.animate-spin {
    border-color: var(--border-color);
    border-top-color: var(--primary);
}

/* ==========================================================================
   15. STATUS BADGES
   ========================================================================== */

span.rounded-full {
    padding: 0.25em 0.75em !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ==========================================================================
   16. PAGE-CONTENT (fade in por sección)
   ========================================================================== */

.page-content {
    animation: fadeIn 0.25s ease forwards;
}

/* ==========================================================================
   17. FIX DEFINITIVO pl-* — Tailwind CDN inyecta estilos ANTES de main.css,
       por lo que input { padding-left: 0.875rem } gana sobre pl-7/pl-8/pl-9.
       Estas reglas restauran los valores correctos con !important explícito.
       Aplica a: inputs con ícono prefijo ($, lupa, etc.)
   ========================================================================== */

input.pl-7  { padding-left: 1.75rem !important; }
input.pl-8  { padding-left: 2rem    !important; }
input.pl-9  { padding-left: 2.25rem !important; }
input.pl-10 { padding-left: 2.5rem  !important; }
input.pl-11 { padding-left: 2.75rem !important; }
input.pl-12 { padding-left: 3rem    !important; }

/* ==========================================================================
   18. MODAL DE ABONOS — Altura máxima y scroll interno.
       Evita que el modal desborde la pantalla cuando hay muchos abonos.
   ========================================================================== */

#modalCustomContent {
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 2px;
}

#paymentsList {
    max-height: 36vh !important;
    overflow-y: auto;
}
