/* ADA Substrate Web Client — Unified Stylesheet */
:root {
    --primary: #112d46;
    --primary-hover: #1a4466;
    --accent: #38b2ac;
    --accent-hover: #319795;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0b1e2f;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --border: #e2e8f0;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --warning: #f59e0b;
    --success: #16a34a;
    --info: #2563eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--font-mono); font-size: 0.9em; }
pre { white-space: pre-wrap; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* Alpine cloak */
[x-cloak] { display: none !important; }

/* ========== Layout ========== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.main-content { flex: 1; overflow-y: auto; padding: 24px; }

/* Sidebar */
.sidebar {
    width: 220px; min-width: 220px; flex-shrink: 0;
    background: var(--bg-sidebar); color: var(--text-sidebar);
    display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-brand {
    padding: 20px 18px 12px; font-size: 16px; font-weight: 700;
    color: var(--text-sidebar-active); letter-spacing: 0.5px;
}
.sidebar-nav { flex: 1; padding: 0 10px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius);
    color: var(--text-sidebar); font-size: 13px; transition: all 0.15s;
    cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text-sidebar-active); text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); }

/* ========== Page Header ========== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ========== Cards ========== */
.card {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card-header {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 14px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-body { padding: 14px 18px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
    padding: 18px;
}
.stat-card-header { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card-value { font-size: 28px; font-weight: 700; color: var(--primary); }

/* ========== Forms ========== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.form-input, .form-select {
    width: 100%; padding: 8px 12px; font-size: 14px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); color: var(--text);
    transition: border-color 0.15s; font-family: inherit;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,178,172,0.15); }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; font-size: 13px; font-weight: 600;
    border-radius: var(--radius); border: 1px solid transparent;
    cursor: pointer; transition: all 0.15s; font-family: inherit;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; min-width: 30px; }

/* ========== Badges ========== */
.badge {
    display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600;
    border-radius: 12px; background: var(--bg); color: var(--text-muted);
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ========== Tables ========== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.table th { font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg); }
.table tr:hover td { background: var(--bg); }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ========== Tabs ========== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn {
    padding: 8px 16px; font-size: 13px; font-weight: 500;
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-muted); cursor: pointer; transition: all 0.15s;
    font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== Modals ========== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center;
}
.modal {
    background: var(--bg-card); border-radius: 12px; box-shadow: var(--shadow-lg);
    padding: 24px; width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto;
}
.modal-lg { max-width: 800px; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }

/* ========== Live Log ========== */
.live-log {
    background: #1e293b; color: #a7f3d0; border-radius: var(--radius);
    padding: 14px; font-family: var(--font-mono); font-size: 12px;
    max-height: 400px; overflow-y: auto; line-height: 1.7;
}
.log-entry { display: flex; gap: 10px; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.log-time { color: #64748b; min-width: 75px; flex-shrink: 0; }
.log-type { min-width: 50px; flex-shrink: 0; font-weight: 600; color: var(--accent); }
.log-type.error { color: var(--danger); }
.log-type.warn  { color: var(--warning); }

/* ========== WS Status ========== */
.ws-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.ws-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: ws-pulse 2s infinite; }
@keyframes ws-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ========== Error & Status ========== */
.error-message {
    background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: var(--radius);
    font-size: 13px; margin-bottom: 14px; border: 1px solid #fecaca;
}
.success-message {
    background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: var(--radius);
    font-size: 13px; margin-bottom: 14px; border: 1px solid #bbf7d0;
}

/* ========== Spinner ========== */
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-skeleton {
    text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px;
}

/* ========== Login Page ========== */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: #0b1e2f;
    background-image: url('/static/cnbg.png');
    background-repeat: repeat;
}
.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }
.login-container {
    background: var(--bg-card); border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3); padding: 32px;
}
.login-container h1 { font-size: 22px; color: var(--primary); margin-bottom: 4px; }
.login-container .logo-section { text-align: center; margin-bottom: 24px; }
.login-container .logo-section p { color: var(--text-muted); font-size: 13px; }

/* ========== Utilities ========== */
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
