/* IA-Pi Dashboard — Dark Theme v2 (clean, smooth, faithful) */

:root {
    --bg: #0a0e1a;
    --bg2: #111827;
    --bg3: #1e293b;
    --surface: #1a2236;
    --surface2: #222d42;
    --border: #2d3a52;
    --text: #e2e8f0;
    --text2: #94a3b8;
    --text3: #64748b;
    --accent: #6366f1;
    --accent2: #22d3ee;
    --green: #10b981;
    --yellow: #f59e0b;
    --red: #ef4444;
    --orange: #f97316;
    --purple: #8b5cf6;
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 220px;
    --transition: 0.2s ease;
    --transition-page: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.nav-brand {
    padding: 20px 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.brand-icon { font-size: 22px; }

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 20px;
    cursor: pointer;
    margin-left: auto;
}

.nav-links {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text2);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg3);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--accent);
}

.nav-icon { width: 18px; text-align: center; font-size: 14px; }
.bot1-color { color: var(--accent); }
.bot2-color { color: var(--accent2); }

.nav-sep {
    padding: 16px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text3);
}

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

.nav-badge.active { display: inline-block; }

.alert-badge { background: var(--red); }

.nav-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 8px;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text3);
    transition: background var(--transition);
}

.status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.status-dot.offline { background: var(--red); }
.status-dot.connecting { background: var(--yellow); animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.nav-logout {
    display: block;
    text-align: center;
    padding: 6px;
    color: var(--text3);
    text-decoration: none;
    font-size: 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.nav-logout:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }

/* ===== Content ===== */
.content {
    margin-left: var(--sidebar-w);
    padding: 24px;
    min-height: 100vh;
}

/* ===== Pages — smooth transitions ===== */
.page {
    display: none;
    opacity: 0;
    transform: translateY(8px);
}

.page.active {
    display: block;
    animation: pageEnter var(--transition-page) forwards;
}

@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text3);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-label { font-weight: 500; }

/* ===== Grid ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow 0.3s ease, transform 0.2s ease;
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.card-sub {
    font-size: 12px;
    color: var(--text3);
}

.card-body { padding: 16px; }

/* ===== Activity Banner ===== */
.activity-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border-left: 3px solid var(--accent);
    font-size: 13px;
    transition: all var(--transition);
}

.activity-banner.active {
    border-left-color: var(--green);
    background: rgba(16, 185, 129, 0.06);
}

.activity-banner.sleeping {
    border-left-color: var(--text3);
    opacity: 0.7;
}

.activity-banner-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.activity-banner-content {
    flex: 1;
    min-width: 0;
}

.activity-banner-repo {
    font-weight: 600;
    color: var(--accent2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-banner-task {
    color: var(--text2);
    font-size: 12px;
}

.activity-banner-time {
    font-size: 11px;
    color: var(--text3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ===== Mode Badge ===== */
.mode-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition);
}

.mode-badge.work { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.mode-badge.idle { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.mode-badge.sleep { background: rgba(100, 116, 139, 0.15); color: var(--text3); }
.mode-badge.ci_fix { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.mode-badge.ci_fix_deep { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }
.mode-badge.social { background: rgba(34, 211, 238, 0.15); color: var(--accent2); }
.mode-badge.error { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.mode-badge.active { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.mode-badge.stale { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.mode-badge.unknown { background: rgba(100, 116, 139, 0.15); color: var(--text3); }
.mode-badge.release { background: rgba(249, 115, 22, 0.15); color: var(--orange); }
.mode-badge.test { background: rgba(34, 211, 238, 0.15); color: var(--accent2); }
.mode-badge.evolution { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.mode-badge.readme_review { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.mode-badge.curious { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

/* ===== Metrics ===== */
.metric-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.metric {
    flex: 1;
    text-align: center;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    transition: color var(--transition);
}

.metric-label {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value.highlight { color: var(--accent2); }
.metric-value.danger { color: var(--red); }
.metric-value.success { color: var(--green); }

/* ===== Task Info ===== */
.task-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 13px;
}

.task-label { color: var(--text3); }
.task-value { color: var(--text); font-weight: 500; }

/* ===== Progress Bar ===== */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    font-size: 12px;
    color: var(--text3);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

/* ===== Schedule ===== */
.schedule-visual {
    margin-bottom: 12px;
}

.schedule-bar {
    height: 24px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.schedule-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text3);
    margin-top: 4px;
}

.schedule-info {
    font-size: 13px;
    color: var(--text2);
}

.schedule-status {
    font-weight: 600;
    transition: color var(--transition);
}

.schedule-status.active { color: var(--green); }
.schedule-status.sleeping { color: var(--text3); }

/* ===== Alerts ===== */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

.alert-item.critical { background: rgba(239, 68, 68, 0.1); border-left: 3px solid var(--red); }
.alert-item.error { background: rgba(239, 68, 68, 0.1); border-left: 3px solid var(--red); }
.alert-item.warning { background: rgba(245, 158, 11, 0.1); border-left: 3px solid var(--yellow); }
.alert-item.info { background: rgba(99, 102, 241, 0.1); border-left: 3px solid var(--accent); }

.alert-icon { font-size: 16px; }
.alert-message { flex: 1; color: var(--text2); }

/* ===== Timeline ===== */
.timeline {
    max-height: 400px;
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
    transition: transform var(--transition);
}

.timeline-item:hover .timeline-dot { transform: scale(1.4); }

.timeline-dot.error { background: var(--red); }
.timeline-dot.warning { background: var(--yellow); }
.timeline-dot.ci { background: var(--purple); }
.timeline-dot.social { background: var(--accent2); }
.timeline-dot.work { background: var(--green); }
.timeline-dot.info { background: var(--text3); }

.timeline-content { flex: 1; min-width: 0; }

.timeline-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 6px;
    text-transform: uppercase;
}

.timeline-tag.error { background: rgba(239, 68, 68, 0.2); color: var(--red); }
.timeline-tag.warning { background: rgba(245, 158, 11, 0.2); color: var(--yellow); }
.timeline-tag.ci { background: rgba(139, 92, 246, 0.2); color: var(--purple); }
.timeline-tag.social { background: rgba(34, 211, 238, 0.2); color: var(--accent2); }
.timeline-tag.work { background: rgba(16, 185, 129, 0.2); color: var(--green); }
.timeline-tag.info { background: rgba(100, 116, 139, 0.2); color: var(--text3); }

.timeline-msg {
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-time {
    font-size: 11px;
    color: var(--text3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ===== Charts ===== */
.chart-container {
    height: 250px;
    position: relative;
}

.chart-range-select {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
}

/* ===== Logs — colorized ===== */
.log-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text2);
    height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Log line colorization */
.log-commit { color: var(--green); }
.log-push { color: var(--purple); }
.log-error { color: var(--red); font-weight: 600; }
.log-warning { color: var(--yellow); }
.log-groq { color: var(--accent2); }
.log-test { color: #a78bfa; }
.log-release { color: var(--orange); }
.log-mode { color: var(--accent); }
.log-time { color: var(--text3); }
.log-bracket { color: var(--text3); }

/* ===== Buttons ===== */
.btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn:hover { background: var(--surface2); color: var(--text); }
.btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: #4f46e5; }
.btn-full { width: 100%; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text3);
    cursor: pointer;
}

/* ===== Auth Pages ===== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.auth-brand {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 24px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    color: var(--text2);
    font-weight: 500;
}

.form-group input {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
}

.auth-info {
    text-align: center;
    padding: 16px;
    color: var(--text3);
    font-size: 14px;
}

.auth-info a { color: var(--accent); }

.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
}

.auth-footer a { color: var(--text3); text-decoration: none; }
.auth-footer a:hover { color: var(--accent); }

/* ===== Empty / Loading ===== */
.empty-text {
    text-align: center;
    padding: 24px;
    color: var(--text3);
    font-size: 13px;
}

.loading {
    text-align: center;
    padding: 48px;
    color: var(--text3);
    font-size: 14px;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease; }
.slide-up { animation: slideUp 0.3s ease; }

/* ===== Bot Detail Page ===== */
.bot-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.bot-detail-title {
    font-size: 20px;
    font-weight: 700;
}

.bot-detail-subtitle {
    font-size: 13px;
    color: var(--text3);
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text3);
    margin-bottom: 8px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: block;
    }
    .content {
        margin-left: 0;
        padding: 16px;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .grid-3 {
        grid-template-columns: 1fr;
    }
    .metric-row {
        flex-wrap: wrap;
    }
    .metric {
        min-width: calc(50% - 8px);
    }
}
