/* =========================================
   SISTEMA DE DISEÑO PREMIUM - ÓPTICA MULTIESTILOS
   "The Executive Suite" V2.1 - Refined Edition
   ========================================= */

/* @import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Playfair+Display:wght@700;800&display=swap'); */


:root {
    /* Color Palette - Deeper and cleaner */
    --primary: #0f172a;       
    --primary-alt: #1e293b;   
    --accent: #d4af37;        
    --accent-glow: rgba(212, 175, 55, 0.4);
    --accent-light: #fdf5d2;
    --secondary: #64748b;     
    --success: #10b981;       
    --warning: #f59e0b;       
    --danger: #ef4444;        
    --bg-app: #f8fafc;        
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-focus: #94a3b8;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --tr: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 16px;
}

/* Reset Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-title); }


a { text-decoration: none; color: inherit; transition: var(--tr); }

/* Layout Grid */
.admin-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--primary);
    color: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--tr);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3.5rem;
    padding-left: 0.5rem;
}

.sidebar-logo .icon {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.5rem;
    box-shadow: 0 0 25px var(--accent-glow);
}

.sidebar-logo span {
    font-family: var(--font-title);
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}


.nav-menu { flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.9rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 0.6rem;
    font-weight: 500;
    color: #94a3b8;
    font-size: 0.95rem;
}

.nav-item i { width: 22px; font-size: 1.2rem; transition: var(--tr); }

.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: white; }
.nav-item:hover i { transform: translateX(3px); }

.nav-item.active { background: var(--accent); color: var(--primary); font-weight: 600; }
.nav-item.active i { color: var(--primary); }

.nav-item.logout { margin-top: auto; color: #f87171; }
.nav-item.logout:hover { background: rgba(239, 68, 68, 0.1); }

/* Main Content */
.main-wrapper {
    flex: 1;
    margin-left: 280px;
    padding: 3rem;
    width: calc(100% - 280px);
    transition: var(--tr);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3.5rem;
}

.page-header h1 { font-size: 2.75rem; color: var(--primary); letter-spacing: -0.5px; }
.page-header p { color: var(--secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 2px; font-size: 0.75rem; margin-bottom: 0.5rem; }

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 4rem;
}

.kpi-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--tr);
}

.kpi-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--accent); }

.kpi-card .icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.kpi-card .data h3 { font-size: 2rem; line-height: 1; margin-bottom: 0.4rem; font-weight: 700; color: var(--primary); }
.kpi-card .data p { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--secondary); }

/* Action Cards */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.action-card {
    background: white;
    padding: 2.25rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: var(--tr);
}

.action-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); border-color: var(--accent); }

.action-card .icon-box {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--primary);
    transition: var(--tr);
}

.action-card h4 { font-size: 1.3rem; color: var(--primary); }
.action-card p { font-size: 0.95rem; color: var(--secondary); line-height: 1.5; }

/* Forms UI */
.form-card {
    background: white;
    padding: 3rem;
    border-radius: 24px;
    box-shadow: var(--shadow-premium);
    border: 1px solid var(--border);
    max-width: 900px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.form-group { margin-bottom: 2rem; }
.form-group.full-width { grid-column: span 2; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--primary);
    background: var(--bg-app);
    transition: var(--tr);
}

.form-control:focus {
    outline: none;
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

textarea.form-control { min-height: 120px; resize: vertical; }

.btn-block { width: 100%; justify-content: center; padding: 1.25rem; font-size: 1rem; }

/* Buttons Refined */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.75rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: var(--tr);
}

.btn i { font-size: 1rem; }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2); }
.btn-primary:active { transform: scale(0.98); }

.btn-gold { background: var(--accent); color: var(--primary); box-shadow: 0 4px 14px var(--accent-glow); }

.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-app); }

/* Table Premium */
.table-wrapper {
    background: white;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--bg-app);
    color: var(--secondary);
    letter-spacing: 1px;
}

.table td { padding: 1.5rem; border-top: 1px solid var(--border); font-size: 0.95rem; vertical-align: middle; }
.table tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-primary { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Reports Specific */
.report-card {
    background: white;
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid var(--border);
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.data-row:last-child { border-bottom: none; }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .sidebar { width: 85px; padding: 2.5rem 1rem; left: 0; }
    .sidebar-logo span, .nav-item span { display: none; }
    .main-wrapper { margin-left: 85px; width: calc(100% - 85px); padding: 2rem; }
    .kpi-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: auto; }
}

/* Auth / Landing Styles */
.public-body { display: block; background: #0f172a; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(circle at top right, #1e293b, #0f172a); }
.login-card { width: 100%; max-width: 440px; padding: 3.5rem; }

/* MODALS PREMIUM */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(8px); 
    display: none; align-items: center; justify-content: center; z-index: 9999; padding: 20px; 
}
.modal-overlay.active { display: flex; }

.modal-content { 
    background: white; border-radius: 24px; width: 100%; max-height: 90vh; 
    display: flex; flex-direction: column; overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.modal-content form { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.modal-header { padding: 1.5rem 2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); flex-shrink: 0; position: relative; }
.modal-header h3 { font-size: 1.35rem; font-family: 'Playfair Display', serif; margin: 0; padding-right: 30px; }
.btn-close, .close-btn { background: var(--bg-app); border: none; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); font-size: 1.2rem; transition: var(--tr); position: absolute; right: 1.5rem; top: 1.5rem; }
.btn-close:hover, .close-btn:hover { background: var(--danger); color: white; }

.modal-body { padding: 2rem; overflow-y: auto; flex: 1; }
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

.modal-footer { padding: 1.5rem 2rem; border-top: 1px solid var(--border); background: #f8fafc; flex-shrink: 0; }
.modal-content .form-control { padding: 0.75rem 1rem; font-size: 0.9rem; }
.modal-content .info-label { margin-bottom: 0.5rem; font-size: 0.7rem; }

@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.alert { padding: 1.25rem 1.5rem; border-radius: var(--radius); margin-bottom: 2.5rem; border: 1px solid transparent; display: flex; align-items: center; gap: 1rem; font-weight: 600; font-size: 0.95rem; animation: fadeIn 0.4s ease-out; box-shadow: var(--shadow-sm); }
.alert-success { background-color: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-danger { background-color: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* =========================================
   📱 RESPONSIVE MEDIA QUERIES (FIXED FOR MOBILE)
   ========================================= */

@media (max-width: 768px) {
    /* Admin Shell y Sidebar (Overriding the 1024px rule) */
    .sidebar {
        width: 250px;
        left: -260px; /* Hidden offscreen reliably */
        padding: 1rem 1rem;
        z-index: 1050;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
        transition: left 0.3s ease;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    /* Bring back labels when mobile menu opens */
    .sidebar-logo span, .nav-item span {
        display: inline-block !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1.5rem 1rem;
    }
    
    /* Modals for Mobile */
    .modal-content { max-height: 95vh; border-radius: 16px; margin: 10px; width: calc(100% - 20px); }
    .modal-body { padding: 1.5rem; }
    
    /* Cabecera / Buscador en Admin */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    .page-header h1 { font-size: 1.7rem; }
    
    .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .header-actions .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    /* Botón Hamburguesa */
    .mobile-toggle {
        display: flex !important;
        align-items: center;
        gap: 10px;
        background: var(--primary);
        color: var(--accent);
        border: none;
        padding: 0.6rem 1.2rem;
        border-radius: 10px;
        font-weight: 800;
        font-size: 1rem;
        cursor: pointer;
        margin-bottom: 0;
    }
    
    /* Wrapper del header manual para poner hamburguesa e info a los extremos */
    .main-header-toolbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 1.5rem;
    }
    
    /* Grillas */
    .kpi-grid { grid-template-columns: 1fr !important; gap: 1rem; margin-bottom: 1.5rem; }
    .action-grid { grid-template-columns: 1fr; gap: 1rem; }
    
    /* Tablas Resposivas - Swipeable */
    .table-card, .table-responsive {
        width: 100%;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem; /* Less padding to fit more table */
        box-shadow: inset -10px 0 10px -10px rgba(0,0,0,0.1); /* HINT to scroll right */
    }
    .table {
        min-width: 650px; /* Forzar el ancho mínimo para obligar el scroll horizontal! */
    }
    .table th, .table td {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 1rem 0.5rem;
    }

    /* Formularios */
    .form-card { padding: 1.2rem; }
    .form-group { margin-bottom: 1.25rem; }
    
    /* Barra pública */
    .navbar-public .container {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    .navbar-public .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    /* Landing Hero */
    .hero-text h1 { font-size: 2.5rem !important; }
    .hero-text p { font-size: 1rem !important; }
    .hero-btns { display: flex; flex-direction: column; gap: 1rem; }
    .hero-btns .btn { width: 100%; margin-left: 0 !important; text-align: center; justify-content: center; }
    /* Pestañas / Tabs (Horizontal Scroll on Mobile) */
    .inventory-tabs, .tabs-container {
        display: flex;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 0; /* Keep buttons touching */
        scrollbar-width: none; /* Hide scrollbar Firefox */
        -ms-overflow-style: none; /* Hide scrollbar IE */
    }
    .inventory-tabs::-webkit-scrollbar, .tabs-container::-webkit-scrollbar { display: none; } /* Hide scrollbar Chrome/Safari */
    
    .tab-link, .tab-btn {
        flex: 0 0 auto; /* Don't shrink, keep width based on text */
        padding: 1rem 1.5rem !important;
    }
}

