:root {
    --bg-color: #f4f6f9;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-orange: #f97316;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --border-color: #e2e8f0;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}

/* --- TEMAS VISUALES PREMIUM --- */

/* 1. TEMA ESTÁNDAR (Cristal - Por Defecto) */
/* Ya definido en el :root principal, pero lo reforzamos con toques de glassmorphism */
:root[data-theme="cristal"] {
    --bg-color: #ffffff; /* Fondo blanco puro a peticion del usuario */
    --surface-color: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-blue: #2563eb;
    --accent-orange: #f97316;
    --border-color: #e2e8f0;
    --card-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.08), 0 8px 10px -6px rgba(59, 130, 246, 0.04);
}
:root[data-theme="cristal"] body { background: #ffffff; min-height: 100vh; }
:root[data-theme="cristal"] .app-header { background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255, 255, 255, 0.5); }
:root[data-theme="cristal"] .menu-item { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 1); box-shadow: 0 10px 20px rgba(0,0,0,0.03); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease; }
:root[data-theme="cristal"] .menu-item:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 15px 30px rgba(37, 99, 235, 0.1); }
:root[data-theme="cristal"] .bottom-nav { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); }

/* 2. TEMA OSCURO (Industrial) */
:root[data-theme="oscuro"] {
    --bg-color: #09090b; /* Muy oscuro, casi negro */
    --surface-color: #18181b; /* Gris oscuro para tarjetas */
    --text-primary: #f8fafc;
    --text-secondary: #a1a1aa;
    --accent-blue: #38bdf8; /* Azul neón brillante */
    --accent-orange: #fb923c;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --border-color: #27272a;
    --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
}
:root[data-theme="oscuro"] body { background-color: var(--bg-color); background-image: radial-gradient(circle at top right, rgba(56, 189, 248, 0.05) 0%, transparent 40%); }
:root[data-theme="oscuro"] .app-header { background: rgba(24, 24, 27, 0.85); backdrop-filter: blur(10px); border-bottom: 1px solid #27272a; }
:root[data-theme="oscuro"] .menu-item { background: linear-gradient(145deg, #18181b 0%, #27272a 100%); border: 1px solid #3f3f46; box-shadow: var(--card-shadow); border-radius: 20px; }
:root[data-theme="oscuro"] .menu-item:hover { transform: translateY(-3px); box-shadow: 0 0 20px rgba(56, 189, 248, 0.15), inset 0 0 0 1px rgba(56, 189, 248, 0.3); }
:root[data-theme="oscuro"] .menu-item span { color: #f4f4f5; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
:root[data-theme="oscuro"] .illustration-container { box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.05), 0 8px 16px -4px rgba(0, 0, 0, 0.5); background: rgba(0,0,0,0.2); }
:root[data-theme="oscuro"] .modal-content, :root[data-theme="oscuro"] .app-form { background: #18181b; border: 1px solid #27272a; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 1); }
:root[data-theme="oscuro"] input, :root[data-theme="oscuro"] select { background-color: #09090b; color: #f8fafc; border-color: #3f3f46; }
:root[data-theme="oscuro"] input:focus, :root[data-theme="oscuro"] select:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2); }
:root[data-theme="oscuro"] .bottom-nav { background: #18181b; border-top: 1px solid #27272a; }
:root[data-theme="oscuro"] .bottom-nav-item.active { color: var(--accent-blue); background: rgba(56, 189, 248, 0.1); }

/* 3. TEMA MINIMALISTA (Corporativo) */
:root[data-theme="minimalista"] {
    --bg-color: #ffffff;
    --surface-color: #ffffff;
    --text-primary: #000000; /* Contraste máximo */
    --text-secondary: #525252;
    --accent-blue: #000000; /* Todo se vuelve muy sobrio, acentos en negro/gris oscuro */
    --accent-orange: #171717;
    --accent-green: #166534;
    --accent-red: #991b1b;
    --border-color: #d4d4d8;
    --card-shadow: none; /* Sin sombras difusas */
}
:root[data-theme="minimalista"] body { background-color: #fafafa; }
:root[data-theme="minimalista"] .app-header { background: #ffffff; border-bottom: 2px solid #000000; box-shadow: none; }
:root[data-theme="minimalista"] .app-header h1 { font-weight: 800; letter-spacing: -0.5px; color: #000000; }
:root[data-theme="minimalista"] .menu-item { background: #ffffff; border: 2px solid #e5e5e5; box-shadow: 4px 4px 0px #e5e5e5; border-radius: 4px; transition: all 0.15s ease-out; }
:root[data-theme="minimalista"] .menu-item:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0px #d4d4d8; border-color: #000000; }
:root[data-theme="minimalista"] .menu-item:active { transform: translate(4px, 4px); box-shadow: 0px 0px 0px #000000; }
:root[data-theme="minimalista"] .menu-item span { font-weight: 800; color: #000000; letter-spacing: 0; }
:root[data-theme="minimalista"] .illustration-container { box-shadow: none; border-radius: 4px; border: 2px solid #000000; background: #ffffff; }
:root[data-theme="minimalista"] .modal-content, :root[data-theme="minimalista"] .app-form { background: #ffffff; border: 3px solid #000000; border-radius: 0; box-shadow: 12px 12px 0px rgba(0,0,0,0.1); }
:root[data-theme="minimalista"] .btn { border-radius: 0; box-shadow: 4px 4px 0px rgba(0,0,0,1); border: 2px solid #000; font-weight: 800; text-transform: uppercase; }
:root[data-theme="minimalista"] .btn:active { transform: translate(4px, 4px); box-shadow: 0px 0px 0px rgba(0,0,0,1); }
:root[data-theme="minimalista"] input, :root[data-theme="minimalista"] select { border-radius: 0; border: 2px solid #d4d4d8; background: #fafafa; }
:root[data-theme="minimalista"] input:focus, :root[data-theme="minimalista"] select:focus { border-color: #000000; box-shadow: 4px 4px 0px rgba(0,0,0,0.1); }
:root[data-theme="minimalista"] .bottom-nav { background: #ffffff; border-top: 2px solid #000000; }
:root[data-theme="minimalista"] .bottom-nav-item.active { background: #000000; color: #ffffff; border-radius: 0; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #cbd5e1;
    /* Darker bg for desktop */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Mobile Wrapper Trick */
#app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    max-height: 900px;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@media (min-width: 481px) {
    #app-container {
        height: 90vh;
        border-radius: 24px;
    }
}

/* HEADER */
.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(20px + env(safe-area-inset-top)) 24px 20px 24px;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
    flex-shrink: 0;
}

.menu-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
}

#screen-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* VIEWS - the pages */
.view {
    display: none;
    /* hidden by default */
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 80px;
    /* Space for bottom nav */
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* MENU GRID */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.menu-item {
    background: linear-gradient(145deg, var(--surface-color) 0%, #f8fafc 100%);
    border-radius: 24px;
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.menu-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.menu-item:hover::before {
    opacity: 1;
}

.menu-item:active {
    transform: scale(0.96) translateY(0);
}

.illustration-container {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.8), 0 8px 16px -4px rgba(0, 0, 0, 0.1);
}

.premium-icon {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.bg-gradient-orange {
    background: linear-gradient(135deg, #fffed4 0%, #fed7aa 100%);
}

.bg-gradient-blue {
    background: linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 100%);
}

.bg-gradient-green {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.bg-gradient-red {
    background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
}

.menu-item span {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

/* FORMS */
.app-form {
    background: var(--surface-color);
    padding: 24px;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.row-group {
    display: flex;
    gap: 16px;
}

.row-group .form-group {
    flex: 1;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

input,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    background-color: #f8fafc;
    transition: all 0.2s;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent-orange);
    background-color: var(--surface-color);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-right: 48px;
}

.input-with-icon i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 20px;
}

.form-actions {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.btn {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.8;
}

.btn-primary {
    background-color: var(--accent-orange);
    color: white;
    box-shadow: 0 8px 16px -4px rgba(249, 115, 22, 0.4);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.scanner-placeholder {
    height: 180px;
    background: #0f172a;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.scanner-placeholder i {
    font-size: 32px;
}

.scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% {
        top: 0%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

/* BOTTOM NAVIGATION */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface-color);
    display: flex;
    justify-content: space-around;
    padding: 12px 0 calc(20px + env(safe-area-inset-bottom)) 0;
    border-top: 1px solid var(--border-color);
    z-index: 10;
}

@media (min-width: 481px) {
    .bottom-nav {
        padding-bottom: 12px;
        border-bottom-left-radius: 24px;
        border-bottom-right-radius: 24px;
    }
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn span {
    font-size: 10px;
    font-weight: 600;
}

.nav-btn.active {
    color: var(--accent-orange);
}

/* --- MODALS E IMPRESIÓN --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 20px;
}

#print-modal,
#edit-modal {
    z-index: 9999999 !important;
    /* Forzar que el ticket pase por encima de cualquier teclado o input bloqueqdo */
}

/* Evitar el bug de Safari/Chrome donde align-items: center desplaza el div visual pero su TouchTarget se queda abajo al abrir teclado */
#print-modal,
#edit-modal {
    align-items: flex-start !important;
    padding-top: 2vh;
}

#print-modal .form-actions,
#edit-modal .form-actions {
    position: relative;
    z-index: 9999999;
    pointer-events: auto !important;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Configuración para móviles pequeños: habilitar scroll interno y bloquear scroll de fondo */
    max-height: 80vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Print styles are now injected dynamically via app.js to prevent conflicts between different ticket sizes */

/* --- PREVISIONES (v322) --- */
.campana-chip {
    padding: 6px 10px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    color: #475569;
    border: 1px solid #cbd5e1;
    transition: all 0.2s;
}

.campana-chip:hover {
    background: #e2e8f0;
}

.campana-chip.active {
    background: #ddd6fe;
    color: #7c3aed;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

/* FORZAR Z-INDEX DE SWEETALERT (v575) */
.swal2-container {
    z-index: 20000 !important;
}