/* public/assets/app.css */

:root {
    --bg: #0a0b0a;
    --surface: #17191a;
    --surface-raised: #202223;
    --border: #383b3a;
    --border-soft: #2a2c2b;
    --text: #dedfd9;
    --text-muted: #9a9c96;
    --text-dim: #6b6d67;
    --accent-orange: #ff5a1f;
    --accent-orange-dim: #c2450f;
    --lume: #dce67c;
    --lume-dim: #a3ac52;
    --status-up: #6fae66;
    --status-down: #c85c5c;
    --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Roboto Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
}

a { color: var(--accent-orange); }

h1 { font-family: var(--font-heading); font-size: 1.5rem; margin: 0 0 6px; letter-spacing: 0.01em; }
h2 {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    margin: 40px 0 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}
h3 { font-size: 0.95rem; margin: 24px 0 10px; color: var(--text); }

/* ---------- shared header (rendered by lib/layout.php) ---------- */

.topbar {
    border-bottom: 1px solid var(--border);
}
/* Row 1: brand + tenant (left), user/logout (right). Row 2 (.topbar-nav,
   below) shares the same max-width/padding so its content aligns exactly
   with .shell's -- see the deploying-xeoradar-era header alignment fix. */
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 14px 20px;
    flex-wrap: wrap;
}
.wordmark {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.12em;
    font-size: 14px;
    white-space: nowrap;
}
.wordmark span { color: var(--accent-orange); }
.topbar-divider { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }
.tenant { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.tenant-logo { height: 20px; width: auto; max-width: 120px; object-fit: contain; }
.topbar-nav {
    display: flex;
    gap: 16px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px 14px;
    flex-wrap: wrap;
}
.topbar-nav a { font-size: 13.5px; color: var(--text-muted); text-decoration: none; }
.topbar-nav a:hover, .topbar-nav a.active { color: var(--accent-orange); }
.topbar-inner .user {
    margin-left: auto;
    font-size: 12.5px;
    color: var(--text-dim);
    white-space: nowrap;
}
.topbar-inner .user a { color: var(--text-dim); }
.topbar-inner .user a:hover { color: var(--accent-orange); }

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 20px 0 24px; flex-wrap: wrap; }
.tab-bar a { padding: 10px 16px; font-size: 13.5px; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-bar a:hover { color: var(--text); }
.tab-bar a.active { color: var(--accent-orange); border-bottom-color: var(--accent-orange); }

/* ---------- page shell ---------- */

.shell { max-width: 1000px; margin: 0 auto; padding: 32px 20px 80px; }

.auth-card {
    max-width: 380px;
    margin: 60px auto 0;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 32px;
}

/* ---------- forms ---------- */

label { display: block; margin-top: 16px; font-weight: 600; font-size: 13.5px; color: var(--text-muted); }
input, select {
    width: 100%;
    padding: 9px 10px;
    margin-top: 5px;
    box-sizing: border-box;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent-orange); outline-offset: 1px; }
button {
    margin-top: 20px;
    padding: 9px 18px;
    cursor: pointer;
    background: var(--accent-orange);
    color: var(--bg);
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
}
button:hover { background: var(--accent-orange-dim); }
form.inline { display: inline; }
form.inline button { margin-top: 0; background: var(--surface-raised); color: var(--text-muted); border: 1px solid var(--border); }
form.inline button:hover { background: var(--border-soft); color: var(--text); }
.logo-preview { margin: 8px 0; }
.logo-preview img { max-height: 40px; }
.add-form { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.add-form input { flex: 1; margin-top: 0; min-width: 160px; }
.add-form input[name=name] { flex: 0 0 200px; }
.add-form button { margin-top: 0; }

/* ---------- messages ---------- */

.msg { padding: 10px 14px; border-radius: 4px; margin: 14px 0; font-size: 14px; }
.msg.ok { background: rgba(111, 174, 102, 0.12); color: var(--status-up); border: 1px solid rgba(111, 174, 102, 0.3); }
.msg.err { background: rgba(200, 92, 92, 0.12); color: var(--status-down); border: 1px solid rgba(200, 92, 92, 0.3); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: top; }
th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; }
td { color: var(--text-muted); }
tr.own-site td { color: var(--text); font-weight: 600; }
tr.own-site { background: rgba(255, 90, 31, 0.05); }
tr.inactive td { opacity: 0.5; }

/* ---------- cards ---------- */

.card { border: 1px solid var(--border-soft); background: var(--surface); border-radius: 6px; padding: 16px 18px; margin-top: 12px; }
.rec-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.rec-item:last-child { border-bottom: none; }
.rec-item-text strong { display: block; font-size: 14px; color: var(--text); }
.rec-item-text p { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }
.card.own-site { border-color: rgba(255, 90, 31, 0.3); }
.aeo-history { margin-top: 10px; }
.aeo-history summary { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.aeo-history summary:hover { color: var(--text); }
.aeo-history[open] summary { color: var(--accent-orange); margin-bottom: 6px; }
.aeo-provider { margin-bottom: 20px; }
.aeo-provider:last-child { margin-bottom: 0; }
.aeo-provider-name { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.aeo-provider-icon { width: 16px; height: 16px; border-radius: 3px; }
.aeo-sources { margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.aeo-sources-list { list-style: none; margin: 2px 0 0; padding-left: 14px; }
.aeo-sources-list li { margin-top: 2px; line-height: 1.4; position: relative; }
.aeo-sources-list li::before { content: "\2013"; position: absolute; left: -14px; }
.aeo-sources a { color: var(--text-muted); }
.muted { color: var(--text-dim); font-size: 13px; }
.app-footer { text-align: center; padding: 20px 0; margin-top: 20px; border-top: 1px solid var(--border-soft); color: var(--text-dim); font-size: 12px; }
.diff { background: var(--surface-raised); padding: 10px 12px; border-radius: 4px; margin-top: 10px; font-size: 13px; color: var(--text-muted); }
ul.tight { margin: 4px 0; padding-left: 20px; }
ul.tight li { color: var(--text-muted); font-size: 13.5px; }
.page-changes { margin-top: 10px; }
.page-changes strong { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.page-changes ul.tight { margin-top: 4px; }
.page-changes a { word-break: break-all; }

/* ---------- badges ---------- */

.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11.5px; margin-left: 8px; font-family: var(--font-mono); background: var(--surface-raised); color: var(--text-dim); }
.badge.changed { background: rgba(255, 90, 31, 0.12); color: var(--accent-orange); }
.badge.up { background: rgba(111, 174, 102, 0.12); color: var(--status-up); }
.badge.down { background: rgba(200, 92, 92, 0.12); color: var(--status-down); }
.badge.flat { background: var(--surface-raised); color: var(--text-dim); }

/* ---------- score ring (lib/layout.php render_score_ring()) ---------- */

.score-ring { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; margin-left: 12px; vertical-align: middle; }
.score-ring svg text { font-family: var(--font-mono); font-weight: 600; fill: var(--text); }
.score-ring .ring-num { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- trend charts (lib/layout.php render_trend_chart()) ---------- */

.trend-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); margin: 40px 0 6px; padding-bottom: 8px; flex-wrap: wrap; gap: 12px; }
.trend-header h2 { margin: 0; border: none; padding: 0; }
.trend-header-controls { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.trend-range-picker { display: flex; gap: 4px; }
.trend-range-picker a { padding: 4px 10px; font-size: 12px; color: var(--text-muted); text-decoration: none; border-radius: 4px; }
.trend-range-picker a:hover { color: var(--text); }
.trend-range-picker a.active { color: var(--accent-orange); background: rgba(255, 90, 31, 0.1); }
.trend-charts { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.trend-chart-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 6px; padding: 12px; }
.trend-chart-title { font-size: 12.5px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.trend-gridline { stroke: var(--border-soft); stroke-width: 1; }
.trend-axis-label { fill: var(--text-dim); font-family: var(--font-mono); font-size: 11px; }
.trend-legend { display: flex; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.trend-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.trend-swatch { width: 10px; height: 2px; display: inline-block; }
.trend-toggle { display: flex; align-items: center; gap: 8px; margin-top: 0; font-weight: 400; font-size: 14px; line-height: 20px; color: var(--text-muted); cursor: pointer; width: fit-content; }
/* Custom-drawn checkbox instead of the native control -- native checkbox
   boxes render with inconsistent intrinsic sizing/baseline across
   browsers and OSes, which threw off alignment with .trend-range-picker
   next to it even though both were flex-centered the same way. */
.trend-toggle input {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    cursor: pointer;
    position: relative;
}
.trend-toggle input:checked {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
}
.trend-toggle input:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid var(--bg);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
#trendCharts.hide-competitors .trend-line.competitor,
#trendCharts.hide-competitors .trend-marker.competitor,
#trendCharts.hide-competitors .trend-legend-item.competitor { display: none; }
.trend-hit { cursor: pointer; }
.trend-tooltip { position: fixed; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 4px; padding: 4px 8px; font-size: 11px; font-family: var(--font-mono); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); pointer-events: none; z-index: 50; }

.section-heading { display: flex; align-items: center; gap: 4px; }

/* ---------- dashboard summary strip + tooltips ---------- */

.summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    padding: 20px 0;
    margin-top: 8px;
    border-bottom: 1px solid var(--border);
}
.summary-strip .score-ring { margin-left: 0; }

.metric-tooltip { position: relative; display: inline-flex; }
.metric-tooltip:focus { outline: none; }
.section-heading .metric-tooltip { font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text-muted); cursor: help; }
.metric-tooltip .tooltip-text {
    font-family: var(--font-body);
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    width: 220px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    padding: 10px 12px;
    border-radius: 4px;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 20;
}
.metric-tooltip:hover .tooltip-text,
.metric-tooltip:focus-within .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.chat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 24px; }
.chat-card h2 { margin-top: 0; padding-bottom: 0; border-bottom: none; text-transform: none; letter-spacing: normal; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.chat-messages { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.chat-message { padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5; max-width: 85%; }
.chat-message.chat-assistant { background: var(--surface-raised); color: var(--text); align-self: flex-start; }
.chat-message.chat-user { background: var(--accent-orange-dim); color: var(--text); align-self: flex-end; }
.chat-message.chat-thinking { opacity: 0.6; font-style: italic; }
.chat-message-time { font-size: 10px; opacity: 0.5; margin-top: 4px; }
.chat-message.chat-user .chat-message-time { text-align: right; }
.chat-form { display: flex; gap: 8px; }
.chat-form input[type="text"] { flex: 1; background: var(--surface-raised); border: 1px solid var(--border-soft); border-radius: 6px; padding: 10px 12px; color: var(--text); font-size: 14px; }
.chat-form button { background: var(--accent-orange); color: var(--bg); border: none; border-radius: 6px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
.chat-form button:hover { background: #ff7420; }
.chat-error { color: var(--status-down); font-size: 13px; margin-top: 8px; }
