/* ═══════════════════════════════════════════════════════════
   GREGORIO LABS — Dashboard Design System
   Complementa cyberpunk.css sin reemplazarlo.
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS VARIABLES ───
   Mapped to cosmos design tokens (cosmos.css). The --grm-* names are kept for
   backwards-compatibility with all dashboard / canvas / srs / aprender styles
   that still reference them. Single source of truth lives in cosmos.css. */
:root {
    --grm-bg:           var(--bg-base, #0a0a0f);
    --grm-surface:      var(--bg-surface, #12111a);
    --grm-surface-2:    var(--bg-card, #1a1828);
    --grm-surface-3:    var(--bg-elevated, #221f33);
    --grm-border:       var(--border, rgba(124, 58, 237, 0.20));
    --grm-border-hover: var(--border-strong, rgba(124, 58, 237, 0.45));
    --grm-indigo:       var(--accent-violet, #7c3aed);
    --grm-indigo-dim:   rgba(124, 58, 237, 0.12);
    --grm-indigo-glow:  rgba(124, 58, 237, 0.30);
    --grm-emerald:      var(--accent-emerald, #06d6a0);
    --grm-emerald-dim:  rgba(6, 214, 160, 0.12);
    --grm-amber:        var(--accent-gold, #ffd60a);
    --grm-amber-dim:    rgba(255, 214, 10, 0.15);
    --grm-red:          var(--accent-magenta, #f72585);
    --grm-red-dim:      rgba(247, 37, 133, 0.15);
    --grm-text:         var(--text-primary, #f0f0f8);
    --grm-muted:        var(--text-secondary, #9d9bb5);
    --grm-muted-2:      var(--text-muted, #5a5875);
    --font-ui:         'Inter', system-ui, sans-serif;
    --font-mono:       'JetBrains Mono', monospace;
    --radius:          10px;
    --radius-lg:       14px;
    --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md:       0 4px 20px rgba(0, 0, 0, 0.45);
    --transition:      200ms ease;
}

/* Light mode overrides — kept neutral, no longer pulls forest greens */
.light-mode {
    --grm-bg:        #f1f5f9;
    --grm-surface:   #ffffff;
    --grm-surface-2: #f8fafc;
    --grm-surface-3: #f1f5f9;
    --grm-border:    rgba(0, 0, 0, 0.08);
    --grm-text:      #1e293b;
    --grm-muted:     #64748b;
    background-color: var(--grm-bg) !important;
    color: var(--grm-text) !important;
}

/* ─── NAV ADDITIONS ─── */
.nav-mode-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 5px 9px;
    cursor: pointer;
    color: #fff;
    font-size: 0.9rem;
    transition: background var(--transition);
}
.nav-mode-btn:hover { background: rgba(255, 255, 255, 0.16); }

.nav-username {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--grm-muted);
}

.nav-streak {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--grm-amber);
    font-family: var(--font-mono);
}

.nav-nivel {
    font-size: 0.72rem;
    font-weight: 800;
    color: #0f0f1a;
    background: var(--grm-indigo);
    padding: 2px 8px;
    border-radius: 10px;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
}

.nav-btn {
    color: var(--grm-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-family: var(--font-ui);
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.nav-btn:hover {
    color: var(--grm-text);
    background: rgba(255, 255, 255, 0.06);
}

/* ─── GLASSMORPHISM CARD ─── */
.glass-card {
    background: var(--grm-surface);
    border: 1px solid var(--grm-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(8px);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.glass-card:hover {
    border-color: var(--grm-border-hover);
    box-shadow: var(--shadow-sm);
}

/* ─── STAT / METRIC CARD ─── */
.stat-card {
    background: var(--grm-surface);
    border: 1px solid var(--grm-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--grm-border-hover); }

.stat-label {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--grm-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--grm-text);
    line-height: 1.2;
}
.stat-sub {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--grm-muted);
}

.stat-value.indigo { color: var(--grm-indigo); }
.stat-value.emerald { color: var(--grm-emerald); }
.stat-value.amber { color: var(--grm-amber); }

/* ─── PROVIDER STATUS BADGE ─── */
.provider-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: opacity var(--transition);
}
.provider-badge.state-closed {
    background: var(--grm-emerald-dim);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--grm-emerald);
}
.provider-badge.state-open {
    background: var(--grm-red-dim);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--grm-red);
}
.provider-badge.state-half_open {
    background: var(--grm-amber-dim);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--grm-amber);
}
.provider-badge.state-unknown {
    background: rgba(100, 116, 139, 0.15);
    border-color: rgba(100, 116, 139, 0.3);
    color: var(--grm-muted);
}
.provider-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
    flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}
.state-open .provider-dot { animation: none; }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── PROGRESS BAR ─── */
.progress-bar-track {
    background: var(--grm-surface-2);
    border-radius: 999px;
    overflow: hidden;
    height: 6px;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--grm-indigo), var(--grm-emerald));
    transition: width 0.5s ease;
}

/* ─── GENRE SELECTOR BUTTONS ─── */
.genre-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 8px;
    border: 1px solid var(--grm-border);
    background: transparent;
    color: var(--grm-muted);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition);
}
.genre-btn:hover {
    border-color: var(--grm-border-hover);
    color: var(--grm-text);
    background: rgba(255, 255, 255, 0.04);
}
.genre-btn.active {
    border-color: var(--grm-indigo);
    background: var(--grm-indigo-dim);
    color: var(--grm-indigo);
    box-shadow: 0 0 12px var(--grm-indigo-glow);
}
.genre-btn .genre-icon { font-size: 1.25rem; }

/* ─── SECTION HEADER ─── */
.section-header {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--grm-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
}

/* ─── HISTORY ITEM ─── */
.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition);
    font-family: var(--font-ui);
    font-size: 0.82rem;
}
.history-item:hover { background: var(--grm-surface-2); }
.history-num {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--grm-indigo);
    font-size: 0.8rem;
    min-width: 50px;
}
.history-word {
    color: var(--grm-muted);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── SEGMENTO CARD ─── */
.segment-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--grm-surface-2);
    border: 1px solid var(--grm-border);
    border-left: 3px solid var(--grm-indigo);
    border-radius: 8px;
    gap: 8px;
    transition: border-color var(--transition);
}
.segment-chip:hover { border-color: var(--grm-indigo); }
.segment-pair {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--grm-text);
}
.segment-tag {
    background: var(--grm-indigo-dim);
    color: var(--grm-indigo);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── LOADING SPINNER ─── */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--grm-indigo);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOAST NOTIFICATIONS ─── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    cursor: pointer;
    max-width: 340px;
    border: 1px solid;
}
.toast-success {
    background: rgba(16, 42, 30, 0.95);
    border-color: rgba(52, 211, 153, 0.4);
    color: #6ee7b7;
}
.toast-error {
    background: rgba(42, 16, 16, 0.95);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}
.toast-warning {
    background: rgba(42, 36, 16, 0.95);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}
.toast-info {
    background: rgba(18, 18, 40, 0.95);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg { flex: 1; }

/* Toast transitions */
.toast-enter { transition: all 0.2s ease; }
.toast-enter-start { opacity: 0; transform: translateX(20px); }
.toast-enter-end { opacity: 1; transform: translateX(0); }
.toast-leave { transition: all 0.2s ease; }
.toast-leave-start { opacity: 1; }
.toast-leave-end { opacity: 0; transform: translateX(20px); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ─── UTILITY ─── */
.font-mono { font-family: var(--font-mono) !important; }
.font-ui   { font-family: var(--font-ui) !important; }
.text-indigo  { color: var(--grm-indigo) !important; }
.text-emerald { color: var(--grm-emerald) !important; }
.text-amber   { color: var(--grm-amber) !important; }
.text-muted-gr{ color: var(--grm-muted) !important; }
