/* ============================================
   styles.css - Estilos del Dashboard y globales
   ============================================ */

/* ----- Variables (igual que antes, pero con soporte para temas) ----- */
:root {
    --primary: #1a2a3a;
    --primary-light: #2c3e50;
    --accent: #7b9cff;
    --accent-hover: #5a7fdb;
    --bg-main: #f0f4f9;
    --bg-card: #ffffff;
    --text-dark: #0b1a2a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
    --radius: 16px;
    --transition: 0.3s ease;
}

/* ----- Reset y base ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    display: flex;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================
   TEMA OSCURO (aplicado a html.theme-oscuro)
   ============================================ */
html.theme-oscuro {
    --primary: #1a2a3a;
    --primary-light: #2c3e50;
    --accent: #7b9cff;
    --accent-hover: #5a7fdb;
    --bg-main: #0d1117;
    --bg-card: #161b22;
    --text-dark: #e6edf3;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

html.theme-oscuro body {
    background: var(--bg-main);
    color: var(--text-dark);
}

html.theme-oscuro .sidebar {
    background: #0d1117;
    border-right: 1px solid var(--border-color);
}

html.theme-oscuro .sidebar-brand {
    border-bottom-color: var(--border-color);
}

html.theme-oscuro .sidebar-nav ul li a {
    color: rgba(255, 255, 255, 0.6);
}
html.theme-oscuro .sidebar-nav ul li a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}
html.theme-oscuro .sidebar-nav ul li.active a {
    background: rgba(123, 156, 255, 0.15);
    color: #fff;
}

html.theme-oscuro .sidebar-footer {
    border-top-color: var(--border-color);
}

html.theme-oscuro .kpi-card,
html.theme-oscuro .summary-card,
html.theme-oscuro .table-card,
html.theme-oscuro .chart-card,
html.theme-oscuro .activity-card,
html.theme-oscuro .config-card {
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

html.theme-oscuro .search-wrapper {
    background: var(--bg-card);
    border-color: var(--border-color);
}
html.theme-oscuro .search-wrapper input {
    color: var(--text-dark);
}
html.theme-oscuro .search-wrapper input::placeholder {
    color: var(--text-muted);
}

html.theme-oscuro .topbar {
    border-bottom: 1px solid var(--border-color);
}

html.theme-oscuro .profile-btn {
    background: var(--bg-card);
    border-color: var(--border-color);
}
html.theme-oscuro .profile-btn span {
    color: var(--text-dark);
}

html.theme-oscuro .dropdown-menu {
    background: var(--bg-card);
    border-color: var(--border-color);
}
html.theme-oscuro .dropdown-menu a {
    color: var(--text-dark);
}
html.theme-oscuro .dropdown-menu a:hover {
    background: var(--bg-main);
}

html.theme-oscuro .status-badge.status-activo {
    background: #1a4a2a;
    color: #7ee08a;
}
html.theme-oscuro .status-badge.status-inactivo {
    background: #4a1a1a;
    color: #f08a8a;
}
html.theme-oscuro .status-badge.status-pendiente {
    background: #4a3a1a;
    color: #f0d08a;
}
html.theme-oscuro .status-badge.status-completado {
    background: #1a3a2a;
    color: #7ee08a;
}
html.theme-oscuro .status-badge.status-enviado {
    background: #1a2a4a;
    color: #8ab0f0;
}
html.theme-oscuro .status-badge.status-cancelado {
    background: #3a1a1a;
    color: #f08a8a;
}
html.theme-oscuro .status-badge.status-bajo {
    background: #3a1a1a;
    color: #f08a8a;
}
html.theme-oscuro .status-badge.status-normal {
    background: #1a3a2a;
    color: #7ee08a;
}
html.theme-oscuro .status-badge.status-exceso {
    background: #1a2a4a;
    color: #8ab0f0;
}

html.theme-oscuro .modal {
    background: var(--bg-card);
}
html.theme-oscuro .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

html.theme-oscuro .filter-bar {
    background: var(--bg-card);
}

html.theme-oscuro .form-group input,
html.theme-oscuro .form-group select {
    background: var(--bg-main);
    border-color: var(--border-color);
    color: var(--text-dark);
}
html.theme-oscuro .form-group input:focus,
html.theme-oscuro .form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(123, 156, 255, 0.12);
}

html.theme-oscuro .btn-primary {
    background: var(--primary-light);
}
html.theme-oscuro .btn-primary:hover {
    background: var(--primary);
}

html.theme-oscuro .btn-outline {
    border-color: var(--border-color);
    color: var(--text-muted);
}
html.theme-oscuro .btn-outline:hover {
    background: var(--bg-main);
    border-color: var(--text-muted);
}

html.theme-oscuro .tabs {
    background: var(--bg-card);
}
html.theme-oscuro .tab-btn {
    color: var(--text-muted);
}
html.theme-oscuro .tab-btn:hover {
    background: var(--bg-main);
    color: var(--text-dark);
}
html.theme-oscuro .tab-btn.active {
    background: var(--primary);
    color: #fff;
}

html.theme-oscuro .bar-track {
    background: var(--bg-main);
}
html.theme-oscuro .bar-fill {
    background: var(--accent);
}
html.theme-oscuro .bar-fill.orange {
    background: #e08a3a;
}
html.theme-oscuro .bar-fill.green {
    background: #3ae08a;
}
html.theme-oscuro .bar-fill.purple {
    background: #a08ae0;
}
html.theme-oscuro .bar-fill.pink {
    background: #e08ac8;
}
html.theme-oscuro .bar-fill.teal {
    background: #3ae0d0;
}

html.theme-oscuro .action-btn {
    color: var(--text-muted);
}
html.theme-oscuro .action-btn:hover {
    color: var(--text-dark);
}

html.theme-oscuro .flow-step {
    background: var(--bg-main);
}

html.theme-oscuro .perm-tag {
    background: var(--bg-main);
    color: var(--text-muted);
}
html.theme-oscuro .perm-tag.admin {
    background: #4a3a1a;
    color: #f0d08a;
}

html.theme-oscuro .error-message {
    color: #f08a8a;
}

html.theme-oscuro .sidebar-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* ============================================
   TEMA CLARO (por defecto, sin clase adicional)
   ============================================ */
html.theme-claro body {
    background: #f0f4f9;
    color: #0b1a2a;
}

/* Los estilos claros ya están definidos por defecto en las variables originales */
/* El cambio de tema se gestiona con las clases .theme-oscuro */

/* ============================================
   RESTO DE ESTILOS (Dashboard, KPI, etc.)
   ============================================ */
/* (Aquí mantienes todos los estilos existentes de tu dashboard) */

/* Ejemplo: KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.2rem;
}
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem 1.5rem 1.3rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 30px -8px rgba(0,0,0,0.08);
}
.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
}
.kpi-icon.blue { background: #7b9cff; }
.kpi-icon.green { background: #38a169; }
.kpi-icon.orange { background: #ed8936; }
.kpi-icon.purple { background: #805ad5; }
.kpi-info { flex: 1; }
.kpi-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    font-weight: 600;
}
.kpi-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0.1rem 0 0.2rem;
    color: var(--text-dark);
}
.kpi-change {
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.kpi-change.positive { color: #38a169; }
.kpi-change.negative { color: #e53e3e; }

/* Charts Row */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

/* Bar chart */
.bar-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 200px;
    gap: 0.3rem;
    padding-top: 0.5rem;
}
.bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
}
.bar-group {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 3px;
    height: 180px;
    width: 100%;
}
.bar {
    width: 16px;
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    transition: height 0.6s ease;
}
.bar-venta { background: var(--accent); }
.bar-compra { background: #38a169; }
.bar-item span {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
}

/* Activity list */
.activity-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.activity-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    font-size: 0.9rem;
    line-height: 1.4;
}
.activity-list li i {
    font-size: 1.1rem;
    margin-top: 0.1rem;
    width: 1.4rem;
    text-align: center;
}
.activity-list li .green { color: #38a169; }
.activity-list li .blue { color: var(--accent); }
.activity-list li .orange { color: #ed8936; }
.activity-list li .purple { color: #805ad5; }
.activity-list li div { flex: 1; }
.activity-list li .time {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* Tablas */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
thead { background: var(--bg-main); border-radius: 8px; }
th {
    text-align: left;
    padding: 0.7rem 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
}
tr:last-child td { border-bottom: none; }

/* Status badges (genéricos) */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 30px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Overlay para móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 90;
}
.sidebar-overlay.active { display: block; }

/* Responsive */
@media (max-width: 1024px) { .charts-row { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        height: 100vh;
        top: 0;
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: block; }
    .main-content { padding: 1rem; }
    .topbar { padding-bottom: 1rem; }
    .search-wrapper { max-width: 100%; }
    .profile-btn span { display: none; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .kpi-card { padding: 1rem; }
    .kpi-value { font-size: 1.3rem; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .topbar-left { flex: 1 1 100%; }
    .topbar-right { width: 100%; justify-content: flex-end; }
    .bar-chart { height: 120px; }
    .bar { width: 12px; }
}