﻿/* --- NUEVA FUENTE --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* Estilos generales */
.hidden { display: none; }
.view, .modal { display: none; }
.view.active, .modal.active { display: flex; }
.nav-link.active { 
    /* NUEVO: Estilo de link activo más notorio */
    background-color: #6d28d9; /* bg-purple-700 */
    border-left-color: #a855f7; /* border-purple-500 */
    color: white;
    font-weight: 600;
}

#realtime-clock {
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    color: #fefce8;
    text-shadow: 0 0 6px rgba(15, 23, 42, 0.45);
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 150px;
    text-align: right;
    white-space: nowrap;
}
.dark #realtime-clock {
    color: #fcd34d;
}

/* Estilos para impresión */
@media print {
    aside, .no-print { display: none !important; }
    main.view, #app-container { display: block !important; }
    main.view { width: 100% !important; height: auto !important; overflow: visible !important; }
    header, footer, .shadow, .rounded-lg { box-shadow: none !important; border-radius: 0 !important; }
    .p-6 { padding: 0 !important; }
    html, body { background: #fff !important; color: #000 !important; }
}

body.printing-receipt {
    background: #fff;
}

body.printing-receipt #receipt-print-area {
    display: block !important;
}

body.printing-receipt #app-container,
body.printing-receipt #login-container,
body.printing-receipt #loader,
body.printing-receipt footer,
body.printing-receipt #toast-container,
body.printing-receipt .modal {
    display: none !important;
}

@media print {
    body.printing-receipt #receipt-print-area {
        display: block !important;
        visibility: visible !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }
    body.printing-receipt *:not(#receipt-print-area):not(#receipt-print-area *) {
        visibility: hidden !important;
    }
    body.printing-receipt #receipt-print-area,
    body.printing-receipt #receipt-print-area * {
        visibility: visible !important;
    }
}

#receipt-print-area {
    font-family: 'Poppins', sans-serif;
    padding: 16px;
}

.receipt-wrapper {
    max-width: 320px;
    margin: 0 auto;
    border: 1px dashed #cbd5f5;
    padding: 16px;
    font-size: 12px;
    color: #0f172a;
}

.receipt-header {
    text-align: center;
    margin-bottom: 12px;
}

.receipt-header img {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
    margin: 0 auto 8px auto;
}

.receipt-brand-fallback {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.receipt-meta {
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    margin-bottom: 8px;
}

.receipt-items {
    margin: 12px 0;
    border-top: 1px dashed #cbd5f5;
    border-bottom: 1px dashed #cbd5f5;
    padding: 8px 0;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 4px;
}

.receipt-item span {
    display: block;
}

.receipt-totals {
    margin-top: 8px;
    font-size: 12px;
}

.receipt-totals .row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.receipt-totals .row.total {
    font-weight: 600;
    font-size: 13px;
}

.receipt-payment {
    margin-top: 10px;
    font-size: 12px;
}

.receipt-payment .row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.receipt-footer {
    margin-top: 12px;
    text-align: center;
    font-size: 11px;
    line-height: 1.4;
}

.receipt-divider {
    border-top: 1px dashed #cbd5f5;
    margin: 8px 0;
}

/* Asegurar que el body no tenga margen ni desplazamiento no deseado */
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    /* NUEVO: Aplicar la fuente Poppins a todo */
    font-family: 'Poppins', sans-serif;
}

#app-container {
    min-height: 100vh;
    width: 100%;
}

.view-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.header-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
}

.header-actions > * {
    width: 100%;
}

@media (min-width: 768px) {
    .view-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .header-actions {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        width: auto;
    }

    .header-actions > * {
        width: auto;
    }
}

/* --- NUEVAS ANIMACIONES RADICALES --- */

/* 1. Animación de Fondo "Aurora" */
@keyframes aurora {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.aurora-bg {
    /* Este es el fondo para el modo oscuro */
    background: linear-gradient(-45deg, #0f172a, #1e1b4b, #312e81, #0f172a);
    background-size: 400% 400%;
    animation: aurora 15s ease infinite;
}
/* El modo claro no tendrá la aurora, solo un fondo limpio */
body:not(.dark) .aurora-bg {
    background: #f1f5f9; /* bg-slate-100 */
    animation: none;
}


/* 2. Animación de "Brillo Neón" para botones */
.neon-glow-purple:hover {
    box-shadow: 0 0 15px 3px rgba(168, 85, 247, 0.6), /* Sombra exterior púrpura */
                 0 0 5px 1px rgba(255, 255, 255, 0.7) inset; /* Brillo interior */
}
.neon-glow-green:hover {
    box-shadow: 0 0 15px 3px rgba(16, 185, 129, 0.6), 
                 0 0 5px 1px rgba(255, 255, 255, 0.7) inset;
}
.neon-glow-red:hover {
    box-shadow: 0 0 15px 3px rgba(239, 68, 68, 0.6), 
                 0 0 5px 1px rgba(255, 255, 255, 0.7) inset;
}
.neon-glow-teal:hover {
    box-shadow: 0 0 15px 3px rgba(20, 184, 166, 0.6),
                 0 0 5px 1px rgba(255, 255, 255, 0.7) inset;
}
.neon-glow-gray:hover {
    box-shadow: 0 0 15px 3px rgba(107, 114, 128, 0.6),
                 0 0 5px 1px rgba(255, 255, 255, 0.7) inset;
}


/* 3. Animación de "Fade In Up" para vistas y tarjetas */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.fade-in-up {
    animation: fade-in-up 0.5s ease-out forwards;
}

/* 4. Animación de "Rebote" para Modales */
@keyframes modal-bounce-in {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    80% {
        transform: scale(1.02);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
.modal-bounce-in {
    animation: modal-bounce-in 0.3s ease-out;
}
.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Fin de nuevas animaciones */


/* Estilo para vistas activas */
.view.active {
    display: flex; /* Asegura flexibilidad en vistas */
    flex-direction: column; /* Alinea elementos verticalmente */
    flex: 1; /* Ocupa el espacio disponible */
    overflow: auto; /* Permite scroll interno */
    
    /* NUEVO: Aplicar animación de entrada a la vista */
    animation: fade-in-up 0.4s ease-out;
}

/* Estilo para el contenedor principal */
#main-content {
    display: flex;
    flex-direction: column;
    flex: 1; /* Ocupa el espacio restante */
    overflow: auto; /* Permite scroll interno */
}

/* Estilo para vistas dentro del main */
#main-content .view {
    display: none; /* Oculto por defecto */
    flex-direction: column; /* Asegura estructura interna */
    flex: 1; /* Ocupa el espacio disponible dentro de main */
}

#main-content .view.active {
    display: flex; /* Mostrar solo la activa */
}

#app-container {
    position: relative; /* Contenedor principal */
}

#main-content {
    position: relative; /* Contenedor de vistas */
    z-index: 10; 
}

#sidebar {
    z-index: 30; 
    display: flex;
    flex-direction: column;
    max-height: 100vh;
}

#sidebar nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

#sidebar-footer {
    position: sticky;
    bottom: 0;
    background-color: #0f172a;
    z-index: 5;
}

#sidebar-overlay {
    z-index: 20; 
}

/* Ajustes responsivos para móvil */
@media (max-width: 767px) {
    #sidebar {
        z-index: 40;
        width: min(18rem, 85vw);
    }
    #sidebar-overlay {
        z-index: 35;
    }
    #mobile-menu-button {
        top: 1rem;
        left: 1rem;
    }
    #main-content {
        padding: 4.5rem 0.75rem 2rem;
    }
    #main-content .view {
        padding: 1rem 0;
        gap: 1rem;
    }
    #main-content .view header {
        padding: 1rem;
        gap: 1rem;
    }
    #inventory-view #searchInput {
        font-size: 0.95rem;
    }
    #inventory-stats-bar {
        margin-top: 0.5rem;
        top: 0.5rem;
    }
    #inventory-stats-bar h3 {
        font-size: 0.75rem;
    }
    #inventory-stats-bar p {
        font-size: 1rem;
    }
    .header-actions button {
        font-size: 0.95rem;
    }
    #inventory-view table th,
    #inventory-view table td {
        font-size: 0.78rem;
        padding: 0.5rem;
        white-space: nowrap;
    }
    #inventory-view table td:first-child {
        white-space: normal;
    }
}


/* **** CORRECCIÓN **** */
/* Estilos del carrito re-agregados y adaptados al nuevo tema "Aura" */
/* Ahora usan 'body.dark' para forzar los colores sin tocar tu JS */

body.dark #cart-items-container {
    border-color: #334155; /* dark:border-slate-700 */
    background-color: #0f172a; /* dark:bg-slate-900/50 */
}

#cart-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* space-y-2 */
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem; /* p-2 */
    border-bottom: 1px solid #e2e8f0; /* border-b border-slate-200 */
}

body.dark .cart-item {
    border-bottom-color: #334155; /* dark:border-slate-700 */
}

.cart-item:last-child {
    border-bottom: none; /* border-b-0 */
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-name {
    font-weight: 500; /* font-medium */
    font-size: 0.875rem; /* text-sm */
    color: #ffffff; /* text-slate-800 */
}
body.dark .cart-item-name {
    color: #f1f9f4; /* dark:text-slate-100 */
}

.cart-item-price {
    font-size: 0.75rem; /* text-xs */
    color: #64748b; /* text-slate-500 */
    margin-top: 0.125rem; /* mt-1 */
}
body.dark .cart-item-price {
    color: #94a3b8; /* dark:text-slate-400 */
}

.cart-item-quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem; /* space-x-1 */
    margin: 0 0.5rem; /* mx-2 */
}

.quantity-btn {
    background-color: #cbd5e1; /* bg-slate-300 */
    border: none;
    border-radius: 0.25rem; /* rounded */
    width: 1.5rem; /* w-6 */
    height: 1.5rem; /* h-6 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem; /* text-sm */
    cursor: pointer;
    color: #0f172a; /* text-slate-800 */
    transition: all 0.2s;
}
.quantity-btn:hover {
    background-color: #94a3b8; /* hover:bg-slate-400 */
}
body.dark .quantity-btn {
    background-color: #475569; /* dark:bg-slate-600 */
    color: #f1f5f9; /* dark:text-white */
}
body.dark .quantity-btn:hover {
    background-color: #64748b; /* dark:hover:bg-slate-500 */
}

.quantity-input {
    width: 3rem; /* w-12 */
    text-align: center;
    border: 1px solid #cbd5e1; /* border border-slate-300 */
    background-color: #242222; /* bg-white */
    border-radius: 0.25rem; /* rounded */
    padding: 0.125rem 0; /* py-0.5 */
    font-size: 0.875rem; /* text-sm */
}
body.dark .quantity-input {
    background-color: #334155; /* dark:bg-slate-700 */
    border-color: #475569; /* dark:border-slate-600 */
    color: #f1f5f9; /* dark:text-white */
}
.quantity-input:focus {
    outline: none;
    border-color: #a855f7; /* focus:border-purple-500 */
}

.remove-item-btn {
    background-color: #dc2626; /* bg-red-600 */
    color: rgb(92, 1, 1);
    border: none;
    border-radius: 0.25rem; /* rounded */
    padding: 0.25rem 0.5rem; /* px-2 py-1 */
    font-size: 0.75rem; /* text-xs */
    cursor: pointer;
    transition: all 0.2s;
}
.remove-item-btn:hover {
    background-color: #b91c1c; /* hover:bg-red-700 */
}

#empty-cart-message {
    padding: 1rem; /* p-4 */
    text-align: center;
    color: #64748b; /* text-slate-500 */
}
body.dark #empty-cart-message {
    color: #94a3b8; /* dark:text-slate-400 */
}
/* --- Fin de la corrección del carrito --- */

/* --- Toast Notifications --- */
.toast {
    background: #1f2937;
    color: #f8fafc;
    border-left: 4px solid transparent;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.4);
    opacity: 0;
    transform: translateY(12px);
    min-width: 220px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-left-color: #bbf7d0;
}
.toast.error {
    background: linear-gradient(135deg, #f87171, #ef4444);
    border-left-color: #fee2e2;
}
.toast.warning {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-left-color: #fef3c7;
}
.toast.info {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    border-left-color: #bae6fd;
}
/* --- Fin Toast Notifications --- */

/* --- Permission Toggle --- */
.permission-switch {
    position: relative;
    display: inline-flex;
    width: 42px;
    height: 22px;
}
.permission-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.permission-switch .permission-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5f5;
    transition: 0.3s;
    border-radius: 9999px;
    box-shadow: inset 0 0 5px rgba(15, 23, 42, 0.2);
}
.dark .permission-switch .permission-slider {
    background-color: #475569;
}
.permission-switch .permission-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: #fff;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
}
.permission-switch input:checked + .permission-slider {
    background-color: #34d399;
}
.permission-switch input:checked + .permission-slider::before {
    transform: translateX(20px);
}
/* --- Fin Permission Toggle --- */

/* Estilo para el botón flotante del carrito (Se mantiene por 'position: absolute') */
#view-cart-btn {
    position: relative; /* Para posicionar el contador */
}

#cart-count {
    position: absolute;
    top: -5px; 
    right: -5px; 
    background-color: #ef4444; /* bg-red-500 */
    color: rgb(255, 255, 255);
    border-radius: 50%; /* rounded-full */
    width: 1.25rem; /* w-5 */
    height: 1.25rem; /* h-5 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem; /* text-xs */
    font-weight: bold;
}


/* Ajustes responsivos adicionales */
@media (max-width: 767px) {
    #main-content {
        overflow: visible;
    }

    .view,
    .view.active {
        min-height: auto;
        overflow: visible;
    }

    .header-actions {
        align-items: stretch;
    }

    .header-actions > * {
        width: 100%;
    }

    .header-actions button,
    .header-actions a,
    .header-actions span {
        justify-content: center;
        text-align: center;
    }

    #inventory-view .flex-1.overflow-auto.mb-4 {
        height: auto;
        overflow: visible;
    }

    #inventory-view footer {
        text-align: center;
    }
}
