/* =============================================
   BACKTESTING ALL — Dark Glassmorphism Theme
   Mejores Horarios Dashboard
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;800&display=swap');

/* ===================================
   CSS VARIABLES
   =================================== */
:root {
    --bg-primary:    #0a0e1a;
    --bg-secondary:  #111827;

    --accent-cyan:   #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-green:  #10b981;
    --accent-red:    #ef4444;
    --accent-orange: #f59e0b;
    --accent-gold:   #fbbf24;
    --accent-silver: #94a3b8;
    --accent-bronze: #cd7c3e;

    --text-primary:   #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted:     #6b7280;

    --gradient-green:  linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-red:    linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    --gradient-gold:   linear-gradient(135deg, #fbbf24 0%, #d97706 100%);

    --glass-bg:     rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
}

/* ===================================
   BODY
   =================================== */
body {
    background: var(--bg-primary);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 85% 20%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 90%, rgba(251, 191, 36, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><rect width="60" height="60" fill="none"/><circle cx="30" cy="30" r="0.8" fill="rgba(255,255,255,0.025)"/></svg>');
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

main { flex: 1; }

/* ===================================
   THEME TOGGLE (navbar)
   =================================== */
.theme-toggle { display: flex; align-items: center; gap: 1rem; }
.switch { position: relative; display: inline-block; width: 56px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: rgba(255,255,255,0.1);
    transition: .4s cubic-bezier(0.4,0,0.2,1);
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,0.2);
}
.slider::before {
    position: absolute; content: "";
    height: 22px; width: 22px; left: 3px; bottom: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: .4s cubic-bezier(0.4,0,0.2,1);
    border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
input:checked + .slider { background: var(--accent-cyan); box-shadow: 0 0 15px rgba(6,182,212,0.5); }
input:checked + .slider::before { transform: translateX(28px); background: white; }
.btn-outline-secondary.rounded-circle { border: none !important; background: transparent !important; padding: 2px !important; box-shadow: none !important; }
.btn-outline-secondary.rounded-circle:hover { background: transparent !important; border: none !important; }

/* ===================================
   DASHBOARD LAYOUT
   =================================== */
.dashboard-layout {
    display: flex;
    min-height: calc(100vh - 60px);
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

/* ── Sidebar ── */
.dashboard-sidebar {
    width: 240px;
    min-width: 240px;
    padding: 1.25rem 1rem;
    border-right: 1px solid rgba(255,255,255,0.08);
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(139,92,246,0.3) transparent;
}

.sidebar-brand { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.5rem; }
.sidebar-brand-icon { font-size: 1.5rem; line-height: 1; }
.sidebar-brand-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.sidebar-brand-sub   { font-size: 0.68rem; color: var(--text-muted); line-height: 1; }

.sidebar-divider { margin: 0.65rem 0; opacity: 0.15; border-color: var(--glass-border); }

.sidebar-controls { display: flex; flex-direction: column; gap: 0.65rem; }
.sidebar-field    { display: flex; flex-direction: column; gap: 0.2rem; }

.sidebar-label {
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.sidebar-select {
    font-size: 0.82rem !important;
    padding: 0.28rem 0.5rem !important;
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    transition: all 0.3s ease;
}
.sidebar-select:hover  { border-color: var(--accent-purple) !important; box-shadow: 0 0 12px rgba(139,92,246,0.3) !important; }
.sidebar-select:focus  { border-color: var(--accent-cyan) !important; box-shadow: 0 0 16px rgba(6,182,212,0.4) !important; outline: none; }
.sidebar-select option { background: #1a202c; color: var(--text-primary); }

.sidebar-btn-load {
    background: var(--gradient-green) !important;
    border: none !important; font-weight: 700;
    border-radius: var(--radius-sm) !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16,185,129,0.3);
    width: 100%;
}
.sidebar-btn-load:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,0.5) !important; }

.sidebar-section-title {
    font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-muted); margin-bottom: 0.5rem;
}

/* Profit destacado */
.sidebar-profit-row {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}
.sidebar-profit-row.is-loss { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); }
.sidebar-profit-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-profit-value { font-size: 1.45rem; font-weight: 800; line-height: 1.2; color: #10b981; }
.sidebar-profit-row.is-loss .sidebar-profit-value { color: #ef4444; }

/* KPI list */
.sidebar-kpi-list { display: flex; flex-direction: column; }
.sidebar-kpi-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.28rem 0; border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.75rem;
}
.sidebar-kpi-item-label { color: var(--text-secondary); }

.sidebar-footer-note {
    font-size: 0.65rem; color: var(--text-muted);
    text-align: center; line-height: 1.4;
}

/* ── Main Content ── */
.dashboard-main {
    flex: 1; min-width: 0;
    padding: 1.5rem 2rem;
    overflow-x: auto;
}

/* Empty state */
.dashboard-empty-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 50vh; opacity: 0.35;
    text-align: center; gap: 0.5rem;
}
.dashboard-empty-icon  { font-size: 3.5rem; }
.dashboard-empty-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.dashboard-empty-sub   { font-size: 0.85rem; color: var(--text-secondary); }

/* ===================================
   SYMBOL HEADER
   =================================== */
.symbol-header {
    display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; gap: 1rem;
}
.symbol-header-left { display: flex; align-items: center; gap: 1rem; }

.symbol-badge {
    font-size: 1.1rem; font-weight: 800;
    font-family: 'Poppins', sans-serif;
    padding: 0.4rem 1rem;
    background: var(--gradient-purple);
    border-radius: var(--radius-sm);
    color: #fff;
    box-shadow: 0 4px 15px rgba(139,92,246,0.4);
    letter-spacing: 0.05em;
}
.symbol-title    { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.symbol-subtitle { font-size: 0.75rem; color: var(--text-muted); }

.risk-badge {
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    border: 1.5px solid var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(6,182,212,0.08);
}

/* ===================================
   STRATEGY TABS
   =================================== */
.strategy-tabs {
    display: flex; gap: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0;
}

.strategy-tab {
    background: transparent;
    border: none; outline: none;
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem; font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.strategy-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.strategy-tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
    background: rgba(6,182,212,0.06);
}

/* ===================================
   SECTION LABEL
   =================================== */
.section-label {
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--text-muted);
}

/* ===================================
   RANKING CARDS — TOP 3
   =================================== */
.ranking-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.ranking-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
.ranking-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.ranking-card.gold::before   { background: var(--gradient-gold); }
.ranking-card.silver::before { background: linear-gradient(135deg, #94a3b8, #64748b); }
.ranking-card.bronze::before { background: linear-gradient(135deg, #cd7c3e, #92400e); }

.ranking-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.4); }

.ranking-card.gold   { border-color: rgba(251,191,36,0.3); box-shadow: 0 4px 20px rgba(251,191,36,0.1); }
.ranking-card.silver { border-color: rgba(148,163,184,0.3); }
.ranking-card.bronze { border-color: rgba(205,124,62,0.2); }

.ranking-medal { font-size: 2rem; line-height: 1; margin-bottom: 0.5rem; }

.ranking-hora {
    font-size: 1.6rem; font-weight: 800;
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.ranking-pl {
    font-size: 1.1rem; font-weight: 700;
    margin-bottom: 1rem;
}
.ranking-pl.positive { color: var(--accent-green); }
.ranking-pl.negative { color: var(--accent-red); }

.ranking-stats {
    display: flex; justify-content: space-around;
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
    gap: 0.5rem;
}
.ranking-stat { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.ranking-stat-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ranking-stat-value { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); }

/* ===================================
   TABLE CARD
   =================================== */
.table-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--glass-shadow);
}

.table-card-controls {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(139,92,246,0.08);
    flex-wrap: wrap; gap: 0.5rem;
}

.sort-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.7rem;
    font-size: 0.72rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease;
}
.sort-btn:hover { border-color: var(--accent-purple); color: var(--text-primary); }
.sort-btn.active {
    background: rgba(139,92,246,0.2);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.table-count-badge {
    font-size: 0.7rem; font-weight: 600;
    color: var(--text-muted);
    padding: 0.2rem 0.7rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
}

/* ── bkt-table ── */
.bkt-table {
    width: 100%; border-collapse: collapse;
    font-size: 0.82rem;
}
.bkt-table thead th {
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}
.bkt-table tbody tr td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    vertical-align: middle;
    font-family: 'Trebuchet MS', Arial, sans-serif;
}
.bkt-table tbody tr:last-child td { border-bottom: none; }
.bkt-table tbody tr:hover td { background: rgba(139,92,246,0.08); }
.bkt-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.bkt-table tbody tr:nth-child(even):hover td { background: rgba(139,92,246,0.08); }

.cell-rank  { font-weight: 700; color: var(--text-muted); width: 50px; text-align: center; }
.cell-hora  { font-weight: 700; font-family: 'Poppins', sans-serif; }
.cell-positive { color: var(--accent-green) !important; font-weight: 600; }
.cell-negative { color: var(--accent-red)   !important; font-weight: 600; }
.cell-neutral  { color: var(--text-secondary); }

.mini-medal { font-size: 0.9rem; margin-right: 4px; }

/* ===================================
   FORM CONTROLS (sidebar overrides)
   =================================== */
.form-select, .form-control {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
}
.form-select:focus, .form-control:focus {
    border-color: var(--accent-cyan) !important;
    box-shadow: 0 0 16px rgba(6,182,212,0.35) !important;
    outline: none;
}

/* ===================================
   BUTTONS
   =================================== */
.btn-success {
    background: var(--gradient-green) !important;
    border: none !important; font-weight: 700;
    border-radius: var(--radius-sm) !important;
    transition: all 0.3s ease;
}
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,0.5) !important; }

/* =============================================
   LIGHT MODE
   ============================================= */
body:not(.dark-mode) {
    --text-primary:   #1a202c;
    --text-secondary: #4a5568;
    --text-muted:     #718096;
    --glass-bg:     rgba(255,255,255,0.85);
    --glass-border: rgba(0,0,0,0.1);
    --glass-shadow: 0 4px 20px rgba(0,0,0,0.08);

    background: #f0f2f5 !important;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(139,92,246,0.04) 0%, transparent 50%),
        radial-gradient(circle at 85% 20%, rgba(6,182,212,0.04) 0%, transparent 50%) !important;
    color: #1a202c !important;
}
body:not(.dark-mode)::before { opacity: 0.06; }

body:not(.dark-mode) .dashboard-sidebar {
    background-color: #ffffff !important;
    border-right-color: #e2e8f0 !important;
}
body:not(.dark-mode) .dashboard-main { background-color: #f0f2f5 !important; }

body:not(.dark-mode) .sidebar-brand-title { color: #1a202c; }
body:not(.dark-mode) .sidebar-brand-sub   { color: #718096; }
body:not(.dark-mode) .sidebar-label       { color: #4a5568 !important; }
body:not(.dark-mode) .sidebar-section-title { color: #718096; }
body:not(.dark-mode) .sidebar-kpi-item    { border-bottom-color: rgba(0,0,0,0.07); }
body:not(.dark-mode) .sidebar-kpi-item-label { color: #4a5568; }
body:not(.dark-mode) .sidebar-footer-note  { color: #718096; }
body:not(.dark-mode) .sidebar-divider      { border-color: #e2e8f0; opacity: 1; }

body:not(.dark-mode) .sidebar-select {
    background: #ffffff !important;
    border: 1px solid #cbd5e0 !important;
    color: #1a202c !important;
}
body:not(.dark-mode) .sidebar-select option { background: #fff; color: #1a202c; }
body:not(.dark-mode) .form-select,
body:not(.dark-mode) .form-control {
    background: #ffffff !important;
    border: 1px solid #cbd5e0 !important;
    color: #1a202c !important;
}

body:not(.dark-mode) .sidebar-profit-row { background: rgba(5,150,105,0.08); border-color: rgba(5,150,105,0.2); }
body:not(.dark-mode) .sidebar-profit-row.is-loss { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.2); }
body:not(.dark-mode) .sidebar-profit-value       { color: #059669; }
body:not(.dark-mode) .sidebar-profit-row.is-loss .sidebar-profit-value { color: #dc2626; }

body:not(.dark-mode) .ranking-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
body:not(.dark-mode) .ranking-card.gold   { border-color: rgba(251,191,36,0.4) !important; }
body:not(.dark-mode) .ranking-card.silver { border-color: rgba(148,163,184,0.4) !important; }
body:not(.dark-mode) .ranking-card.bronze { border-color: rgba(205,124,62,0.3) !important; }
body:not(.dark-mode) .ranking-hora        { color: #1a202c; }
body:not(.dark-mode) .ranking-stats       { border-top-color: #e2e8f0; }
body:not(.dark-mode) .ranking-stat-label  { color: #718096; }
body:not(.dark-mode) .ranking-stat-value  { color: #1a202c; }

body:not(.dark-mode) .table-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06) !important;
}
body:not(.dark-mode) .table-card-controls {
    background: rgba(139,92,246,0.05) !important;
    border-bottom-color: #e2e8f0 !important;
}
body:not(.dark-mode) .sort-btn { border-color: #e2e8f0; color: #4a5568; }
body:not(.dark-mode) .sort-btn.active { background: rgba(139,92,246,0.1); color: #6d28d9; border-color: #8b5cf6; }
body:not(.dark-mode) .table-count-badge { border-color: #e2e8f0; color: #718096; }

body:not(.dark-mode) .bkt-table thead th {
    background: #f7fafc; color: #4a5568;
    border-bottom-color: #e2e8f0;
}
body:not(.dark-mode) .bkt-table tbody tr td {
    color: #1a202c; border-bottom-color: #f0f2f5;
}
body:not(.dark-mode) .bkt-table tbody tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
body:not(.dark-mode) .bkt-table tbody tr:hover td { background: rgba(139,92,246,0.05); }
body:not(.dark-mode) .cell-rank { color: #718096; }

body:not(.dark-mode) .strategy-tab { color: #4a5568; }
body:not(.dark-mode) .strategy-tab:hover { color: #1a202c; background: rgba(0,0,0,0.03); }
body:not(.dark-mode) .strategy-tab.active { color: #0891b2; border-bottom-color: #0891b2; background: rgba(6,182,212,0.05); }
body:not(.dark-mode) .strategy-tabs { border-bottom-color: #e2e8f0; }

body:not(.dark-mode) .section-label { color: #718096; }
body:not(.dark-mode) .symbol-title  { color: #1a202c; }
body:not(.dark-mode) .symbol-subtitle { color: #718096; }

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 900px) {
    .ranking-grid { grid-template-columns: 1fr; max-width: 380px; margin: 0 auto; }
}

@media (max-width: 768px) {
    .dashboard-layout  { flex-direction: column; }
    .dashboard-sidebar { width: 100%; min-width: unset; position: static; height: auto; border-right: none; border-bottom: 1px solid rgba(128,128,128,0.2); }
    .dashboard-main    { padding: 1rem; }
    .ranking-grid      { grid-template-columns: 1fr; }
    .symbol-header     { flex-direction: column; align-items: flex-start; }
}