/* Variables de Diseño */
:root {
    --primary: #1E3A8A;
    --success: #10B981;
    --accent: #FBBF24;
    --surface-dark: #1b2842; /* 30% mas claro */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.12);
    --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Tipografía súper nítida y Anti-Blur en animaciones */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Forzar renderizado por hardware para evitar que el texto se distorsione al hacer hover/escala */
.transition-all, 
.transition-transform, 
.card-glass-vibrant,
[class*="scale-"] {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-font-smoothing: subpixel-antialiased;
    will-change: transform;
}

/* Fondo Cinematográfico (Verde, Azul, Amarillo) con 25% más de intensidad */
body {
    background: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.4) 0%, transparent 50%),
                radial-gradient(circle at 90% 80%, rgba(30, 58, 138, 0.5) 0%, transparent 50%),
                radial-gradient(circle at 50% 50%, rgba(243, 156, 18, 0.35) 0%, transparent 60%),
                var(--surface-dark);
    background-attachment: fixed;
    animation: cinematicFlow 20s infinite alternate ease-in-out;
}

@keyframes cinematicFlow {
    0% {
        background-position: 0% 0%, 100% 100%, 50% 50%;
    }
    100% {
        background-position: 20% 10%, 80% 90%, 40% 60%;
    }
}

/* Capa Cinematográfica (Viñeta Oscura en Bordes más suave) */
.cinematic-vignette {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.45) 120%);
    pointer-events: none;
    z-index: 40; /* Por debajo de menús pero encima de fondo */
}

/* Menú Superior - Plateado Satinado */
.header-glass {
    background: linear-gradient(135deg, rgba(200, 200, 200, 0.15) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(180, 180, 180, 0.1) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.glass-hero {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.2));
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.2), var(--shadow-premium);
    transform-style: preserve-3d;
}

.search-glass-container {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(0,0,0,0.1));
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255,255,255,0.05);
}

/* Tarjetas 3D Metálicas */
.card-glass-vibrant {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.3));
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(16px);
    transform-style: preserve-3d;
    perspective: 1200px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), inset 0 2px 5px rgba(255, 255, 255, 0.1);
}

.card-glass-vibrant:hover {
    transform: translateY(-15px) scale(1.02) rotateX(4deg) rotateY(-4deg);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 40px 80px -20px rgba(16, 185, 129, 0.25), 
                20px 20px 50px rgba(0,0,0,0.6),
                inset 0 2px 10px rgba(255,255,255,0.2);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.15));
}

/* Navegación */
.nav-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
    position: relative;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5); /* Nitidez extra */
}

.nav-link:hover,
.nav-link.active {
    color: white;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Animaciones de Brillo Metálico (Shimmer) */
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-25deg) translateX(-150%);
    transition: 0.5s;
}

button:hover::after {
    animation: shimmer 0.8s ease-in-out;
}

/* Animaciones Hero (Fade In Up) */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }

/* Footer Glass */
.footer-glass {
    background: linear-gradient(to top, rgba(6, 14, 32, 0.9), rgba(11, 19, 38, 0.8));
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Custom Dashboard Styles */
.sidebar-glass {
    background: linear-gradient(135deg, rgba(11, 19, 38, 0.8), rgba(20, 30, 50, 0.9));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid rgba(255,255,255,0.1);
    box-shadow: 5px 0 20px rgba(0,0,0,0.3);
    flex-shrink: 0;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.sidebar-glass > div:first-child,
.sidebar-glass > div:last-child {
    flex-shrink: 0;
}

.sidebar-glass > nav {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.sidebar-glass > nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-glass > nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.sidebar-link span.material-icons {
    font-size: 1.25rem;
}

.sidebar-link:hover {
    background: linear-gradient(90deg, rgba(255,255,255,0.1), transparent);
    color: white;
    transform: translateX(5px);
    border-left: 3px solid var(--success);
}

.sidebar-link.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border-left: 3px solid var(--success);
    text-shadow: 0 0 10px rgba(16,185,129,0.3);
}

/* Utilidades para los Logos */
.logo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px dashed rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.3s ease;
}

.logo-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 768px) {
    h1 { font-size: 2.4rem !important; }
    .glass-hero { padding: 2rem !important; border-radius: 24px; }
    .search-glass-container { flex-direction: column; padding: 1rem; }
    .search-glass-container button { width: 100%; }
    .logo-placeholder { width: 40px; height: 40px; }
}

/* Layout adaptable para paneles con sidebar: admin, empresario y futuras vistas */
body:has(.sidebar-glass) {
    min-height: 100dvh;
}

body:has(.sidebar-glass) > main {
    min-width: 0;
    min-height: 0;
}

body:has(.sidebar-glass) main header {
    min-width: 0;
}

body:has(.sidebar-glass) table {
    min-width: 760px;
}

@media (max-width: 1180px) {
    body:has(.sidebar-glass) > main {
        padding: 1.5rem !important;
    }

    body:has(.sidebar-glass) main header {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 1rem;
    }

    body:has(.sidebar-glass) main header h2 {
        font-size: clamp(1.75rem, 4vw, 2.75rem) !important;
        line-height: 1.12;
    }
}

@media (max-width: 900px) {
    body:has(.sidebar-glass) {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 100dvh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    body:has(.sidebar-glass) > .sidebar-glass {
        width: 100% !important;
        height: auto !important;
        max-height: none;
        position: sticky;
        top: 0;
        z-index: 80;
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    body:has(.sidebar-glass) > .sidebar-glass > div:first-child {
        flex-direction: row !important;
        justify-content: flex-start !important;
        padding: 1rem !important;
        text-align: left !important;
    }

    body:has(.sidebar-glass) > .sidebar-glass > div:first-child > div:first-child {
        width: 4rem !important;
        height: 4rem !important;
    }

    body:has(.sidebar-glass) > .sidebar-glass > nav {
        flex-direction: row !important;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.75rem 1rem !important;
        gap: 0.5rem !important;
        scrollbar-width: none;
    }

    body:has(.sidebar-glass) > .sidebar-glass > nav::-webkit-scrollbar {
        display: none;
    }

    body:has(.sidebar-glass) .sidebar-link {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 0.75rem 1rem;
    }

    body:has(.sidebar-glass) > .sidebar-glass > div:last-child {
        padding: 0 1rem 1rem !important;
    }

    body:has(.sidebar-glass) > main {
        overflow: visible !important;
        width: 100%;
        padding: 1rem !important;
    }
}

@media (max-width: 640px) {
    body:has(.sidebar-glass) > .sidebar-glass > div:first-child p {
        display: none;
    }

    body:has(.sidebar-glass) > .sidebar-glass > div:first-child h1 {
        font-size: 1rem !important;
    }

    body:has(.sidebar-glass) > .sidebar-glass > div:first-child h2 {
        font-size: 0.7rem !important;
    }

    body:has(.sidebar-glass) main header {
        padding: 1rem !important;
        border-radius: 1rem !important;
    }

    body:has(.sidebar-glass) main header > .w-16,
    body:has(.sidebar-glass) main header > .hidden.md\:flex {
        display: none !important;
    }

    body:has(.sidebar-glass) main header .flex.gap-4 {
        width: 100%;
        flex-wrap: wrap;
    }

    body:has(.sidebar-glass) main header button {
        flex: 1 1 160px;
        justify-content: center;
        padding: 0.75rem 1rem !important;
    }

    body:has(.sidebar-glass) .card-glass-vibrant {
        border-radius: 1rem;
    }

    #modalDetalleContent,
    #modalPreviewContent,
    #modalProductoContent,
    #modalEstablecimientoContent,
    #modalEditProductoAdminContent,
    #modalPreviewProductoAdminContent {
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 2rem !important; }
    .glass-hero { padding: 1.25rem !important; }
    body:has(.sidebar-glass) .sidebar-link {
        font-size: 0.78rem;
        padding: 0.65rem 0.8rem;
    }
}

/* Modales y paginas emergentes: scroll seguro en escritorio, tablet y movil */
[id*="Modal"].fixed.inset-0,
[id^="modal"].fixed.inset-0 {
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
}

[id*="Modal"].fixed.inset-0.items-center,
[id^="modal"].fixed.inset-0.items-center {
    align-items: flex-start !important;
}

[id*="Modal"].fixed.inset-0.justify-center,
[id^="modal"].fixed.inset-0.justify-center {
    justify-content: center !important;
}

[id*="Modal"].fixed.inset-0 > .card-glass-vibrant,
[id^="modal"].fixed.inset-0 > .card-glass-vibrant {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-top: auto;
    margin-bottom: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

[id*="Modal"].fixed.inset-0 > .card-glass-vibrant::-webkit-scrollbar,
[id^="modal"].fixed.inset-0 > .card-glass-vibrant::-webkit-scrollbar {
    width: 6px;
}

[id*="Modal"].fixed.inset-0 > .card-glass-vibrant::-webkit-scrollbar-thumb,
[id^="modal"].fixed.inset-0 > .card-glass-vibrant::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
}

#loginModal {
    align-items: flex-start !important;
    overflow-y: auto !important;
    padding: 1rem;
}

#loginModal > .card-glass-vibrant {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    margin-top: auto;
    margin-bottom: auto;
}

@media (max-width: 640px) {
    [id*="Modal"].fixed.inset-0,
    [id^="modal"].fixed.inset-0 {
        padding: 0.75rem !important;
    }

    [id*="Modal"].fixed.inset-0 > .card-glass-vibrant,
    [id^="modal"].fixed.inset-0 > .card-glass-vibrant,
    #loginModal > .card-glass-vibrant {
        width: 100% !important;
        max-height: calc(100dvh - 1.5rem);
        padding: 1.25rem !important;
        border-radius: 1rem !important;
    }

    #loginModal .h-36 {
        height: 5.5rem !important;
    }

    #loginModal form {
        gap: 1rem !important;
    }

    #loginModal input {
        padding: 0.85rem 1rem !important;
        font-size: 1rem !important;
    }

    #loginModal button[type="submit"] {
        padding: 0.95rem 1rem !important;
        font-size: 1rem !important;
    }

    [id*="Modal"].fixed.inset-0 h2,
    [id^="modal"].fixed.inset-0 h2 {
        font-size: clamp(1.6rem, 7vw, 2.25rem) !important;
    }

    [id*="Modal"].fixed.inset-0 h3,
    [id^="modal"].fixed.inset-0 h3 {
        font-size: clamp(1.25rem, 6vw, 1.75rem) !important;
        line-height: 1.15;
    }

    [id*="Modal"].fixed.inset-0 form,
    [id^="modal"].fixed.inset-0 form {
        grid-template-columns: 1fr !important;
    }

    [id*="Modal"].fixed.inset-0 .md\:col-span-2,
    [id^="modal"].fixed.inset-0 .md\:col-span-2 {
        grid-column: auto !important;
    }
}
/* Hide scrollbar for horizontal scroll containers */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
