:root {
    --bg-main: #e8ecf0;
    --bg-secondary: #ffffff;
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.3);
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.3);
    --success: #16a34a;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.1);
    --font-primary: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-primary);
    background: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3.5rem;
}

.brand-logo {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: contain;
    background: white; /* by default some PNGs need background */
}
.brand h1, .brand h2 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--accent);
    white-space: nowrap;
}
.brand i {
    font-size: 1.8rem;
    color: #00f2fe;
}

.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 1.8rem;
    cursor: pointer;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.nav-links li {
    padding: 1.1rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.nav-links li:hover, .nav-links li.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--accent);
    box-shadow: inset 4px 0 0 var(--accent);
}

.content-area {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-main);
}

.stat-icon {
    width: 65px;
    height: 65px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.25));
    color: var(--accent);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
}

.content-area {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: radial-gradient(circle at top right, rgba(79, 172, 254, 0.05), transparent 40%),
                radial-gradient(circle at bottom left, rgba(255, 75, 75, 0.03), transparent 40%);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.user-profile img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.view-section {
    display: none;
    animation: fadeScale 0.4s ease forwards;
}
.view-section.active {
    display: block;
}

@keyframes fadeScale {
    from { opacity: 0; transform: translateY(15px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--accent-glow);
}

.stat-icon {
    width: 65px;
    height: 65px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(0,242,254,0.1), rgba(79,172,254,0.25));
    color: var(--accent);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
}

.stat-details h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.stat-details p {
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: 5px;
    color: var(--text-main);
}

.table-container {
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.table-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
}

.premium-table th {
    text-align: center;
    padding: 0.8rem 0.6rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.premium-table td {
    text-align: center;
    padding: 0.8rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 400;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.premium-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.badge {
    padding: 0.45rem 1rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.badge.stock-high { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.badge.stock-low { background: rgba(255, 75, 75, 0.15); color: var(--danger); box-shadow: 0 0 10px rgba(255,75,75,0.2); }
.badge.stock-none { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.form-container {
    padding: 3rem;
    max-width: 650px;
    margin: 0 auto;
}

.form-container h2 {
    margin-bottom: 2.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.6rem;
}

.form-group {
    margin-bottom: 1.8rem;
}

.form-row {
    display: flex;
    gap: 1.5rem;
}
.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
}

input, select {
    width: 100%;
    padding: 1.1rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: rgba(0, 0, 0, 0.4);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-main);
}

button {
    cursor: pointer;
    font-family: var(--font-primary);
}

.btn-primary {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    padding: 0.7rem 1.4rem;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}
.btn-primary:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-submit {
    width: 100%;
    padding: 1.2rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: white;
    font-size: 1.15rem;
    font-weight: 800;
    margin-top: 1rem;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-danger {
    background: linear-gradient(135deg, #ff4b4b 0%, #ff0f0f 100%);
}
.btn-danger:hover {
    box-shadow: 0 8px 25px var(--danger-glow);
}

#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 1.2rem 1.8rem;
    border-radius: 12px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =========================================
   Acciones y Modales
   ========================================= */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    width: 90%;
    max-width: 520px;
    padding: 2.5rem;
    animation: fadeScale 0.3s ease;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    margin: 0 4px;
    transition: all 0.2s ease;
}

.btn-action.edit:hover { 
    color: var(--accent); 
    border-color: var(--accent);
    background: rgba(79, 172, 254, 0.1);
    transform: translateY(-2px); 
}

.btn-action.delete:hover { 
    color: var(--danger); 
    border-color: var(--danger);
    background: rgba(255, 75, 75, 0.1);
    transform: translateY(-2px); 
}

/* =========================================
   Responsive / Adaptabilidad Móvil y Tablets
   ========================================= */

@media screen and (max-width: 900px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        padding: 1.2rem;
        flex-direction: column;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        background: rgba(22, 27, 34, 0.95);
        position: sticky;
        top: 0;
        z-index: 100;
        backdrop-filter: blur(20px);
    }

    .brand {
        margin-bottom: 1rem;
        justify-content: space-between;
        width: 100%;
    }
    .brand h1, .brand h2 {
        font-size: 1.35rem;
    }
    .brand i {
        font-size: 1.6rem;
    }

    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    .nav-links.show-mobile {
        display: flex;
        animation: fadeScale 0.3s ease;
    }

    .nav-links li {
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
        flex: 1;
        justify-content: center;
        text-align: center;
        min-width: 150px;
    }

    .nav-links li:hover, .nav-links li.active {
        box-shadow: inset 0 -3px 0 var(--accent);
        background: rgba(79, 172, 254, 0.15);
    }

    .content-area {
        padding: 1rem 0.5rem;
        overflow-y: visible;
    }
    
    .table-container {
        padding: 1.5rem 0.5rem;
    }

    header {
        flex-direction: column;
        align-items: center;
        gap: 1.2rem;
        text-align: center;
        margin-bottom: 2rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-container {
        padding: 1.5rem;
        margin: 0;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .table-header {
        flex-direction: column;
        gap: 1.2rem;
        text-align: center;
    }
    
    .table-container {
        padding: 1rem;
    }
    
    .premium-table th, .premium-table td {
        padding: 0.8rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .btn-primary {
        width: 100%;
    }
}

@media screen and (max-width: 480px) {
    .nav-links {
        flex-direction: column;
    }
    .nav-links li {
        justify-content: center;
        width: 100%;
    }
    .nav-links li:hover, .nav-links li.active {
        box-shadow: inset 4px 0 0 var(--accent);
    }
    .brand h1, .brand h2 {
        font-size: 1.15rem;
    }
    .brand i {
        font-size: 1.4rem;
    }
    .content-area {
        padding: 1rem 0.5rem;
    }
    header h1 {
        font-size: 1.5rem;
    }
    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem 1rem;
    }
    .form-container {
        padding: 1.2rem;
    }
    /* Fixing the toast location on mobile */
    #toast-container {
        right: 15px;
        bottom: 15px;
        left: 15px;
    }
    .toast {
        width: calc(100% - 30px);
        margin: 0 auto;
        box-sizing: border-box;
    }
}
