/* Saki Partners Data Gateway — Phase 1 theme.
 *
 * A neutral slate canvas with a teal accent — a PLACEHOLDER palette (the Saki
 * brand colours are an open assumption; see app/web/main.py). Deliberately NOT
 * the United Radiology cyan. Self-contained: no Tailwind, no CDN, no web fonts,
 * so the page renders with a clean console (the §8 smoke asserts no errors).
 */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e3e8ee;
    --text: #1f2933;
    --muted: #647889;
    --accent: #0f766e;        /* teal-700 */
    --accent-hover: #115e56;
    --accent-contrast: #ffffff;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(31, 41, 51, 0.06), 0 4px 12px rgba(31, 41, 51, 0.05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.gw-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- top bar ---- */
.gw-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.gw-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
}

.gw-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-contrast);
}
.gw-brand-mark svg { width: 20px; height: 20px; }

.gw-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.gw-brand-name { font-weight: 700; font-size: 0.98rem; }
.gw-brand-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }

.gw-user { display: inline-flex; align-items: center; gap: 0.85rem; }
.gw-user-email { font-size: 0.88rem; color: var(--muted); }
.gw-logout-form { margin: 0; }

/* ---- main + cards ---- */
.gw-main {
    flex: 1;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.gw-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.gw-card-narrow { max-width: 440px; margin: 1.5rem auto; }
.gw-card-title { margin: 0 0 0.5rem; font-size: 1.4rem; font-weight: 700; }
.gw-muted { color: var(--muted); margin: 0 0 1.25rem; }

/* ---- forms ---- */
.gw-form { display: flex; flex-direction: column; gap: 1rem; }
.gw-field { display: flex; flex-direction: column; gap: 0.35rem; }
.gw-field-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }

.gw-input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    font-size: 1rem;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.gw-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

/* ---- buttons ---- */
.gw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.gw-btn-primary { background: var(--accent); color: var(--accent-contrast); }
.gw-btn-primary:hover { background: var(--accent-hover); }
.gw-btn-ghost {
    background: transparent;
    color: var(--accent);
    border-color: var(--border);
}
.gw-btn-ghost:hover { border-color: var(--accent); }

/* ---- empty state ---- */
.gw-empty {
    margin-top: 1.5rem;
    padding: 2.5rem 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
}
.gw-empty-mark {
    display: inline-flex;
    width: 44px;
    height: 44px;
    color: var(--accent);
}
.gw-empty-mark svg { width: 44px; height: 44px; }
.gw-empty-text { margin: 0; font-size: 0.95rem; }

/* ---- connections list ---- */
.gw-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.gw-head-actions { display: flex; gap: 0.5rem; align-items: center; }
.gw-conn-list { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.gw-conn {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}
.gw-conn:first-child { border-top: none; }
.gw-conn-main { display: flex; align-items: center; gap: 0.65rem; flex: 1 1 14rem; }
.gw-conn-name { font-weight: 600; }
.gw-conn-meta { color: var(--muted); font-size: 0.82rem; display: flex; gap: 0.4rem; flex: 1 1 12rem; }
.gw-conn-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.gw-inline-form { margin: 0; }

.gw-badge {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid transparent;
}
.gw-badge-connected { background: #e6f5f1; color: #0f766e; border-color: #b8e3d8; }
.gw-badge-reconnect_required { background: #fdf1e3; color: #b45309; border-color: #f3d9b0; }
.gw-badge-disconnected { background: #eef1f4; color: #647889; border-color: #dce2e8; }

.gw-btn-danger { background: transparent; color: #b42318; border-color: var(--border); }
.gw-btn-danger:hover { border-color: #b42318; background: #fdf0ee; }

/* ---- footer ---- */
.gw-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.gw-footer-sep { opacity: 0.5; }

/* ---- top nav ---- */
.gw-nav { display: inline-flex; gap: 0.25rem; margin-right: 0.75rem; }
.gw-nav-link {
    text-decoration: none; color: var(--muted); font-size: 0.9rem; font-weight: 600;
    padding: 0.35rem 0.6rem; border-radius: 8px;
}
.gw-nav-link:hover { color: var(--text); background: var(--bg); }

/* ---- dashboards ---- */
.gw-dash { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; align-items: start; }
.gw-dash-nav { position: sticky; top: 1rem; }
.gw-dash-heading {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--muted); margin: 1rem 0 0.5rem;
}
.gw-tool-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.gw-tool-link {
    display: block; text-decoration: none; color: var(--text); font-size: 0.92rem;
    padding: 0.45rem 0.65rem; border-radius: 8px;
}
.gw-tool-link:hover { background: var(--surface); }
.gw-tool-link.is-active { background: var(--accent); color: var(--accent-contrast); }
.gw-saved-row { display: flex; align-items: center; gap: 0.25rem; }
.gw-saved-row .gw-tool-link { flex: 1; }
.gw-btn-x {
    border: none; background: transparent; color: var(--muted); cursor: pointer;
    font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.4rem; border-radius: 6px;
}
.gw-btn-x:hover { color: #b42318; background: #fdf0ee; }

.gw-dash-main { min-width: 0; }
.gw-org-form { display: flex; flex-direction: column; gap: 0.3rem; min-width: 200px; }

.gw-table { width: 100%; border-collapse: collapse; margin-top: 1.25rem; font-size: 0.92rem; }
.gw-table th, .gw-table td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
.gw-table th { color: var(--muted); font-weight: 600; text-transform: capitalize; font-size: 0.8rem; }
.gw-table td.gw-num, .gw-table th.gw-num { text-align: right; font-variant-numeric: tabular-nums; }
.gw-num { text-align: right; font-variant-numeric: tabular-nums; }

.gw-view-actions { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.gw-save-form { display: flex; gap: 0.5rem; align-items: center; }
.gw-save-form .gw-input { max-width: 280px; }
.gw-export { display: flex; gap: 0.5rem; }

@media (max-width: 720px) { .gw-dash { grid-template-columns: 1fr; } }

/* ---- AI pane ---- */
.gw-ai-output {
    margin: 1.25rem 0; min-height: 200px; max-height: 55vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 0.6rem;
}
.gw-ai-msg { padding: 0.6rem 0.85rem; border-radius: 10px; font-size: 0.93rem; max-width: 90%; white-space: pre-wrap; }
.gw-ai-you { align-self: flex-end; background: var(--accent); color: var(--accent-contrast); }
.gw-ai-bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); }
.gw-ai-tool { align-self: flex-start; font-size: 0.78rem; color: var(--muted); font-style: italic; padding: 0.1rem 0.4rem; }
.gw-ai-banner { align-self: center; background: #fdf1e3; color: #b45309; border: 1px solid #f3d9b0; font-size: 0.85rem; }
.gw-ai-error { align-self: flex-start; background: #fdf0ee; color: #b42318; border: 1px solid #f3c6c0; }
.gw-ai-form { display: flex; gap: 0.5rem; }
.gw-ai-form .gw-input { flex: 1; }
