:root {
    /* Color Palette - Cyber Astroboy Theme */
    --bg-color: #050b14; /* Deep Space Black */
    --panel-bg: rgba(10, 20, 35, 0.65); /* Astro Blue-Black with opacity */
    --text-primary: #e2f1ff;
    --text-secondary: #82a8d4;
    
    /* Thematic Colors */
    --astro-plasma: #00f0ff; /* Neon Cyan / Blue Plasma */
    --astro-engine: #ff2a2a; /* Astroboy Boots Red */
    --astro-gold: #ffbe0b;   /* Energy Gold */
    --success-color: #00ff88; /* Neon Green */
    --danger-color: #ff2a2a; /* Red */
    
    --glow-plasma: rgba(0, 240, 255, 0.4);
    --glow-engine: rgba(255, 42, 42, 0.4);
    
    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    /* Grid background to give that sci-fi lab feel */
    background-image: 
        linear-gradient(rgba(0, 240, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 240, 255, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 50% 0%, rgba(0, 240, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(255, 42, 42, 0.1) 0%, transparent 50%);
    background-size: 30px 30px, 30px 30px, 100% 100%, 100% 100%;
    background-attachment: fixed;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: var(--astro-plasma); border-radius: 4px; }

/* Glassmorphism utility */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0,240,255,0.05);
}

.gradient-border {
    position: relative;
}
.gradient-border::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 18px;
    background: linear-gradient(45deg, var(--astro-plasma), transparent, var(--astro-engine));
    z-index: -1;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}
.gradient-border:hover::before {
    opacity: 1;
    filter: blur(4px);
}

/* =========================================
   INTRO ANIMATION
========================================= */
#intro-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, rgba(0, 240, 255, 0.15) 0%, rgba(255, 42, 42, 0.05) 50%, var(--bg-color) 100%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease;
}

#intro-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.flying-astro {
    width: 400px;
    filter: drop-shadow(0 0 30px var(--astro-plasma));
    animation: flyAcross 2.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes flyAcross {
    0% {
        transform: translate(-100vw, 50vh) scale(0.3) rotate(-30deg);
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Password Toggle Styles */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrapper input {
    padding-right: 3rem;
    width: 100%;
}
.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
.toggle-password:hover {
    color: var(--astro-plasma);
    text-shadow: 0 0 10px var(--glow-plasma);
}

/* =========================================
   LOGIN SCREEN SPECIFICS
========================================= */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    text-align: center;
    animation: bootUp 1.2s cubic-bezier(0.17, 0.84, 0.44, 1) 2.5s both;
}

@keyframes bootUp {
    0% { transform: scale(0.8) translateY(50px); opacity: 0; filter: blur(10px); }
    100% { transform: scale(1) translateY(0); opacity: 1; filter: blur(0); }
}

.login-logo {
    margin-bottom: 2rem;
}
.login-logo h1 {
    font-size: 2.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}
.login-logo span {
    color: var(--astro-plasma);
    text-shadow: 0 0 10px var(--astro-plasma);
}
.login-logo .subtitle {
    color: var(--astro-engine);
    font-size: 0.9rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    position: relative;
    text-align: left;
}
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.input-group input {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--astro-plasma);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
    background: rgba(0, 240, 255, 0.05);
}

.btn-login {
    margin-top: 1rem;
    padding: 1.2rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--astro-plasma), #0077ff);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: 0 0 20px var(--glow-plasma);
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px var(--glow-plasma);
}
.btn-login::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(45deg) translateX(-100%);
    transition: transform 0.6s ease;
}
.btn-login:hover::after {
    transform: rotate(45deg) translateX(100%);
}

.login-error {
    color: var(--astro-engine);
    font-size: 0.9rem;
    min-height: 20px;
    text-shadow: 0 0 5px rgba(255, 42, 42, 0.5);
}


/* =========================================
   DASHBOARD / POS LAYOUT (UPDATED THEME)
========================================= */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    margin: 1rem;
}

.logo h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
}
.logo span {
    color: var(--astro-plasma);
    text-shadow: 0 0 10px var(--glow-plasma);
}

.nav-links {
    list-style: none;
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: block;
    border: 1px solid transparent;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--astro-plasma);
    background: rgba(0, 240, 255, 0.05);
    border-color: rgba(0, 240, 255, 0.2);
    transform: translateX(5px);
    box-shadow: inset 4px 0 0 var(--astro-plasma);
}

.main-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
}
.topbar h1 {
    font-weight: 300;
    letter-spacing: 1px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--astro-plasma), #0077ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 0 10px var(--glow-plasma);
}
.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: color 0.3s;
}
.logout-btn:hover {
    color: var(--astro-engine);
}

/* Dashboard Widgets */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.3s;
}
.card:hover {
    transform: translateY(-5px);
}
.card h3 {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.amount {
    font-size: 2.5rem;
    font-weight: 800;
}
.amount.expense { color: var(--astro-engine); text-shadow: 0 0 10px var(--glow-engine); }
.amount.net { color: var(--success-color); text-shadow: 0 0 10px rgba(0, 255, 136, 0.4); }

/* Analytics Dashboard Section */
.analytics-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.filters {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filters h3 {
    color: var(--text-secondary);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.date-pickers {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date-input {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 240, 255, 0.2);
    background: rgba(0,0,0,0.4);
    color: white;
    font-family: inherit;
}

.date-input:focus {
    outline: none;
    border-color: var(--astro-plasma);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.chart-container, .top-products-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-container h3, .top-products-container h3 {
    color: var(--text-secondary);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.chart-container canvas {
    width: 100% !important;
    height: 350px !important;
}

.top-products-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    max-height: 350px;
    padding-right: 5px;
}

.top-product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    border-left: 3px solid var(--astro-gold);
    transition: transform 0.3s;
}

.top-product-item:hover {
    transform: translateX(5px);
    background: rgba(0, 240, 255, 0.05);
}

.product-info strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.product-info small {
    color: var(--astro-plasma);
    text-transform: uppercase;
    font-size: 0.75rem;
}

.product-stats {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.product-stats .qty {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.product-stats .prof {
    color: var(--success-color);
    font-weight: bold;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}
.primary-btn {
    background-color: rgba(0, 240, 255, 0.1);
    color: var(--astro-plasma);
    border: 1px solid rgba(0, 240, 255, 0.3);
}
.primary-btn:hover {
    background-color: rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}
.action-btn {
    background: linear-gradient(90deg, var(--astro-plasma), #0077ff);
    color: white;
    box-shadow: 0 0 15px var(--glow-plasma);
}
.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--glow-plasma);
}
.action-btn:disabled {
    background: #1e293b;
    color: #64748b;
    box-shadow: none;
    cursor: not-allowed;
}
.full-width {
    width: 100%;
}

/* POS Layout */
.pos-layout .pos-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    flex: 1;
}

.products-area, .cart-area {
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.pos-form {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-group label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
}
.form-group input, .form-group select {
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 240, 255, 0.2);
    background: rgba(0,0,0,0.4);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: border 0.3s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--astro-plasma);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    max-height: 45vh;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 5px;
}
.empty-cart {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 2rem;
    font-style: italic;
}
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    border-left: 3px solid var(--astro-plasma);
}
.cart-item .item-info h4 {
    margin-bottom: 0.3rem;
    color: var(--text-primary);
}
.cart-item .item-info small {
    color: var(--text-secondary);
}
.cart-total {
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(0, 240, 255, 0.1);
}
.cart-total h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}
.cart-total p {
    font-size: 2rem;
    font-weight: 800;
    color: var(--success-color);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

/* Catalog Product Cards */
#products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.product-card {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}
.product-card:hover {
    transform: translateY(-5px);
    border-color: var(--astro-plasma);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}
.status-indicator {
    width: 10px; height: 10px;
    border-radius: 50%;
    position: absolute;
    top: 15px; right: 15px;
}
.status-verde { background: #00ff88; box-shadow: 0 0 8px #00ff88; }
.status-amarillo { background: #ffbe0b; box-shadow: 0 0 8px #ffbe0b; }
.status-rojo { background: #ff2a2a; box-shadow: 0 0 8px #ff2a2a; }

.product-card h4 {
    margin-bottom: 5px;
    font-size: 1rem;
    padding-right: 15px; /* Para que no pise el semáforo */
}
.brand-text {
    font-size: 0.75rem;
    color: var(--astro-plasma);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
.price-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}
.suggested-price {
    font-weight: bold;
    color: var(--success-color);
    font-size: 1.1rem;
}

/* Brand Cards */
.brand-card {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.brand-card:hover {
    transform: translateY(-5px);
    border-color: var(--astro-plasma);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}
.brand-img-container {
    height: 150px;
    width: 100%;
    background-color: rgba(0,0,0,0.3);
}
.brand-name-container {
    padding: 15px;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid rgba(0, 240, 255, 0.1);
}
.brand-name-container h3 {
    margin: 0;
    font-size: 1.1rem;
    color: white;
    text-shadow: 0 0 5px var(--glow-plasma);
    text-transform: uppercase;
}

/* Fix Calendar Icon Color for dark theme */
::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* History Tickets */
.ticket-card {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: rgba(0, 240, 255, 0.05);
    transition: background 0.3s;
}
.ticket-header:hover {
    background: rgba(0, 240, 255, 0.1);
}

.ticket-summary {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.ticket-summary .total {
    font-weight: bold;
    color: var(--astro-plasma);
    font-size: 1.2rem;
}

.ticket-summary .profit {
    color: var(--success-color);
}

.ticket-body {
    padding: 1.5rem;
    border-top: 1px solid rgba(0, 240, 255, 0.1);
    background: rgba(0,0,0,0.6);
    overflow-x: auto;
}

.history-table th {
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.history-table td {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Filtro Activo */
.active-filter {
    background: var(--astro-plasma) !important;
    color: black !important;
    font-weight: bold;
    box-shadow: 0 0 10px var(--astro-plasma);
}

/* Modals */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    margin: 10% auto;
    padding: 20px;
    width: 80%;
}

/* =========================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
========================================= */

@media (max-width: 1024px) {
    /* Adjust POS container for tablets */
    .pos-layout .pos-container {
        grid-template-columns: 1fr;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        /* Prevent elastic scroll on mobile if possible */
        overscroll-behavior-y: none;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding-bottom: 70px; /* Espacio para el menú inferior */
        overflow-y: visible;
    }

    /* Transform Sidebar into Bottom Nav */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        margin: 0;
        padding: 0;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        border-radius: 0;
        border-top: 1px solid rgba(0, 240, 255, 0.15);
        border-bottom: none;
        border-left: none;
        border-right: none;
        z-index: 1000;
        background: rgba(10, 20, 35, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .sidebar .logo {
        display: none; /* Ocultar el logo en el menú inferior para dar espacio */
    }

    .nav-links {
        margin-top: 0;
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        gap: 0;
    }

    .nav-links a {
        font-size: 0.8rem;
        padding: 0.5rem;
        text-align: center;
        border-radius: 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .nav-links a:hover, .nav-links a.active {
        transform: translateY(-3px);
        box-shadow: 0 2px 10px rgba(0, 240, 255, 0.2);
    }

    /* Main Content adjustments */
    .main-content {
        padding: 1rem 0.5rem;
        overflow-y: visible; /* Let the body scroll */
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .date-pickers {
        flex-wrap: wrap;
        justify-content: center;
    }

    .topbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .topbar h1 {
        font-size: 1.5rem;
    }

    .dashboard-widgets {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Login Page Mobile */
    .login-container {
        padding: 2rem 1.5rem;
    }

    .login-logo h1 {
        font-size: 2.2rem;
    }

    /* Upload area adjustments */
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .list-name-input {
        width: 100%;
    }

    .products-area, .cart-area {
        padding: 1rem;
    }

    #products-grid, #brands-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        padding-right: 10px; /* Evita que el scrollbar tape los botones verdes */
    }
    
    .product-card {
        padding: 12px;
    }
    
    .status-indicator {
        top: 12px;
        right: 12px;
    }
    
    .cart-item {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
}
