/* ═══════════════════════════════════════════════════════════════
   PERFERRO — ADMIN STYLESHEET
═══════════════════════════════════════════════════════════════ */

/* ── Admin Layout ───────────────────────────────────────────── */
.admin-body { background: var(--color-bg-alt); }
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.admin-sidebar {
    background: var(--color-nav-bg);
    color: var(--color-nav-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand { margin-bottom: 0.15rem; }
.sidebar-brand small { color: rgba(255,255,255,.4); font-size: 0.75rem; }
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    flex: 1;
}
.sidebar-group {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
}
.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 1.25rem;
    color: rgba(255,255,255,.7);
    font-size: 0.9rem;
    text-decoration: none;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar-link.active { color: #fff; background: rgba(204,43,43,.2); border-left-color: var(--color-accent); }
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .theme-toggle { width: 100%; }
.badge {
    background: var(--color-accent);
    color: #fff;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    min-width: 1.4rem;
    text-align: center;
}

/* ── Main Area ──────────────────────────────────────────────── */
.admin-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.admin-page-title { margin: 0; font-size: 1.3rem; }
.admin-content { padding: 2rem; flex: 1; }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}
.stat-num { font-size: 2.5rem; font-weight: 800; color: var(--color-accent); line-height: 1; }
.stat-label { color: var(--color-text-muted); font-size: 0.85rem; margin: 0.35rem 0 0.75rem; }
.stat-link { font-size: 0.85rem; color: var(--color-accent); font-weight: 600; }

/* ── Admin Section ──────────────────────────────────────────── */
.admin-section { margin-bottom: 2.5rem; }
.section-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}
.section-header-bar h2 { margin: 0; font-size: 1.15rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.9rem;
}
.admin-table th {
    background: var(--color-bg-alt);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}
.admin-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--color-bg-alt); }
.row-unread td { font-weight: 600; }
.table-actions { white-space: nowrap; display: flex; gap: 0.4rem; }
.empty-row { text-align: center; color: var(--color-text-muted); padding: 2rem; }
code {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

/* ── Status Badges ──────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
}
.status-badge.published { background: #dcfce7; color: #166534; }
.status-badge.draft     { background: #fef3c7; color: #92400e; }
[data-theme="dark"] .status-badge.published { background: #14532d; color: #86efac; }
[data-theme="dark"] .status-badge.draft     { background: #451a03; color: #fde68a; }

/* ── Form Pages ─────────────────────────────────────────────── */
.form-page { max-width: 800px; }
.back-link {
    display: inline-block;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
    text-decoration: none;
}
.back-link:hover { color: var(--color-text); }
.code-textarea {
    font-family: var(--font-mono) !important;
    font-size: 0.85rem !important;
}

/* ── Message View ───────────────────────────────────────────── */
.message-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.message-meta {
    background: var(--color-bg-alt);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}
.message-meta strong { color: var(--color-text); }
.message-body {
    padding: 1.75rem 1.5rem;
    line-height: 1.8;
    white-space: pre-wrap;
}
.message-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.75rem;
}

/* ── Login ──────────────────────────────────────────────────── */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-alt);
}
.login-wrap { width: 100%; max-width: 400px; padding: 1.5rem; }
.login-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.75rem;
    justify-content: center;
}
.login-brand .brand-name { color: var(--color-heading); font-size: 1.2rem; font-weight: 700; }
.login-title { text-align: center; margin: 0 0 1.5rem; font-size: 1.15rem; }
