/* ============================================
   PSYCHE AI Tracker — Dashboard Styles
   ============================================ */

/* === Layout === */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* === Sidebar === */
.dashboard-sidebar {
    width: 260px;
    background: var(--surface-1);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: var(--space-5) var(--space-5) 0;
}

.sidebar-header .nav-logo { font-size: var(--text-lg); }
.sidebar-header .nav-logo-img { height: 32px; }

.sidebar-nav {
    flex: 1;
    padding: var(--space-6) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background: rgba(6, 182, 212, 0.05);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(6, 182, 212, 0.1);
    color: var(--cyan-400);
    font-weight: 600;
}

.sidebar-link svg { width: 18px; height: 18px; }

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-3) var(--space-4);
}

.sidebar-user {
    padding: var(--space-4);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: var(--text-sm);
}

.user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.user-plan {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* === Main Content === */
.dashboard-main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Top Bar === */
.dashboard-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.topbar-left h1 {
    font-family: var(--font-body);
    font-size: var(--text-xl);
    font-weight: 700;
}

.topbar-date {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.topbar-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.topbar-btn:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.topbar-btn svg { width: 18px; height: 18px; }

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-2);
}

/* === Page Views === */
.page-view {
    display: none;
    padding: var(--space-6);
    animation: viewFadeIn 0.3s ease;
}

.page-view.active { display: block; }

@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    padding: var(--space-5);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.stat-card:hover {
    border-color: rgba(6, 182, 212, 0.2);
    transform: translateY(-2px);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: var(--space-3);
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    font-family: var(--font-body);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.stat-value small {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-tertiary);
}

.stat-unit {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 500;
    margin-bottom: var(--space-3);
}

.stat-change {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--surface-2);
}

.stat-bar {
    height: 4px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 1s ease;
}

/* === Dashboard Grid === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

/* === Chart Cards === */
.chart-card {
    padding: var(--space-5);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    transition: all 0.3s;
}

.chart-card:hover {
    border-color: rgba(6, 182, 212, 0.15);
}

.chart-card h3 {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 700;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.chart-container {
    position: relative;
    height: 250px;
}

/* === Timeline === */
.timeline-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.timeline-hour {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    width: 55px;
    text-align: right;
    white-space: nowrap;
}

.timeline-hour.current {
    color: var(--cyan-400);
}

.timeline-bar-bg {
    flex: 1;
    height: 18px;
    background: var(--surface-3);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.timeline-bar {
    height: 100%;
    border-radius: var(--radius-md);
    transition: width 0.5s ease;
}

/* === Heatmap === */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
}

.heatmap-full {
    grid-template-columns: repeat(24, 1fr);
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--surface-3);
    transition: all 0.2s;
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.3);
    z-index: 2;
}

/* === Suggestions === */
.suggestions-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.suggestion-icon {
    font-size: var(--text-lg);
    flex-shrink: 0;
}

/* === Timer === */
.timer-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: var(--space-6);
    align-items: start;
}

.timer-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-8) 0;
}

.timer-ring-container {
    position: relative;
    width: 300px;
    height: 300px;
}

.timer-ring {
    width: 300px;
    height: 300px;
}

.timer-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-display {
    font-family: var(--font-mono);
    font-size: 56px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.timer-label {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.timer-controls {
    display: flex;
    gap: var(--space-4);
}

.timer-presets {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: center;
}

.timer-preset {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.timer-preset:hover,
.timer-preset.active {
    background: rgba(6, 182, 212, 0.1);
    border-color: var(--cyan-400);
    color: var(--cyan-400);
}

/* AI Status Bar */
.ai-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
}

.ai-status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 500;
}

.ai-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--green-400, #10b981);
    animation: dotPulse 2s ease infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.live-focus-score {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.focus-score-value {
    font-family: var(--font-mono);
    font-weight: 700;
}

.focus-score-value.high { color: #10b981; }
.focus-score-value.mid { color: #f59e0b; }
.focus-score-value.low { color: #ef4444; }

/* Session History */
.session-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
}

.session-time {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    font-weight: 500;
}

.session-duration {
    color: var(--text-secondary);
    font-weight: 600;
}

.session-score {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--text-xs);
}

.session-score.high { color: #10b981; }
.session-score.mid { color: #f59e0b; }
.session-score.low { color: #ef4444; }

.no-data {
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    padding: var(--space-6);
}

/* Tips */
.tips-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.tip-item {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.5;
}

.tip-item:last-child { border-bottom: none; }

/* === Analytics === */
.analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-4);
}

.chart-large {
    grid-column: span 1;
}

.best-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.best-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-color);
}

.best-stat-item:last-child { border-bottom: none; }

.best-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.best-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--cyan-400);
}

/* === Achievements === */
.achievements-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-4);
    align-items: start;
}

.xp-meter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
}

.xp-circle {
    position: relative;
    width: 120px;
    height: 120px;
}

.xp-circle svg { transform: rotate(-90deg); }

.xp-level {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.xp-level-number {
    font-size: var(--text-3xl);
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.xp-level-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
}

.xp-info { width: 100%; }
.xp-bar-wrap { margin-bottom: var(--space-2); }

.xp-bar {
    height: 8px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-1);
}

.xp-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 1s ease;
}

.xp-text {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    display: block;
    text-align: right;
}

.xp-next {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
}

.badges-grid-full {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    border-radius: var(--radius-xl);
    background: var(--surface-2);
    transition: all 0.3s;
    text-align: center;
}

.badge-item.unlocked {
    border: 1px solid rgba(6, 182, 212, 0.2);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.05);
}

.badge-item.locked {
    opacity: 0.35;
    filter: grayscale(1);
}

.badge-item:hover { transform: scale(1.05); }

.badge-icon { font-size: var(--text-3xl); }

.badge-name {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
}

.badge-desc {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    line-height: 1.4;
}

.badge-unlocked {
    font-size: 10px;
    font-weight: 700;
    color: #10b981;
    margin-top: var(--space-1);
}

/* === AI Insights === */
.insights-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.insight-card {
    display: flex;
    gap: var(--space-5);
    padding: var(--space-6);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    transition: all 0.3s;
}

.insight-card:hover {
    border-color: rgba(6, 182, 212, 0.2);
    transform: translateX(4px);
}

.insight-icon {
    font-size: var(--text-3xl);
    flex-shrink: 0;
}

.insight-content h4 {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.insight-content p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-3);
}

.insight-meta {
    display: flex;
    gap: var(--space-4);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.insight-confidence {
    padding: 2px 8px;
    background: rgba(6, 182, 212, 0.1);
    border-radius: var(--radius-full);
    color: var(--cyan-400);
    font-weight: 600;
}

.insights-empty {
    text-align: center;
    padding: var(--space-12);
}

.insights-empty-icon {
    font-size: 64px;
    margin-bottom: var(--space-4);
}

.insights-empty h3 {
    font-family: var(--font-body);
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

.insights-empty p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

.insights-progress {
    margin-top: var(--space-4) !important;
    font-weight: 600 !important;
    color: var(--cyan-400) !important;
}

/* === Settings === */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.settings-group {
    margin-bottom: var(--space-4);
}

.settings-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.settings-desc {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
    line-height: 1.4;
}

.settings-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    transition: all 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--cyan-400);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: var(--radius-full);
    transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gradient-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* === Responsive === */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .analytics-grid { grid-template-columns: 1fr; }
    .timer-layout { grid-template-columns: 1fr; }
    .achievements-layout { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .badges-grid-full { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
    }
    .dashboard-sidebar.open {
        transform: translateX(0);
    }
    .dashboard-main {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .badges-grid-full { grid-template-columns: repeat(2, 1fr); }
    .timer-ring-container {
        width: 240px;
        height: 240px;
    }
    .timer-ring {
        width: 240px;
        height: 240px;
    }
    .timer-display {
        font-size: 42px;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-view { padding: var(--space-4); }
    .timer-sidebar { display: none; }
    .badges-grid-full { grid-template-columns: 1fr 1fr; }
}
