/* ============================================================
   Intercede — Design System
   Palette: warm off-white bg, charcoal text, muted slate accent
   ============================================================ */

:root {
    --bg:           #FAFAF7;
    --surface:      #FFFFFF;
    --border:       #E8E6E3;
    --border-focus: #5B7FA3;
    --text:         #1C1917;
    --text-muted:   #78716C;
    --accent:       #5B7FA3;
    --accent-hover: #3D6089;
    --accent-light: #EEF3F8;
    --error:        #9A3412;
    --error-bg:     #FEF2F2;
    --error-border: #FECACA;
    --success:      #14532D;
    --success-bg:   #F0FDF4;
    --success-border:#BBF7D0;
    --radius:       6px;
    --shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

/* ---- Reset & Base ---- */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---- Typography ---- */

.wordmark {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 1.5rem;
    font-weight: normal;
    letter-spacing: .02em;
    color: var(--text);
}

h1, h2, h3 {
    margin: 0 0 .5rem;
    line-height: 1.25;
    font-weight: 600;
}

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

/* ---- Layout ---- */

.container {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container--wide {
    max-width: 960px;
}

/* ---- Site Header ---- */

.site-header {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---- Page sections ---- */

.page-hero {
    padding: 3.5rem 0 2rem;
    text-align: center;
}

.page-hero__title {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: normal;
    letter-spacing: .02em;
    margin-bottom: .75rem;
}

.page-hero__sub {
    font-size: 1.0625rem;
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 0;
    line-height: 1.7;
}

/* ---- Card ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

/* ---- Form elements ---- */

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .375rem;
    color: var(--text);
}

.label-optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: .8125rem;
    margin-left: .25rem;
}

input[type="text"],
input[type="email"],
textarea,
select {
    display: block;
    width: 100%;
    padding: .625rem .875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(91,127,163,.15);
}

textarea {
    resize: vertical;
    min-height: 140px;
}

.field-hint {
    margin-top: .375rem;
    font-size: .8125rem;
    color: var(--text-muted);
}

.field-error {
    margin-top: .375rem;
    font-size: .8125rem;
    color: var(--error);
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .65rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}
.btn--primary:hover {
    background: var(--accent-hover);
    color: #fff;
    text-decoration: none;
}

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn--secondary:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

.btn--danger {
    background: #FEF2F2;
    color: var(--error);
    border: 1px solid var(--error-border);
}
.btn--danger:hover {
    background: var(--error-border);
}

.btn--full { width: 100%; }

.btn--sm {
    padding: .375rem .875rem;
    font-size: .875rem;
}

/* ---- Alerts ---- */

.alert {
    padding: .875rem 1.125rem;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: .9375rem;
    margin-bottom: 1.5rem;
}
.alert--error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error); }
.alert--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }

/* ---- Divider CTA ---- */

.divider-cta {
    text-align: center;
    padding: 2rem 0 3rem;
    color: var(--text-muted);
    font-size: .9375rem;
}

/* ---- Site footer ---- */

.site-footer {
    margin-top: 4rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: .8125rem;
    color: var(--text-muted);
}

/* ============================================================
   Admin Panel
   ============================================================ */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #1C1917;
    color: #D6D3D1;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
}

.admin-sidebar__brand {
    padding: 0 1.25rem 1.5rem;
    font-family: Georgia, serif;
    font-size: 1.125rem;
    color: #fff;
    border-bottom: 1px solid #292524;
    margin-bottom: 1rem;
}

.admin-sidebar__label {
    padding: .25rem 1.25rem;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #78716C;
    margin-top: .5rem;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1.25rem;
    font-size: .9375rem;
    color: #D6D3D1;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .1s, color .1s;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: #292524;
    color: #fff;
    text-decoration: none;
}

.admin-nav a.active {
    border-left-color: var(--accent);
}

.admin-sidebar__spacer { flex: 1; }

.admin-sidebar__logout {
    padding: 1rem 1.25rem 0;
    border-top: 1px solid #292524;
}

.admin-sidebar__logout form button {
    background: none;
    border: none;
    color: #78716C;
    font-size: .875rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.admin-sidebar__logout form button:hover { color: #D6D3D1; }

.admin-main {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    background: var(--bg);
}

.admin-page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-page-header h1 {
    font-size: 1.375rem;
    font-weight: 600;
}

/* ---- Badge ---- */

.badge {
    display: inline-block;
    padding: .2rem .625rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.5;
}
.badge--flagged  { background: #FEF3C7; color: #92400E; }
.badge--content  { background: #FEE2E2; color: #991B1B; }
.badge--privacy  { background: #EDE9FE; color: #5B21B6; }
.badge--approved { background: var(--success-bg); color: var(--success); }
.badge--rejected { background: #F3F4F6; color: #6B7280; }
.badge--pending  { background: #F0F9FF; color: #0369A1; }

/* ---- Table ---- */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9375rem;
}

thead th {
    text-align: left;
    padding: .75rem 1rem;
    font-size: .8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

tbody td {
    padding: .875rem 1rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

.table-truncate {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Stats grid ---- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
}

.stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: .25rem;
    color: var(--text);
}

.stat-card__label {
    font-size: .8125rem;
    color: var(--text-muted);
}

/* ---- Queue card (flagged requests) ---- */

.queue-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.queue-item__meta {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .875rem;
    flex-wrap: wrap;
}

.queue-item__timestamp {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-left: auto;
}

.queue-item__text {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    font-size: .9375rem;
    line-height: 1.7;
    margin-bottom: 1rem;
    white-space: pre-wrap;
}

.queue-item__rationale {
    font-size: .875rem;
    color: var(--text-muted);
    margin-bottom: 1.125rem;
    padding: .75rem 1rem;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: var(--radius);
}

.queue-item__rationale strong {
    color: #92400E;
}

.queue-item__actions {
    display: flex;
    gap: .625rem;
    flex-wrap: wrap;
    align-items: center;
}

.edit-form {
    margin-top: 1rem;
    display: none;
}
.edit-form.visible { display: block; }

.edit-form textarea {
    margin-bottom: .75rem;
}

/* ---- Empty state ---- */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state__icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: .4;
}
.empty-state__title {
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: .375rem;
}

/* ---- Responsive ---- */

@media (max-width: 700px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 1rem; }
    .admin-sidebar__brand { border-bottom: none; padding-bottom: 0; }
    .admin-nav { display: flex; flex-wrap: wrap; gap: .25rem; }
    .admin-nav a { padding: .4rem .75rem; border-left: none; border-radius: var(--radius); }
    .admin-main { padding: 1.25rem; }
    .card { padding: 1.25rem; }
}
