/*
 * Settings UI — shared styles for collapsible admin-style panels.
 * ─────────────────────────────────────────────────────────────────────────
 * Admin, Settings, and Brand & Assets each present the same "collapsible
 * card of form fields" pattern (settings-section/header/body), the same
 * status key/value grid, badges, callouts, and form field basics. This file
 * is the single source of truth for that shared chrome so those three pages
 * (and the Site Appearance panel in brand-panel.js) don't each hand-roll a
 * near-identical copy. Pages still own their own page-specific layout CSS.
 * ───────────────────────────────────────────────────────────────────────── */

/* ---- Collapsible sections ---- */
.settings-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); margin-bottom: 1rem; box-shadow: var(--shadow-card); overflow: hidden; }
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1rem 1.25rem; cursor: pointer; user-select: none; transition: background 0.15s; width: 100%; background: none; border: none; text-align: left; color: inherit; font: inherit; }
.settings-header:hover { background: color-mix(in srgb, var(--accent-violet) 3%, transparent); }
.settings-header h2, .settings-header h3 { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 0.5rem; }
.chevron { flex: none; font-size: var(--text-xs); color: var(--text-muted); transition: transform 0.2s ease; }
.settings-body { padding: 0 1.25rem 1.25rem; display: none; }
.settings-body.open { display: block; }
.chevron.open { transform: rotate(0deg); }
.chevron:not(.open) { transform: rotate(-90deg); }
h3.group-title { font-size: var(--text-base); font-weight: 700; color: var(--text-primary); margin: 1.25rem 0 0.6rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- Header main slot: title + a short glanceable status line/badge, so a
   COLLAPSED card still tells you what it's set to (Google-Admin-console
   style summary cards) without opening it. ---- */
.settings-header-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.settings-header-main h2 { flex-wrap: wrap; }
.card-status { font-size: var(--text-xs); font-weight: 500; color: var(--text-muted); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-status .badge { font-size: var(--text-2xs); padding: 0.1rem 0.45rem; }

/* ---- Settings grid: short summary cards in a responsive grid, instead of
   one long vertical stack. Mirrors the app-shell's own container-query
   breakpoints (theme.css) — 1 col mobile, 2 col tablet, 3 col desktop. An
   expanded card spans the full row so its form has room to breathe. ---- */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.settings-grid .settings-section { margin-bottom: 0; }
.settings-grid .settings-section.is-expanded { grid-column: 1 / -1; }
@media (min-width: 768px) { .settings-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .settings-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---- Segmented control (e.g. switching between two connection methods
   inside one card) ---- */
.seg-control { display: inline-flex; padding: 0.2rem; gap: 0.2rem; background: var(--input-bg); border: 1px solid var(--border-subtle); border-radius: 10px; margin-bottom: 1rem; }
.seg-btn { flex: 1; background: none; border: none; color: var(--text-secondary); font: inherit; font-size: var(--text-sm); font-weight: 600; padding: 0.5rem 0.8rem; border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.seg-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.seg-pane { display: none; }
.seg-pane.active { display: block; }

/* ---- Form basics ---- */
.field-group { margin-bottom: 1rem; }
.field-group:last-child { margin-bottom: 0; }
.field-group label, .field-label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: var(--text-base); color: var(--text-primary); }
.help-text { color: var(--text-muted); font-size: var(--text-xs); margin-top: 0.3rem; line-height: 1.4; }
.field-description { color: var(--text-secondary); font-size: var(--text-sm); margin-bottom: 0.6rem; }
/* Checkbox setting row. `.field-group label` above forces display:block and
   bold, which would stack the box above its text, so this overrides both to
   put the control beside its label. The whole row is a <label>, so the text is
   a click target and the pair is announced together by a screen reader. */
.checkbox-row {
    display: flex; align-items: flex-start; gap: 0.55rem; cursor: pointer;
    font-weight: 400; font-size: var(--text-base); color: var(--text-primary);
    margin-bottom: 0; padding: 0.5rem 0.65rem;
    background: var(--input-bg); border: 1px solid var(--border-subtle); border-radius: 8px;
    transition: border-color 0.2s;
}
.checkbox-row:hover { border-color: var(--accent-violet); }
.checkbox-row input[type="checkbox"] {
    width: 16px; height: 16px; margin: 0; flex: 0 0 auto;
    accent-color: var(--accent-violet); cursor: pointer;
}
.checkbox-row input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent-violet); outline-offset: 2px;
}
.checkbox-row span { line-height: 1.35; }
.text-input, input[type="text"].text-input, input[type="password"].text-input, input[type="number"].text-input, select.text-input, textarea.text-input {
    width: 100%; background: var(--input-bg); border: 1px solid var(--border-subtle); border-radius: 8px;
    color: var(--text-primary); padding: 0.65rem 0.75rem; font-size: var(--text-base); font-family: var(--font-sans); transition: border-color 0.2s;
}
.text-input:focus { outline: none; border-color: var(--accent-violet); box-shadow: var(--focus-ring); }

/* ---- Buttons ---- */
.btn-primary { background: var(--gradient-main); color: var(--on-brand); border: none; padding: 0.65rem 1.35rem; border-radius: var(--radius-md); font-size: var(--text-base); font-weight: 600; cursor: pointer; }
.btn-primary:hover { opacity: 0.92; }
.btn-sec { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-primary); padding: 0.65rem 1.2rem; border-radius: var(--radius-md); font-weight: 600; font-size: var(--text-base); cursor: pointer; }
.btn-sec:hover { border-color: var(--accent-violet); }
.btn-danger { background: transparent; border: 1px solid var(--accent-red); color: var(--accent-red); padding: 0.65rem 1.2rem; border-radius: var(--radius-md); font-weight: 600; font-size: var(--text-base); cursor: pointer; }
.btn-danger:hover { background: color-mix(in srgb, var(--accent-red) 8%, transparent); color: var(--accent-red); }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---- Status key/value grid ---- */
.status-grid { border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden; margin-top: 0.5rem; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border-subtle); }
.status-row:last-child { border-bottom: none; }
.status-label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: 500; }
.status-value { font-size: var(--text-sm); color: var(--text-primary); font-weight: 600; text-align: right; word-break: break-all; }
.status-value.mono { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: var(--text-xs); font-weight: 700; border: 1px solid transparent; }
.badge-green { background: color-mix(in srgb, var(--accent-green) 10%, transparent); color: #059669; }
.badge-violet { background: color-mix(in srgb, var(--accent-violet) 10%, transparent); color: var(--accent-violet); }
.badge-orange { background: color-mix(in srgb, var(--accent-amber) 10%, transparent); color: #d97706; }
.badge-amber { background: color-mix(in srgb, var(--accent-amber) 12%, transparent); color: #b45309; }
.badge-red { background: color-mix(in srgb, var(--accent-red) 10%, transparent); color: #dc2626; }
.badge-gray { background: rgba(107,114,128,0.12); color: #6b7280; }

/* ---- Callouts ---- */
.callout { border: 1px solid var(--border-subtle); border-left: 3px solid var(--accent-violet); border-radius: 8px; padding: 0.75rem 0.9rem; font-size: var(--text-sm); color: var(--text-secondary); background: var(--input-bg); margin: 0.75rem 0; }
.callout.warn { border-left-color: var(--accent-amber, #d97706); }
.callout.ok { border-left-color: var(--accent-green); }
.callout.err { border-left-color: var(--accent-red); }

/* ---- Permission chip list (GitHub connection) ---- */
.perm-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; padding: 0; }
.perm-list li { font-size: var(--text-xs); font-weight: 600; background: color-mix(in srgb, var(--accent-violet) 8%, transparent); color: var(--accent-violet); border: 1px solid color-mix(in srgb, var(--accent-violet) 20%, transparent); border-radius: 8px; padding: 0.3rem 0.6rem; font-family: var(--font-mono); }

/* ---- Site Appearance (brand) panel — shared by every page that embeds it
   via brand-panel.js. See frontend/brand-panel.js for the JS behavior. ---- */
.brand-presets { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.5rem; }
.brand-preset { display: inline-flex; align-items: center; gap: 0.5rem; border: 1px solid var(--border-subtle); background: var(--bg-secondary); border-radius: var(--radius-full, 999px); padding: 0.4rem 0.8rem 0.4rem 0.45rem; cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); transition: border-color .15s, color .15s, box-shadow .15s; }
.brand-preset:hover { color: var(--text-primary); border-color: var(--accent-violet); }
.brand-preset.active { color: var(--text-primary); border-color: var(--accent-violet); box-shadow: var(--focus-ring); }
.brand-preset .dots { display: inline-flex; }
.brand-preset .dots i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid var(--bg-secondary); margin-left: -6px; }
.brand-preset .dots i:first-child { margin-left: 0; }
.brand-colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 0.75rem 0 0.5rem; }
.brand-color label { font-size: var(--text-xs); font-weight: 600; margin-bottom: 0.35rem; }
.brand-color .picker { display: flex; align-items: center; gap: 0.5rem; }
.brand-color input[type="color"] { width: 42px; height: 38px; padding: 0; border: 1px solid var(--border-subtle); border-radius: 8px; background: none; cursor: pointer; }
.brand-color input[type="text"] { flex: 1; min-width: 0; background: var(--input-bg); border: 1px solid var(--border-subtle); border-radius: 8px; color: var(--text-primary); padding: 0.5rem 0.6rem; font-family: var(--font-mono); font-size: var(--text-sm); text-transform: lowercase; }
.brand-preview { margin-top: 1rem; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg, 16px); overflow: hidden; background: var(--bg-secondary); }
.brand-preview .bp-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; background: var(--gradient-main); color: var(--on-brand, #fff); font-weight: 800; letter-spacing: -0.02em; }
.brand-preview .bp-glyph { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,0.2); display: grid; place-items: center; font-size: var(--text-base); }
.brand-preview .bp-body { padding: 1rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.bp-btn { border: none; border-radius: var(--radius-sm, 8px); padding: 0.6rem 1.1rem; font-size: var(--text-sm); font-weight: 700; cursor: default; color: var(--on-brand, #fff); }
.bp-btn.main { background: var(--gradient-main); }
.bp-btn.spark { background: var(--gradient-spark); box-shadow: 0 6px 18px var(--border-glow); }
.bp-btn.ghost { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-primary); }
.bp-badge { font-size: var(--text-2xs); font-weight: 700; border-radius: 999px; padding: 0.2rem 0.6rem; color: var(--accent-violet); background: color-mix(in srgb, var(--accent-violet) 10%, transparent); border: 1px solid var(--border-glow); }
.brand-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.brand-note { font-size: var(--text-xs); color: var(--text-muted); margin-top: 0.6rem; line-height: 1.5; }

/* ---- Tenant branding asset cards (icon/logo/banner uploads) ---- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.asset-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 1rem; }
.asset-card h4 { font-size: var(--text-sm); font-weight: 700; margin-bottom: 0.5rem; }
.asset-preview { width: 100%; height: 90px; border: 1px dashed var(--border-subtle); border-radius: 8px; display: grid; place-items: center; overflow: hidden; margin-bottom: 0.6rem; background: var(--input-bg); color: var(--text-muted); font-size: var(--text-xs); }
.asset-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---- Theme color-pair rows (contrast-checked) ---- */
.pair-row { display: grid; grid-template-columns: 1.2fr auto 1fr auto 1fr 1.2fr auto; gap: 0.5rem; align-items: end; margin-bottom: 0.6rem; }
.pair-row .tiny-label { font-size: var(--text-2xs); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.2rem; display: block; }
.icon-btn { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-muted); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; font-size: var(--text-md); }
.icon-btn:hover { border-color: var(--accent-red); color: var(--accent-red); }
@media (max-width: 768px) { .pair-row { grid-template-columns: 1fr 1fr; } }
.contrast-report { margin-top: 0.75rem; }
.contrast-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border-subtle); border-radius: 8px; margin-bottom: 0.4rem; font-size: var(--text-sm); }
.contrast-item .ratio { font-family: var(--font-mono); font-weight: 700; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
