/* CE Tools — Design System
   Dark-first, CE brand: midnight black bg, electric blue / purple accents
   Space Grotesk headings, Inter body (loaded from Google Fonts inline)
*/

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

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

:root {
    --bg:         #0a0a0a;
    --surface:    #111111;
    --surface-2:  #1a1a1a;
    --surface-3:  #222222;
    --border:     #2a2a2a;
    --border-2:   #333333;
    --text:       #e5e5e5;
    --text-muted: #888888;
    --text-dim:   #555555;
    --blue:       #3b82f6;
    --blue-dark:  #1d4ed8;
    --blue-glow:  rgba(59,130,246,0.15);
    --purple:     #8b5cf6;
    --green:      #22c55e;
    --yellow:     #eab308;
    --red:        #ef4444;
    --radius:     8px;
    --radius-lg:  12px;
    --shadow:     0 1px 3px rgba(0,0,0,0.5);
    --font-head:  'Space Grotesk', system-ui, sans-serif;
    --font-body:  'Inter', system-ui, sans-serif;
    --transition: 0.15s ease;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.6; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: #60a5fa; }
code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; background: var(--surface-3); padding: 2px 6px; border-radius: 4px; color: #93c5fd; word-break: break-all; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius); border: none;
    font-family: var(--font-body); font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all var(--transition); white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover   { background: #2563eb; color: #fff; }
.btn-secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); border-color: #444; color: var(--text); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger    { background: transparent; color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; }
.btn svg { width: 16px; height: 16px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-info  { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-warn  { background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.3); color: #fde047; }

/* ── Badge / pill ────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.badge-soon   { background: var(--surface-3); color: var(--text-dim); }
.badge-update { background: rgba(234,179,8,0.15); color: #fde047; border: 1px solid rgba(234,179,8,0.3); }
.badge-ok     { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.badge-warn   { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

/* ── Login page ───────────────────────────────────────────────────────────── */
.page-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.login-logo  { display: flex; align-items: baseline; gap: 8px; margin-bottom: 32px; justify-content: center; }

/* ── Hub ──────────────────────────────────────────────────────────────────── */
.hub { min-height: 100vh; display: flex; flex-direction: column; }
.hub-header { border-bottom: 1px solid var(--border); padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); }
.hub-nav { display: flex; align-items: center; gap: 16px; }
.nav-user { font-size: 13px; color: var(--text-muted); }
.hub-main  { max-width: 900px; margin: 0 auto; padding: 60px 24px; width: 100%; }
.hub-title { font-family: var(--font-head); font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.hub-subtitle { color: var(--text-muted); margin-bottom: 40px; }

/* ── Logo mark ───────────────────────────────────────────────────────────── */
.logo-mark { font-family: var(--font-head); font-weight: 700; font-size: 20px; color: var(--blue); }
.logo-text { font-family: var(--font-head); font-weight: 600; font-size: 18px; color: var(--text); }

/* ── Tool grid ───────────────────────────────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tool-card {
    display: flex; align-items: center; gap: 16px;
    padding: 20px; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border);
    transition: all var(--transition); text-decoration: none; color: var(--text);
    cursor: pointer;
}
.tool-card:hover:not(.tool-card--soon) { border-color: var(--blue); background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--blue), 0 4px 24px var(--blue-glow); }
.tool-card--soon { opacity: 0.5; cursor: default; }
.tool-icon { flex-shrink: 0; width: 44px; height: 44px; background: var(--blue-glow); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.tool-icon svg { width: 22px; height: 22px; color: var(--blue); }
.tool-info { flex: 1; }
.tool-name { font-family: var(--font-head); font-size: 16px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.tool-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.tool-arrow svg { width: 18px; height: 18px; color: var(--text-dim); }

/* ── Form fields ─────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border-2);
    border-radius: var(--radius); color: var(--text); font-family: var(--font-body); font-size: 14px;
    transition: border-color var(--transition); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.field input::placeholder { color: var(--text-dim); }

/* ── Sub-page header (tool pages) ────────────────────────────────────────── */
.page-header { border-bottom: 1px solid var(--border); padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); position: sticky; top: 0; z-index: 100; }
.page-header-left { display: flex; align-items: center; gap: 20px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--text-dim); }
.breadcrumb-current { color: var(--text); font-weight: 500; }
.page-header-right { display: flex; align-items: center; gap: 8px; }

/* ── Main content area ───────────────────────────────────────────────────── */
.page-content { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ── Toolbar (search/filter bar) ─────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.toolbar-search input { padding-left: 36px; }
.toolbar-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-dim); width: 16px; height: 16px; }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn { padding: 7px 14px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-muted); cursor: pointer; transition: all var(--transition); }
.filter-btn:hover, .filter-btn.active { background: var(--blue-glow); border-color: var(--blue); color: var(--text); }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── Stats bar ───────────────────────────────────────────────────────────── */
.stats-bar { display: flex; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; min-width: 140px; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.stat-value { font-family: var(--font-head); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-value.ok     { color: var(--green); }
.stat-value.warn   { color: var(--yellow); }
.stat-value.danger { color: var(--red); }
.stat-value.blue   { color: var(--blue); }

/* ── Site table ──────────────────────────────────────────────────────────── */
.sites-table { width: 100%; border-collapse: collapse; }
.sites-table th {
    text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.sites-table td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.sites-table tr.site-row:hover td { background: var(--surface-2); }
.sites-table tr.site-row { cursor: default; }
.site-name-cell { display: flex; flex-direction: column; gap: 2px; }
.site-name { font-weight: 600; color: var(--text); font-size: 14px; }
.site-url  { font-size: 12px; color: var(--text-muted); }
.site-client { font-size: 13px; color: var(--text-muted); }
.cell-actions { display: flex; gap: 6px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-empty { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 14px; }

/* ── Status indicator ────────────────────────────────────────────────────── */
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok::before     { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.warn::before   { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-dot.danger::before { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.pending::before { background: var(--text-dim); animation: pulse 1.5s infinite; }
.status-dot.loading::before { background: var(--blue); animation: pulse 0.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Detail drawer ───────────────────────────────────────────────────────── */
.detail-row td { padding: 0; }
.detail-panel { padding: 20px 24px; background: var(--surface-2); border-top: 1px solid var(--border); display: none; }
.detail-panel.open { display: block; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-section h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 10px; }
.detail-section { margin-bottom: 16px; }

/* ── Plugin list ─────────────────────────────────────────────────────────── */
.plugin-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.plugin-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 6px; font-size: 13px; }
.plugin-item:hover { background: var(--surface-3); }
.plugin-name { flex: 1; color: var(--text); }
.plugin-name.inactive { color: var(--text-dim); }
.plugin-version { font-size: 12px; color: var(--text-muted); }
.plugin-update { font-size: 12px; color: var(--yellow); }
.plugin-inactive-badge { font-size: 11px; color: var(--text-dim); background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }

/* ── Security issues list ────────────────────────────────────────────────── */
.security-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.security-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 6px 10px; border-radius: 6px; background: rgba(239,68,68,0.07); border: 1px solid rgba(239,68,68,0.15); }
.security-item::before { content: '!'; font-weight: 700; color: var(--red); flex-shrink: 0; }
.security-ok { font-size: 13px; color: var(--green); padding: 6px 10px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 24px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); width: 100%; max-width: 480px; box-shadow: 0 16px 64px rgba(0,0,0,0.6); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--font-head); font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; max-width: 320px; box-shadow: var(--shadow); animation: slide-in 0.2s ease; }
.toast.success { border-color: rgba(34,197,94,0.4); color: #86efac; }
.toast.error   { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Version display ─────────────────────────────────────────────────────── */
.version-ok   { color: var(--green); font-weight: 500; }
.version-warn { color: var(--yellow); font-weight: 500; }

/* ── Loading row ─────────────────────────────────────────────────────────── */
.loading-cell { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .page-header, .hub-header { padding: 0 16px; }
    .page-content { padding: 20px 16px; }
    .sites-table th:nth-child(n+4), .sites-table td:nth-child(n+4) { display: none; }
}
