/* ==========================================================================
   MARKET PRO - HOJA DE ESTILOS PREMIUM ENTERPRISE
   Diseño: Glassmorphism, Gradientes Líquidos, Modo Oscuro/Claro Fluidos
   Tipografía: Outfit & Inter
   ========================================================================== */

/* 1. VARIABLES GLOBALES DE DISEÑO */
:root {
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Fondo Degradado Diagonal Pastel (Por Defecto) */
    --bg-main: linear-gradient(135deg, #ffd1dc 0%, #c4ebd0 100%);
    --bg-surface: rgba(255, 255, 255, 0.45);
    --bg-surface-solid: #ffffff;
    --bg-sidebar: #0f172a; /* Mantiene el sidebar oscuro por elegancia corporativa */
    --border-color: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(15, 23, 42, 0.15);
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    /* Colores del Sistema */
    --primary: #10b981; /* Esmeralda Premium */
    --primary-light: rgba(16, 185, 129, 0.15);
    --primary-hover: #059669;
    --secondary: #0f172a;
    --accent: #f59e0b; /* Amber */
    --accent-light: rgba(245, 158, 11, 0.15);
    
    --success: #10b981;
    --info: #06b6d4;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);

    /* Efectos */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 20px 40px -10px rgba(15, 23, 42, 0.15);
    --glass-blur: blur(16px);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Claro / Fallback */
body.theme-light {
    --bg-main: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.8);
    --bg-surface-solid: #ffffff;
    --bg-sidebar: #0f172a;
    --border-color: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(15, 23, 42, 0.15);
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 20px 40px -10px rgba(15, 23, 42, 0.15);
}

/* 2. REINICIO DE ESTILOS Y ESTRUCTURA GENERAL */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: var(--bg-main) !important;
    background-attachment: fixed !important;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

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

/* 3. SCROLLBARS PERSONALIZADAS */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 4. COMPONENTES Y UTILIDADES PREMIUM */
.glass {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
}

.glass-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.glass-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    opacity: 0.95;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-success { background: var(--primary-light); color: var(--primary); }
.badge-warning { background: var(--accent-light); color: var(--accent); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: rgba(6, 182, 212, 0.15); color: var(--info); }

/* 5. DISEÑO DE LAYOUT GLOBAL (SIDEBAR + TOPBAR + MAIN) */
.layout-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar Corporativo */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    font-size: 22px;
    font-weight: 700;
    color: white;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-brand span { color: var(--primary); }
.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}
.sidebar-item.active a, .sidebar-item a:hover {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* Topbar */
.topbar {
    height: 70px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: rgba(254, 248, 212, 0.95) !important; /* Amarillo Pastel */
    backdrop-filter: var(--glass-blur);
    z-index: 90;
}
.topbar a {
    color: var(--text-primary) !important;
}
.topbar .sidebar-brand a {
    color: var(--text-primary) !important;
}
.search-box {
    position: relative;
    width: 300px;
}
.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(15, 23, 42, 0.15);
    border-radius: 30px;
    padding: 8px 16px 8px 40px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}
.theme-toggle, .notification-trigger {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}
.theme-toggle:hover { color: var(--primary); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.user-profile img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}
.user-info span {
    display: block;
    font-size: 14px;
    font-weight: 600;
}
.user-info small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    padding: 40px;
    overflow-y: auto;
}

/* 6. DASHBOARD EJECUTIVO Y ESTADÍSTICAS */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}
.kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kpi-details span {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}
.kpi-details h3 {
    font-size: 28px;
    margin: 4px 0;
}
.kpi-change {
    font-size: 12px;
    font-weight: 600;
}
.kpi-change.up { color: var(--primary); }
.kpi-change.down { color: var(--danger); }
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}
.chart-box {
    min-height: 320px;
}

/* Tablas y Listados */
.table-box {
    margin-top: 24px;
    overflow-x: auto;
}
table.mp-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
table.mp-table th {
    padding: 16px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
table.mp-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
table.mp-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* 7. SITIO WEB CORPORATIVO Y E-COMMERCE */
.web-hero {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(9, 13, 22, 0.9) 100%), url('../uploads/hero_bg.jpg') center/cover;
    border-radius: var(--radius-lg);
    padding: 80px 40px;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    border: 1px solid var(--border-color);
}
.web-hero h1 {
    font-size: 48px;
    margin-bottom: 16px;
    max-width: 600px;
}
.web-hero p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    max-width: 500px;
}

/* Categorías & Productos */
.section-title {
    margin-bottom: 24px;
    font-size: 24px;
}
.category-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}
.category-btn {
    padding: 10px 20px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}
.category-btn.active, .category-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}
.product-card {
    position: relative;
    display: flex;
    flex-direction: column;
}
.product-image {
    width: 100%;
    height: 180px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    margin-bottom: 16px;
}
.product-card h4 {
    font-size: 16px;
    margin-bottom: 8px;
}
.product-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    flex-grow: 1;
}
.product-price-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.product-price {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-heading);
}
.product-promo-price {
    font-size: 14px;
    color: var(--danger);
    text-decoration: line-through;
    margin-left: 8px;
}
.add-to-cart-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.add-to-cart-btn:hover {
    transform: scale(1.1);
}

/* Recetas y Blog */
.recipes-grid, .blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

/* 8. PUNTO DE VENTA (POS) - INTERFAZ DE CAJA */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    height: calc(100vh - 150px);
}
.pos-products {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 10px;
}
.pos-scanner-box {
    display: flex;
    gap: 12px;
}
.pos-scanner-box input {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: white;
    font-size: 14px;
    outline: none;
}
.pos-cart {
    background: var(--bg-surface-solid);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.pos-cart-items {
    flex-grow: 1;
    overflow-y: auto;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.pos-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
.pos-totals {
    border-top: 2px dashed var(--border-color);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.pos-totals-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}
.pos-totals-row.grand-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 8px;
}

/* 9. RESPONSIVE MEDIA QUERIES */
@media (max-width: 1024px) {
    .layout-wrapper {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none; /* Debería implementarse un menú hamburguesa en JS */
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 20px;
    }
    .web-hero h1 {
        font-size: 32px;
    }
    .topbar {
        padding: 0 20px;
    }
    .search-box {
        width: 150px;
    }
}
