/* Admin Portal — V2 design system */

:root {
    --c-blue: #0052CC;
    --c-blue-dark: #003D99;
    --c-blue-bg: #EFF6FF;
    --c-blue-12: rgba(0,82,204,0.12);
    --c-blue-18: rgba(0,82,204,0.18);
    --c-charcoal: #1A1A1A;
    --c-muted: #6B7280;
    --c-border: #E5E7EB;
    --c-light-gray: #F5F5F5;
    --c-row-alt: #FAFAFA;
    --c-white: #FFFFFF;
    --c-green: #059669;
    --c-green-bg: #ECFDF5;
    --c-amber: #D97706;
    --c-amber-bg: #FFFBEB;
    --c-red: #DC2626;
    --c-red-bg: #FEF2F2;
    --c-red-soft: #FECACA;
    --c-slate: #475569;
    --c-slate-bg: #F1F5F9;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--c-light-gray);
    color: var(--c-charcoal);
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.admin-header {
    background: var(--c-white);
    border-bottom: 1px solid var(--c-border);
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.admin-header-inner {
    max-width: 1500px; margin: 0 auto; height: 100%;
    padding: 0 28px;
    display: flex; align-items: stretch; gap: 28px;
}
.admin-header .logo {
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none; flex-shrink: 0;
}
.admin-header .logo .logo-pill {
    height: 56px; background: var(--c-blue); border-radius: 8px;
    padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
}
.admin-header .logo img { height: 40px; width: auto; display: block; }
.admin-header .logo:hover { text-decoration: none; }
.admin-header .admin-nav {
    flex: 1; display: flex; align-items: stretch; gap: 2px;
    margin: 0; overflow-x: auto;
}
.admin-header .admin-nav a {
    display: inline-flex; align-items: center;
    padding: 0 12px;
    font-size: 13px; font-weight: 500;
    color: var(--c-charcoal);
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    text-decoration: none; white-space: nowrap;
}
.admin-header .admin-nav a:hover { color: var(--c-blue); text-decoration: none; }
.admin-header .admin-nav a.active { color: var(--c-blue); font-weight: 700; border-bottom-color: var(--c-blue); }

.admin-header .admin-user {
    display: flex; align-items: center; gap: 10px;
    padding-left: 20px;
}
.admin-header .admin-user .avatar {
    width: 32px; height: 32px; border-radius: 16px;
    background: var(--c-blue); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.admin-header .admin-user .name { font-size: 13px; color: var(--c-charcoal); }
.admin-header .logout-form { margin: 0; }
.admin-header .logout-btn {
    background: transparent; color: var(--c-muted);
    border: none; padding: 6px 8px;
    font-size: 13px; font-family: inherit; cursor: pointer;
}
.admin-header .logout-btn:hover { color: var(--c-red); }

/* ── Main canvas ─────────────────────────────────────────────────────────── */
.admin-main { min-height: calc(100vh - 64px); }
.admin-container { max-width: 1500px; margin: 0 auto; padding: 0; }

/* Layouts: with sidebar / without */
.with-sidebar { display: flex; min-height: calc(100vh - 64px); }
.with-sidebar .side {
    width: 256px; flex-shrink: 0; background: var(--c-white);
    border-right: 1px solid var(--c-border);
    display: flex; flex-direction: column; overflow: hidden;
}
.with-sidebar .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 28px 14px;
    flex-shrink: 0;
}
.page-header h1 {
    margin: 0; font-size: 20px; font-weight: 800;
    color: var(--c-charcoal); letter-spacing: -0.4px;
}
.page-header .title-wrap { display: flex; align-items: baseline; gap: 8px; }
.page-header .count { font-size: 14px; color: var(--c-muted); }
.page-header .subtitle { font-size: 13px; color: var(--c-muted); margin-top: 2px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    height: 36px; padding: 0 14px;
    border-radius: 8px; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit; border: none;
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--c-blue); color: #fff; box-shadow: 0 2px 6px rgba(0,82,204,0.35); }
.btn-primary:hover { background: var(--c-blue-dark); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--c-white); color: var(--c-charcoal); border: 1px solid var(--c-border); }
.btn-secondary:hover { background: var(--c-light-gray); text-decoration: none; color: var(--c-charcoal); }
.btn-danger { background: var(--c-white); color: var(--c-red); border: 1px solid var(--c-red); }
.btn-danger:hover { background: var(--c-red-bg); text-decoration: none; color: var(--c-red); }
.btn-destructive { background: var(--c-red-bg); color: var(--c-red); border: 1px solid var(--c-red-soft); }
.btn-destructive:hover { background: #FECACA; text-decoration: none; color: var(--c-red); }
.btn-ghost { background: transparent; color: var(--c-blue); padding: 0 10px; height: 30px; font-size: 12px; }
.btn-ghost:hover { background: var(--c-blue-bg); color: var(--c-blue); text-decoration: none; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { background: #CBD5E1; color: #fff; cursor: not-allowed; box-shadow: none; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.a-card {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
}
.a-card + .a-card { margin-top: 14px; }
.a-card .a-card-label {
    font-size: 10px; font-weight: 700; color: var(--c-muted);
    letter-spacing: 0.6px; text-transform: uppercase;
    margin-bottom: 6px;
}
.a-card .a-card-value {
    font-size: 32px; font-weight: 900; color: var(--c-charcoal);
    letter-spacing: -0.8px; line-height: 1;
}
.a-card .a-card-value.accent { color: var(--c-blue); }
.a-card .a-card-sub { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.a-card .a-card-title {
    font-size: 13px; font-weight: 700; color: var(--c-charcoal);
    margin-bottom: 12px;
}
.a-card .row-divider { height: 1px; background: var(--c-border); margin: 12px 0; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    overflow: hidden;
    margin: 0 28px 18px;
}
table.data {
    width: 100%;
    border-collapse: collapse;
}
table.data thead { background: #F9FAFB; }
table.data th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px; font-weight: 700;
    color: var(--c-muted);
    letter-spacing: 0.5px; text-transform: uppercase;
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
table.data td {
    padding: 11px 14px;
    font-size: 13px;
    color: var(--c-charcoal);
    vertical-align: middle;
    border-bottom: 1px solid #F5F5F5;
}
table.data tbody tr:nth-child(even) { background: var(--c-row-alt); }
table.data tbody tr:hover { background: var(--c-blue-bg); cursor: pointer; }
table.data td.muted { color: var(--c-muted); }
table.data td.bold { font-weight: 600; }
table.data td.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace; font-size: 12px; }
table.data tr:last-child td { border-bottom: 0; }
table.data .row-actions { display: flex; gap: 6px; align-items: center; }
table.data .row-actions form { display: inline; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
    display: flex; background: var(--c-white);
    border: 1px solid var(--c-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    padding: 0 28px;
    margin: 0 28px;
}
.tabs a {
    padding: 11px 16px;
    font-size: 13px;
    color: var(--c-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--c-blue); }
.tabs a.active { color: var(--c-blue); font-weight: 700; border-bottom-color: var(--c-blue); }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    font-size: 11px; font-weight: 600;
    padding: 3px 9px; border-radius: 20px;
    white-space: nowrap; letter-spacing: 0.1px;
    background: #F3F4F6; color: var(--c-muted);
}
.badge-gray { background: #F3F4F6; color: var(--c-muted); }
.badge-blue { background: var(--c-blue-bg); color: var(--c-blue); }
.badge-green { background: var(--c-green-bg); color: var(--c-green); }
.badge-amber { background: var(--c-amber-bg); color: var(--c-amber); }
.badge-red { background: var(--c-red-bg); color: var(--c-red); }
.badge-slate { background: var(--c-slate-bg); color: var(--c-slate); }

/* ── Filter sidebar ─────────────────────────────────────────────────────── */
.filter-sec {
    padding: 14px 16px;
    border-bottom: 1px solid var(--c-border);
}
.filter-sec .filter-title {
    font-size: 11px; font-weight: 700; color: var(--c-muted);
    letter-spacing: 0.5px; text-transform: uppercase;
    margin-bottom: 10px;
}
.filter-sec .check-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0;
}
.filter-sec .check-row input[type=checkbox] { accent-color: var(--c-blue); margin-right: 8px; }
.filter-sec .check-row label {
    display: inline-flex; align-items: center;
    font-size: 13px; color: var(--c-charcoal); cursor: pointer;
}
.filter-sec .check-row .count {
    font-size: 11px; color: var(--c-muted);
    background: var(--c-light-gray); padding: 1px 7px; border-radius: 10px;
}
.filter-sec .search {
    height: 36px;
    background: var(--c-light-gray);
    border-radius: 8px;
    display: flex; align-items: center;
    padding: 0 12px; gap: 8px;
}
.filter-sec .search input {
    background: transparent; border: none; outline: none;
    flex: 1; font-size: 13px; font-family: inherit;
}
.filter-sec .search svg { stroke: var(--c-muted); flex-shrink: 0; }
.filter-actions {
    margin-top: auto; padding: 14px 16px; display: flex; gap: 8px;
    border-top: 1px solid var(--c-border);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 14px; max-width: 720px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label {
    font-size: 11px; font-weight: 700; color: var(--c-muted);
    letter-spacing: 0.4px; text-transform: uppercase;
}
.form-row input[type=text],
.form-row input[type=email],
.form-row input[type=tel],
.form-row input[type=password],
.form-row input[type=number],
.form-row input[type=date],
.form-row input[type=datetime-local],
.form-row input[type=url],
.form-row input:not([type]),
.form-row select,
.form-row textarea {
    height: 38px;
    background: var(--c-white);
    border: 1.5px solid var(--c-border);
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13px; color: var(--c-charcoal);
    font-family: inherit;
}
.form-row textarea { height: auto; min-height: 80px; padding: 10px; line-height: 1.5; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: var(--c-blue);
    box-shadow: 0 0 0 3px var(--c-blue-18);
}
.form-row .hint { font-size: 11px; color: var(--c-muted); }
.form-row .err { font-size: 11px; color: var(--c-red); min-height: 14px; }
.form-row-checkbox { flex-direction: row; align-items: center; gap: 8px; }
.form-row-checkbox label { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--c-charcoal); }

.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Checkbox / radio option lists (e.g. people-experience, marketing-source) */
.p-check-list, .p-radio-list {
    display: flex; flex-wrap: wrap; gap: 8px 18px;
    margin-top: 2px;
}
.p-check-item, .p-radio-item {
    display: inline-flex; align-items: center; gap: 6px;
    text-transform: none; letter-spacing: 0; font-weight: 500;
    color: var(--c-charcoal); font-size: 13px;
    cursor: pointer;
}
.p-check-item input, .p-radio-item input { margin: 0; }
@media (max-width: 768px) { .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; } }

.form-summary {
    background: var(--c-red-bg); color: var(--c-red);
    border: 1px solid var(--c-red);
    border-radius: 8px; padding: 10px 14px;
    font-size: 13px; margin-bottom: 14px;
}
.form-summary:empty { display: none; }
.form-summary ul { padding-left: 18px; margin: 0; }

/* ── Flash ───────────────────────────────────────────────────────────────── */
.flash {
    padding: 12px 16px; border-radius: 10px;
    margin: 0 28px 14px; font-size: 14px;
}
.flash.success { background: var(--c-green-bg); color: var(--c-green); border: 1px solid rgba(5,150,105,0.25); }
.flash.error { background: var(--c-red-bg); color: var(--c-red); border: 1px solid rgba(220,38,38,0.25); }
.flash.info { background: var(--c-blue-bg); color: var(--c-blue); border: 1px solid rgba(0,82,204,0.18); }

/* ── Page content (padding wrapper for content not in tables) ─────────────── */
.page-content { padding: 0 28px 24px; }

/* ── Detail header (above tabs) ──────────────────────────────────────────── */
.detail-head {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: 12px 12px 0 0;
    padding: 16px 28px;
    margin: 0 28px;
}
.detail-head .crumb {
    font-size: 12px; color: var(--c-muted);
    margin-bottom: 6px;
}
.detail-head h2 {
    font-size: 22px; font-weight: 800;
    letter-spacing: -0.4px; color: var(--c-charcoal);
}
.detail-head .sub {
    font-size: 13px; color: var(--c-muted); margin-top: 2px;
}
.detail-head .row {
    display: flex; justify-content: space-between;
    align-items: flex-start; gap: 18px; flex-wrap: wrap;
}
.detail-head .avatar-row { display: flex; gap: 18px; align-items: flex-start; }
.detail-head .avatar-lg {
    width: 56px; height: 56px; border-radius: 28px;
    background: var(--c-blue); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700; flex-shrink: 0;
}

/* ── Detail rows (read-only fields) ─────────────────────────────────────── */
.kv {
    font-size: 11px; font-weight: 700; color: var(--c-muted);
    letter-spacing: 0.4px; text-transform: uppercase;
    margin-bottom: 5px;
}
.kv-val { font-size: 14px; color: var(--c-charcoal); font-weight: 500; }
.kv-val.empty { color: var(--c-muted); font-style: italic; font-weight: 400; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kv-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Stat tile (smaller card) ───────────────────────────────────────────── */
.stat-tile {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 16px;
    text-align: center;
}
.stat-tile .v { font-size: 22px; font-weight: 800; color: var(--c-blue); }
.stat-tile .k { font-size: 11px; color: var(--c-muted); margin-top: 4px; }

/* ── Notes / list ────────────────────────────────────────────────────────── */
.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note {
    padding: 12px 14px; background: var(--c-light-gray);
    border-radius: 10px; border-left: 3px solid var(--c-blue);
}
.note-meta { font-size: 12px; color: var(--c-muted); margin-bottom: 4px; }
.note-body { font-size: 14px; color: var(--c-charcoal); white-space: pre-wrap; }

/* ── Toggle ──────────────────────────────────────────────────────────────── */
.toggle {
    width: 40px; height: 22px; border-radius: 11px;
    background: var(--c-border); display: inline-flex; align-items: center;
    padding: 0 3px; cursor: pointer; flex-shrink: 0;
    transition: background 0.15s ease;
}
.toggle .knob { width: 16px; height: 16px; border-radius: 8px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.15s ease; }
.toggle.on { background: var(--c-blue); }
.toggle.on .knob { transform: translateX(18px); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
    background: var(--c-white); border: 1px dashed var(--c-border);
    border-radius: 12px; padding: 36px 24px;
    text-align: center; color: var(--c-muted); font-size: 14px;
}

/* ── Dropdown (legacy details/summary) ───────────────────────────────────── */
.dd { position: relative; display: inline-block; }
.dd > summary { list-style: none; cursor: pointer; user-select: none; }
.dd > summary::-webkit-details-marker { display: none; }
.dd-content {
    position: absolute; top: 100%; right: 0;
    margin-top: 6px;
    background: #fff; border: 1px solid var(--c-border);
    border-radius: 12px; padding: 14px;
    box-shadow: var(--shadow-md);
    min-width: 280px; z-index: 5;
}

/* ── Misc ────────────────────────────────────────────────────────────────── */
pre.json {
    background: var(--c-light-gray); padding: 10px;
    border-radius: 8px; font-size: 12px; max-height: 200px; overflow: auto;
    white-space: pre-wrap; word-break: break-all;
}
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace; font-size: 12px; }
.invitable-list { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; padding: 8px; background: var(--c-light-gray); border-radius: 8px; }
.invitable-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: #fff; border-radius: 6px; font-size: 13px; cursor: pointer; }
.invitable-item input[type=checkbox] { margin: 0; accent-color: var(--c-blue); }
.inline-select { padding: 4px 8px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 12px; background: #fff; }
.muted-text { color: var(--c-muted); }
.spacer { flex: 1; }
.text-right { text-align: right; }
.flex-row { display: flex; align-items: center; gap: 8px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.admin-footer {
    padding: 14px 24px;
    text-align: center;
    border-top: 1px solid var(--c-border);
    background: #fff;
}
.beta-badge {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--c-muted);
    background: var(--c-light-gray);
}
