/* ============================================================
   HALFBLOOD DASHBOARD — STYLE.CSS
   Dark theme management dashboard for Hermes Agent Platform
   ============================================================ */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
    /* Backgrounds */
    --bg-body: #08080d;
    --bg-card: #111119;
    --bg-card-hover: #16161f;
    --bg-sidebar: #0c0c14;
    --bg-input: #0e0e16;
    --bg-modal-overlay: rgba(0, 0, 0, 0.7);
    --bg-tooltip: #1a1a2e;

    /* Borders */
    --border-color: #1e1e2e;
    --border-color-hover: #2a2a3e;
    --border-color-focus: #7c3aed;

    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #08080d;

    /* Accent: Purple */
    --accent-purple: #7c3aed;
    --accent-purple-light: #a78bfa;
    --accent-purple-dark: #5b21b6;
    --accent-purple-bg: rgba(124, 58, 237, 0.1);
    --accent-purple-bg-hover: rgba(124, 58, 237, 0.2);

    /* Accent: Teal */
    --accent-teal: #14b8a6;
    --accent-teal-light: #5eead4;
    --accent-teal-dark: #0d9488;
    --accent-teal-bg: rgba(20, 184, 166, 0.1);

    /* Status Colors */
    --color-success: #22c55e;
    --color-success-bg: rgba(34, 197, 94, 0.1);
    --color-warning: #f59e0b;
    --color-warning-bg: rgba(245, 158, 11, 0.1);
    --color-error: #ef4444;
    --color-error-bg: rgba(239, 68, 68, 0.1);
    --color-info: #3b82f6;
    --color-info-bg: rgba(59, 130, 246, 0.1);

    /* Spacing */
    --sidebar-width: 260px;
    --top-bar-height: 64px;
    --content-max-width: 1400px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

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

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

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
}

pre {
    overflow-x: auto;
}

code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.875rem;
}

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

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.logo-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.logo-text {
    display: flex;
    flex-direction: column;
}
.logo-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}
.sidebar-nav ul {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.935rem;
    transition: all var(--transition-fast);
    position: relative;
}
.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.nav-item:hover {
    background: var(--accent-purple-bg);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--accent-purple-bg-hover);
    color: var(--accent-purple-light);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-purple);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}
.sidebar-footer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 6px var(--color-success);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    display: block;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

/* Top Bar */
.top-bar {
    position: sticky;
    top: 0;
    height: var(--top-bar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(8, 8, 13, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}
.mobile-menu-btn:hover {
    background: var(--accent-purple-bg);
    color: var(--text-primary);
}
.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    min-width: 240px;
    transition: border-color var(--transition-fast);
}
.search-box:focus-within {
    border-color: var(--accent-purple);
}
.search-box svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
    font-size: 0.9rem;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

/* Top Bar Buttons */
.top-bar-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}
.top-bar-btn:hover {
    background: var(--accent-purple-bg);
    color: var(--text-primary);
}
.top-bar-btn svg {
    width: 18px;
    height: 18px;
}
.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--color-error);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* User Avatar */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}
.user-avatar:hover {
    box-shadow: 0 0 0 3px var(--accent-purple-bg-hover);
}
.user-avatar svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

/* Page Container */
.page-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 28px 32px 60px;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 2px;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================================
   PAGES — Show/Hide
   ============================================================ */
.page {
    display: none;
    animation: fadeIn 0.25s ease;
}
.page.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition-normal);
}
.stat-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg {
    width: 22px;
    height: 22px;
}
.stat-icon.purple {
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
}
.stat-icon.teal {
    background: var(--accent-teal-bg);
    color: var(--accent-teal-light);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}
.stat-change {
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}
.stat-change svg {
    width: 14px;
    height: 14px;
}
.stat-change.positive {
    color: var(--color-success);
}
.stat-change.negative {
    color: var(--color-error);
}
.stat-change.neutral {
    color: var(--text-muted);
}

/* ============================================================
   CARD (generic)
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: border-color var(--transition-fast);
}
.card:hover {
    border-color: var(--border-color-hover);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}
.card-header h2 svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* Chart Card */
.chart-card {
    margin-bottom: 24px;
}
.chart-wrapper {
    position: relative;
    height: 280px;
}
.chart-legend {
    display: flex;
    gap: 16px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.legend-dot.purple {
    background: var(--accent-purple);
}
.legend-dot.teal {
    background: var(--accent-teal);
}

/* Two Column Layout */
.two-col {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
}

/* ============================================================
   ACTIVITY FEED
   ============================================================ */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.activity-item:hover {
    background: var(--bg-card-hover);
}
.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
}
.activity-icon svg {
    width: 15px;
    height: 15px;
}
.activity-icon.teal {
    background: var(--accent-teal-bg);
    color: var(--accent-teal-light);
}
.activity-icon.success {
    background: var(--color-success-bg);
    color: var(--color-success);
}
.activity-icon.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}
.activity-info {
    flex: 1;
    min-width: 0;
}
.activity-desc {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.4;
}
.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ============================================================
   QUICK ACTIONS
   ============================================================ */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 16px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.88rem;
    transition: all var(--transition-normal);
}
.quick-action-card svg {
    width: 22px;
    height: 22px;
    color: var(--accent-purple-light);
}
.quick-action-card:hover {
    background: var(--accent-purple-bg);
    border-color: var(--accent-purple);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent-purple);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-purple-dark);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-error);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}
.btn-success:hover {
    background: #16a34a;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 10px;
}
.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}
.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}
.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ============================================================
   SESSIONS PAGE
   ============================================================ */
.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.session-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}
.session-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.1);
}
.session-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.session-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.session-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.session-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.session-card-meta .badge {
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}
.session-card-preview {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-card-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    display: none;
    gap: 4px;
}
.session-card:hover .session-card-actions {
    display: flex;
}

/* ============================================================
   API KEYS PAGE
   ============================================================ */
.keys-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.key-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}
.key-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.key-info {
    flex: 1;
    min-width: 0;
}
.key-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.key-prefix {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    color: var(--accent-purple-light);
    background: var(--accent-purple-bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-bottom: 6px;
}
.key-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.key-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Status Badge */
.status-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge.active {
    background: var(--color-success-bg);
    color: var(--color-success);
}
.status-badge.paused {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}
.status-badge.revoked {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* ============================================================
   WEBHOOKS PAGE
   ============================================================ */
.webhooks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.webhook-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}
.webhook-card:hover {
    border-color: var(--border-color-hover);
}

.webhook-card-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.webhook-info {
    flex: 1;
    min-width: 0;
}
.webhook-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.webhook-events {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.webhook-event-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    background: var(--accent-teal-bg);
    color: var(--accent-teal-light);
}
.webhook-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.webhook-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.webhook-card-body {
    padding: 0 20px 20px;
    display: none;
}
.webhook-card-body.open {
    display: block;
}
.webhook-prompt-preview {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 160px;
    overflow-y: auto;
}

/* ============================================================
   CRON JOBS PAGE
   ============================================================ */
.cron-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cron-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}
.cron-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.cron-info {
    flex: 1;
    min-width: 0;
}
.cron-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.cron-schedule {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    color: var(--accent-teal-light);
    background: var(--accent-teal-bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-bottom: 6px;
}
.cron-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.cron-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ============================================================
   INTEGRATIONS PAGE
   ============================================================ */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
    gap: 16px;
}

.integration-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color var(--transition-fast);
}
.integration-card:hover {
    border-color: var(--border-color-hover);
}

.integration-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.integration-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.integration-icon svg {
    width: 20px;
    height: 20px;
}
.integration-meta {
    flex: 1;
    min-width: 0;
}
.integration-meta h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.integration-meta p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.integration-body {
    margin-bottom: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
.integration-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Code Block */
.code-block {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}
.copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.copy-btn:hover {
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
}
.copy-btn svg {
    width: 12px;
    height: 12px;
}
.copy-btn.copied {
    color: var(--color-success);
}

.code-block pre {
    padding: 14px;
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
    overflow-x: auto;
}
.code-block code {
    font-size: 0.82rem;
}

/* ============================================================
   SETTINGS PAGE
   ============================================================ */
.settings-card {
    margin-bottom: 20px;
}
.settings-card.danger-zone {
    border-color: rgba(239, 68, 68, 0.25);
}
.settings-card.danger-zone .card-header h2 {
    color: var(--color-error);
}
.settings-card.danger-zone .card-header h2 svg {
    color: var(--color-error);
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group input,
.form-group textarea,
.form-group select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px var(--accent-purple-bg);
}
.form-group input.readonly {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}
.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}
.input-with-btn input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
.input-with-btn input:focus {
    border-color: var(--accent-purple);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}

.danger-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 12px 16px;
    background: var(--color-error-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-error);
}

.model-info-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.badge {
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-purple {
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
}
.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Tag Input */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    min-height: 42px;
    transition: border-color var(--transition-fast);
    cursor: text;
}
.tag-input:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px var(--accent-purple-bg);
}
.tag-input input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    flex: 1;
    min-width: 120px;
    font-size: 0.88rem;
}
.tag-input input::placeholder {
    color: var(--text-muted);
}
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-purple-bg);
    color: var(--accent-purple-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 500;
}
.tag button {
    display: inline-flex;
    align-items: center;
    color: var(--accent-purple-light);
    opacity: 0.6;
    transition: opacity var(--transition-fast);
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}
.tag button:hover {
    opacity: 1;
}
.tag button svg {
    width: 12px;
    height: 12px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 24px;
}
.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}
.modal-close:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}
.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: 24px;
}

/* Key Reveal Box (shown after generating a key) */
.key-reveal-box {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 16px;
}
.key-reveal-box .warning-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--color-warning);
    margin-bottom: 8px;
    font-size: 0.88rem;
}
.key-reveal-box .warning-title svg {
    width: 16px;
    height: 16px;
}
.key-reveal-box .key-text {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    word-break: break-all;
    margin-bottom: 10px;
    line-height: 1.5;
}
.key-reveal-box .warning-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Confirmation Dialog */
.confirm-dialog {
    text-align: center;
    padding: 8px 0;
}
.confirm-dialog .confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-error-bg);
    color: var(--color-error);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.confirm-dialog .confirm-icon svg {
    width: 28px;
    height: 28px;
}
.confirm-dialog h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.confirm-dialog p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}
.confirm-dialog .confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================================
   CHAT MODAL (Fullscreen overlay)
   ============================================================ */
.chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 300;
    flex-direction: column;
}
.chat-overlay.active {
    display: flex;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    flex-shrink: 0;
}
.chat-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}
.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    max-width: 75%;
    gap: 10px;
}
.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-message.assistant {
    align-self: flex-start;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
}
.chat-message.user .chat-message-avatar {
    background: var(--accent-purple);
    color: #fff;
}
.chat-message.assistant .chat-message-avatar {
    background: var(--accent-teal);
    color: #fff;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-message.user .chat-message-content {
    background: var(--accent-purple);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-message.assistant .chat-message-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    flex-shrink: 0;
}
.chat-input-bar input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}
.chat-input-bar input:focus {
    border-color: var(--accent-purple);
}

/* Chat empty state */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 12px;
}
.chat-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}
.chat-empty p {
    font-size: 0.95rem;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 500;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-size: 0.88rem;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 420px;
}
.toast.removing {
    animation: toastOut 0.25s ease forwards;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.toast.success .toast-icon { color: var(--color-success); }
.toast.error .toast-icon { color: var(--color-error); }
.toast.info .toast-icon { color: var(--color-info); }
.toast.warning .toast-icon { color: var(--color-warning); }

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-error); }
.toast.info { border-left: 3px solid var(--color-info); }
.toast.warning { border-left: 3px solid var(--color-warning); }

.toast-message {
    flex: 1;
    line-height: 1.4;
}
.toast-close {
    color: var(--text-muted);
    padding: 2px;
    cursor: pointer;
    transition: color var(--transition-fast);
}
.toast-close:hover {
    color: var(--text-primary);
}
.toast-close svg {
    width: 14px;
    height: 14px;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 13, 0.6);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Inline spinner */
.spinner-sm {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}
.empty-state svg {
    width: 56px;
    height: 56px;
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 20px;
}
.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.empty-state p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    max-width: 360px;
}

/* ============================================================
   HELPER CLASSES
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.72rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* Tablet: < 1200px */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .integrations-grid {
        grid-template-columns: 1fr;
    }
}

/* Tablet small: < 1024px */
@media (max-width: 1024px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

/* Mobile: < 768px */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .top-bar {
        padding: 0 16px;
    }

    .search-box {
        min-width: 160px;
    }

    .page-container {
        padding: 20px 16px 40px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header h1 {
        font-size: 1.4rem;
    }

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

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .key-card,
    .cron-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .key-actions,
    .cron-actions {
        align-self: flex-end;
        margin-top: 8px;
    }

    .webhook-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .webhook-card-actions {
        align-self: flex-end;
        margin-top: 8px;
    }

    .chat-message {
        max-width: 90%;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
    .toast {
        min-width: auto;
    }

    .modal {
        max-width: 100%;
        margin: 16px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }
}

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

    .stat-card {
        padding: 16px;
    }

    .page-header-actions {
        width: 100%;
    }
    .page-header-actions .search-box {
        flex: 1;
        min-width: 0;
    }
}
