/**
 * Shared Hub Styles for CronLoop Dashboard
 * Extracted from hub pages to reduce CSS duplication
 * Created: 2026-01-25
 *
 * This file contains common styles used across all hub/center pages:
 * - CSS Variables (color palette, spacing)
 * - Base reset and body styles
 * - Container and layout classes
 * - Tab navigation components
 * - Card and section components
 * - Stats grid components
 * - Button styles
 * - Loading states
 * - Status badges
 * - Responsive utilities
 */

/* ============================================
   CSS VARIABLES - Color Palette & Tokens
   ============================================ */
:root {
    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;

    /* Accent Colors */
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --accent-dark: #2563eb;

    /* Semantic Colors */
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --info: #38bdf8;

    /* Extended Palette */
    --cyan: #06b6d4;
    --purple: #a855f7;
    --pink: #ec4899;
    --orange: #f97316;
    --emerald: #10b981;

    /* Agent Colors */
    --idea-maker: #eab308;
    --project-manager: #a855f7;
    --developer: #3b82f6;
    --developer2: #06b6d4;
    --tester: #22c55e;
    --security: #ef4444;
    --supervisor: #f97316;

    /* Terminal Colors */
    --terminal-text: #00ff00;
    --terminal-dim: #007700;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Light Theme Support */
:root.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
}

/* ============================================
   BASE RESET & BODY STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.container-narrow {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ============================================
   HEADER STYLES
   ============================================ */
header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(135deg, var(--accent), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.nav-link {
    display: inline-block;
    margin-top: var(--spacing-lg);
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-link:hover {
    text-decoration: underline;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--accent);
    text-decoration: none;
    margin-bottom: var(--spacing-md);
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* ============================================
   TAB NAVIGATION
   ============================================ */
.tab-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--bg-card);
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-normal);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--accent);
}

.tab-icon {
    font-size: 1.1rem;
}

/* Alternative Tab Style (pill-style) */
.main-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-xl);
    justify-content: center;
}

.main-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.main-tab:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.main-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.main-tab .icon {
    font-size: 1.1rem;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn var(--transition-slow);
}

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

/* ============================================
   CARD & SECTION COMPONENTS
   ============================================ */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--bg-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.card-icon {
    font-size: 1.25rem;
}

.card-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-transform: uppercase;
}

.section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--bg-card);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ============================================
   STATS GRID COMPONENTS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    border: 1px solid var(--bg-card);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.error { color: var(--error); }
.stat-value.purple { color: var(--purple); }
.stat-value.cyan { color: var(--cyan); }
.stat-value.orange { color: var(--orange); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--spacing-xs);
}

/* Summary Hero */
.summary-hero {
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--bg-card);
}

.summary-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
}

.summary-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--spacing-lg);
}

/* ============================================
   BUTTON STYLES
   ============================================ */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-normal);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.control-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-normal);
}

.control-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.control-btn.active {
    background: var(--accent);
    color: white;
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-card);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

/* ============================================
   STATUS BADGES & INDICATORS
   ============================================ */
.status-ok {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status-warning {
    background: rgba(234, 179, 8, 0.2);
    color: var(--warning);
}

.status-critical,
.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.2);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

.badge-agent {
    background: rgba(168, 85, 247, 0.2);
    color: var(--purple);
}

/* ============================================
   GAUGE & PROGRESS COMPONENTS
   ============================================ */
.gauge-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.gauge-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.gauge-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    margin: var(--spacing-lg) 0;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.gauge-fill.ok { background: var(--success); }
.gauge-fill.warning { background: var(--warning); }
.gauge-fill.critical { background: var(--error); }

.progress-bar {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-slow);
}

.progress-fill.healthy { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.critical { background: var(--error); }

/* ============================================
   FILTER & SEARCH COMPONENTS
   ============================================ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    align-items: center;
}

.filter-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--bg-card);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.search-container {
    position: relative;
    margin-bottom: var(--spacing-lg);
}

.search-input {
    width: 100%;
    padding: 1rem 1.25rem 1rem 3rem;
    background: var(--bg-card);
    border: 2px solid var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-normal);
}

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

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* ============================================
   TABLE STYLES
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-card);
}

.data-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.data-table tr:hover td {
    background: rgba(59, 130, 246, 0.05);
}

/* ============================================
   TIMELINE COMPONENTS
   ============================================ */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--bg-card);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--spacing-lg);
}

.timeline-dot {
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-secondary);
}

.timeline-dot.first { background: var(--success); }
.timeline-dot.success { background: var(--success); }
.timeline-dot.warning { background: var(--warning); }
.timeline-dot.error { background: var(--error); }

.timeline-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

/* ============================================
   AGENT CARDS
   ============================================ */
.agent-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border-left: 4px solid var(--accent);
}

.agent-card.idea-maker { border-left-color: var(--idea-maker); }
.agent-card.project-manager { border-left-color: var(--project-manager); }
.agent-card.developer { border-left-color: var(--developer); }
.agent-card.developer2 { border-left-color: var(--developer2); }
.agent-card.tester { border-left-color: var(--tester); }
.agent-card.security { border-left-color: var(--security); }
.agent-card.supervisor { border-left-color: var(--supervisor); }

/* ============================================
   FOOTER
   ============================================ */
footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }

    h1 {
        font-size: 1.75rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .tab-container {
        justify-content: flex-start;
    }

    .main-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: var(--spacing-md);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-secondary); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }

.hidden { display: none; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Monospace font for code */
.mono {
    font-family: 'Monaco', 'Menlo', 'JetBrains Mono', 'Fira Code', monospace;
}
