/* ============================================================
   OpenClaw Dashboard — Premium Dark Theme
   ============================================================ */

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

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(139, 92, 246, 0.3);
    --text-primary: #f0f0f5;
    --text-secondary: #8b8b9e;
    --text-muted: #55556a;
    --accent-violet: #8b5cf6;
    --accent-violet-light: #a78bfa;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --gradient-primary: linear-gradient(135deg, #8b5cf6, #06b6d4);
    --gradient-card: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(6, 182, 212, 0.05));
    --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* --- Animated Background --- */
.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-pattern::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation: float 20s ease-in-out infinite;
}

.bg-pattern::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
    animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Layout --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* --- Header --- */
.header {
    text-align: center;
    margin-bottom: 48px;
}

.header__logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.header__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-glow);
}

.header__title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-card);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card__title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

/* --- Status Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge--running {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge--stopped {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.badge--syncing {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* --- Status Grid --- */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.status-item {
    text-align: center;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.status-item__label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.status-item__value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.status-item__value--accent {
    color: var(--accent-violet-light);
}

/* --- Model Switcher --- */
.model-switcher {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.model-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.model-option {
    position: relative;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all var(--transition-smooth);
    text-align: center;
}

.model-option:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: var(--bg-card-hover);
}

.model-option.active {
    border-color: var(--accent-violet);
    background: rgba(139, 92, 246, 0.06);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}

.model-option.active::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-violet);
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.model-option__icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.model-option__name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.model-option__id {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.model-option__tag {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.model-option__tag--balanced {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-violet-light);
}

.model-option__tag--context {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-cyan);
}

/* --- Swap Button --- */
.btn-swap {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.btn-swap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-swap:hover::before {
    opacity: 1;
}

.btn-swap:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}

.btn-swap:active {
    transform: translateY(0);
}

.btn-swap:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-swap:disabled::before {
    display: none;
}

/* --- Logs Card --- */
.logs-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.logs-container::-webkit-scrollbar {
    width: 4px;
}

.logs-container::-webkit-scrollbar-track {
    background: transparent;
}

.logs-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.log-entry {
    padding: 2px 0;
}

.log-entry--info { color: var(--accent-cyan); }
.log-entry--success { color: var(--accent-emerald); }
.log-entry--warning { color: var(--accent-amber); }
.log-entry--error { color: var(--accent-rose); }

.log-time {
    color: var(--text-muted);
    margin-right: 8px;
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-spring);
    backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast--success {
    background: rgba(16, 185, 129, 0.9);
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.toast--error {
    background: rgba(244, 63, 94, 0.9);
    border: 1px solid rgba(244, 63, 94, 0.5);
}

.toast--info {
    background: rgba(139, 92, 246, 0.9);
    border: 1px solid rgba(139, 92, 246, 0.5);
}

/* --- Footer --- */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.footer__text {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.footer__link {
    color: var(--accent-violet-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer__link:hover {
    color: var(--accent-violet);
}

/* --- Spinner --- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* --- Sign Out Button --- */
.btn-signout {
    margin-top: 12px;
    padding: 8px 20px;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-smooth);
}

.btn-signout:hover {
    border-color: var(--accent-rose);
    color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.06);
}

/* --- Clerk Overrides --- */
#clerk-sign-in {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .container {
        padding: 24px 16px 40px;
    }

    .header__title {
        font-size: 1.6rem;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .model-options {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px;
    }
}
