#app-container { display: none; }

/* PANTALLA LOGIN */
#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
    color: #333;
}

.login-card h2 {
    margin-bottom: 10px;
    color: #1e3c72;
}

.login-card p {
    color: #666;
    margin-bottom: 25px;
    font-size: 14px;
}

.login-card input {
    text-transform: none !important;
}

.error-msg {
    color: #dc3545;
    margin-top: 15px;
    font-size: 14px;
    display: none;
}

/* HEADER & NAVEGACIÓN (ESCRITORIO) */
header {
    position: sticky;
    top: 0;
    z-index: 2500;
    background-color: var(--header-bg, #ffffff);
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.brand-area {
    display: flex;
    align-items: center;
}

.brand-area h1 { 
    margin: 0; 
    font-size: 22px; 
    font-weight: 900; 
    color: #0F3A66; 
    letter-spacing: 0.5px;
}

.brand-area span { font-size: 11px; color: #555; }

nav a {
    margin-left: 15px;
    text-decoration: none;
    color: #555;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

nav a:hover, nav a.active {
    color: #007bff;
    background: rgba(0, 123, 255, 0.08);
}

.user-info { display: flex; align-items: center; gap: 15px; }
.main-content { padding: 25px; max-width: 1250px; margin: 0 auto; }

/* BOTÓN HAMBURGUESA: OCULTO POR DEFECTO EN PC */
.btn-hamburguesa-movil {
    display: none;
    background: #1e3c72;
    color: #ffffff;
    border: none;
    font-size: 24px;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    z-index: 10001;
}

/* DASHBOARD GRID EN COMPUTADORA */
.dashboard-grid.dashboard-grid-accesos {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 12px !important;
}

/* SECCIONES PRINCIPALES */
.section-view { display: none; }
.section-view.active { display: block; }

/* ESTRUCTURA DE AJUSTES */
.ajustes-layout {
    display: flex;
    gap: 30px;
    background: transparent;
    margin-top: 15px;
}

.ajustes-sidebar {
    width: 220px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 15px 0;
    height: fit-content;
}

.ajustes-sidebar-item {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s;
}

.ajustes-sidebar-item:hover, .ajustes-sidebar-item.active {
    background-color: #f8f9fa;
    color: #d9534f;
    border-left-color: #d9534f;
}

.ajustes-content-panel {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 30px;
    color: #333;
}

.ajustes-subview { display: none; }
.ajustes-subview.active { display: block; }

.tema-card {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
}
.tema-card:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.tema-card.selected {
    border-color: #28a745;
    background-color: #f8fff9;
}
.tema-preview-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(0,0,0,0.25);
    flex-shrink: 0;
}

.archivos-subnav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    flex-wrap: wrap;
}

.archivos-tab-btn {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    transition: all 0.2s;
}

.archivos-tab-btn:hover, .archivos-tab-btn.active {
    background: #1e3c72;
    color: white;
    border-color: #1e3c72;
}

.archivo-section { display: none; }
.archivo-section.active { display: block; }

/* ==========================================================================
   ADAPTACIÓN TOTAL Y EXCLUSIVA PARA CELULARES (MÁXIMO 860px)
   ========================================================================== */
@media screen and (max-width: 860px) {
    body {
        font-size: 14px;
        -webkit-tap-highlight-color: transparent;
    }

    #app-container, .main-content {
        padding: 8px !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* 1. Header móvil limpio */
    header {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 12px !important;
        flex-wrap: nowrap !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
    }

    #header-banner-principal {
        height: 46px !important;
        max-height: 46px !important;
        width: auto !important;
    }

    /* Mostrar botón hamburguesa */
    .btn-hamburguesa-movil {
        display: block !important;
    }

    .user-info {
        gap: 6px !important;
    }

    .user-info span#welcome-user {
        font-size: 11px !important;
        max-width: 85px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-info button {
        padding: 4px 6px !important;
        font-size: 10px !important;
    }

    /* 2. Menú desplegable oculto hasta hacer clic en ☰ */
    header nav#menu-navegacion-principal {
        display: none !important;
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        width: 100% !important;
        background: #ffffff !important;
        box-shadow: 0 12px 25px rgba(0,0,0,0.25) !important;
        flex-direction: column !important;
        padding: 8px 0 !important;
        z-index: 10000 !important;
        border-radius: 0 0 12px 12px !important;
        box-sizing: border-box !important;
    }

    header nav#menu-navegacion-principal.menu-abierto {
        display: flex !important;
    }

    header nav#menu-navegacion-principal a {
        display: block !important;
        width: 100% !important;
        padding: 12px 20px !important;
        margin: 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #334155 !important;
        text-align: left !important;
        box-sizing: border-box !important;
    }

    /* 3. ELEMENTOS SOLO ESCRITORIO OCULTOS EN CELULAR */
    .solo-escritorio,
    .dashboard-grid-accesos .solo-escritorio,
    #dash-btn-ventas,
    #dash-btn-ia,
    #dash-btn-ajustes,
    #nav-ventas,
    #nav-ia,
    #tab-ventas {
        display: none !important;
    }

    /* 4. BOTONES DEL DASHBOARD: EXACTAMENTE 2 POR FILA */
    .dashboard-grid.dashboard-grid-accesos {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* 2 por fila */
        gap: 8px !important;
        width: 100% !important;
        margin-top: 10px !important;
        box-sizing: border-box !important;
    }

    .dashboard-grid.dashboard-grid-accesos .card {
        min-height: 72px !important;
        padding: 8px 10px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }

    .dashboard-grid.dashboard-grid-accesos .card .card-icon {
        font-size: 20px !important;
    }

    .dashboard-grid.dashboard-grid-accesos .card h3 {
        font-size: 12.5px !important;
        white-space: normal !important;
    }

    .dashboard-grid.dashboard-grid-accesos .card p {
        font-size: 10.5px !important;
        white-space: normal !important;
    }

    /* 5. Tablas responsivas con desplazamiento */
    .tabla-responsive-container {
        width: 100% !important;
        max-height: 480px !important;
        overflow-y: auto !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        margin-bottom: 12px;
    }

    table {
        min-width: 580px;
        font-size: 12px !important;
    }

    table th, table td {
        padding: 8px 6px !important;
    }

    /* 6. Formatos táctiles */
    input, select, textarea, button {
        min-height: 40px;
    }

    .kpi-container-elegante {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
}

/* =======================================================
   ESTILOS ADAPTATIVOS PARA LA LISTA Y STOCK EN MÓVIL/TABLET
   ======================================================= */
.tabs-productos-movil {
    display: none;
}

.productos-cards-container-movil {
    display: none;
}

@media screen and (max-width: 860px) {
    /* 1. Ocultar tabla rígida en celulares/tablets */
    .tabla-productos-escritorio {
        display: none !important;
    }

    /* 2. Barra de Solapas ÍTEMS / STOCK (Fotos 3 y 4) */
    .tabs-productos-movil {
        display: flex !important;
        background: #ffffff;
        border-bottom: 2px solid #e2e8f0;
        margin-bottom: 12px;
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .tab-prod-btn {
        flex: 1;
        background: none;
        border: none;
        padding: 10px 0;
        font-size: 13px;
        font-weight: 800;
        color: #94a3b8;
        cursor: pointer;
        text-align: center;
        border-bottom: 3px solid transparent;
        transition: all 0.15s ease;
    }

    .tab-prod-btn.active {
        color: #0d9488 !important;
        border-bottom-color: #0d9488 !important;
    }

    /* 3. Contenedor de Tarjetas Móviles (Foto 2) */
    .productos-cards-container-movil {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .prod-card-movil {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.03);
        display: flex;
        flex-direction: column;
        gap: 8px;
        box-sizing: border-box;
        cursor: pointer;
    }

    .prod-card-movil-top {
        display: flex;
        gap: 12px;
        align-items: center;
    }

    .prod-card-movil-thumb {
        width: 65px;
        height: 65px;
        min-width: 65px;
        border-radius: 8px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 26px;
        overflow: hidden;
    }

    .prod-card-movil-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .prod-card-movil-info {
        flex: 1;
        min-width: 0;
    }

    .prod-card-movil-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-top: 1px dashed #e2e8f0;
        padding-top: 8px;
        margin-top: 2px;
    }

    /* Switch iOS para controlar stock */
    .switch-toggle-stock {
        position: relative;
        display: inline-block;
        width: 44px;
        height: 24px;
    }
    .switch-toggle-stock input {
        opacity: 0;
        width: 0;
        height: 0;
    }
    .slider-toggle-stock {
        position: absolute;
        cursor: pointer;
        top: 0; left: 0; right: 0; bottom: 0;
        background-color: #cbd5e1;
        transition: .3s;
        border-radius: 24px;
    }
    .slider-toggle-stock:before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        transition: .3s;
        border-radius: 50%;
    }
    .switch-toggle-stock input:checked + .slider-toggle-stock {
        background-color: #10b981;
    }
    .switch-toggle-stock input:checked + .slider-toggle-stock:before {
        transform: translateX(20px);
    }
}
