/* Pellamertrix admin portal: Bootstrap 5 with brand accents. */
:root {
    --brand-navy: #0a0d1f;
    --brand-navy-2: #141938;
    --brand-violet: #7c3aed;
    --brand-violet-light: #a78bfa;
    --brand-indigo: #4f46e5;
    --brand-gradient: linear-gradient(135deg, #a78bfa 0%, #7c3aed 50%, #4f46e5 100%);
    --bs-link-color: #6d28d9;
    --bs-link-color-rgb: 109, 40, 217;
    --bs-link-hover-color: #4c1d95;
    --bs-link-hover-color-rgb: 76, 29, 149;
    --bs-focus-ring-color: rgba(124, 58, 237, .25);
}

html, body { height: 100%; }
body { background: #f4f5fb; font-size: .95rem; }

h1:focus { outline: none; }

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-color: #fff;
    background: var(--brand-gradient);
    border: none;
    font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.btn-brand:hover { filter: brightness(1.08); }
.btn-brand:disabled { opacity: .65; }

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand-violet-light);
    box-shadow: 0 0 0 .2rem rgba(124, 58, 237, .18);
}
.form-check-input:checked { background-color: var(--brand-violet); border-color: var(--brand-violet); }

.brand-name {
    font-family: "Segoe UI", system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: .2em;
    background: linear-gradient(180deg, #fff 0%, #c7cad6 60%, #8e93a6 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--brand-navy);
    background-image: radial-gradient(circle at 0% 0%, rgba(124, 58, 237, .25), transparent 55%);
    color: #c7cad6;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 1.25rem .9rem;
}
.admin-brand { display: flex; align-items: center; gap: .7rem; padding: .25rem .5rem 1.5rem; text-decoration: none; }
.admin-brand > span { display: flex; flex-direction: column; line-height: 1.2; }
.admin-brand .brand-name { font-size: .85rem; }
.admin-brand .brand-sub { font-size: .7rem; color: #8e93a6; letter-spacing: .08em; text-transform: uppercase; }

.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav .nav-group {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #6b7190;
    padding: 1rem .75rem .4rem;
}
.admin-nav a {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .75rem; border-radius: 8px;
    color: #c7cad6; text-decoration: none; font-weight: 500;
}
.admin-nav a:hover { background: rgba(167, 139, 250, .1); color: #fff; }
.admin-nav a.active { background: rgba(124, 58, 237, .28); color: #fff; box-shadow: inset 3px 0 0 var(--brand-violet-light); }
.admin-nav .icon { opacity: .85; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    display: flex; align-items: center; gap: .5rem;
    padding: .75rem 2rem; background: #fff; border-bottom: 1px solid #e6e7ef;
    position: sticky; top: 0; z-index: 10;
}
.admin-content { padding: 2rem; max-width: 1400px; width: 100%; }

@media (max-width: 900px) {
    .admin-shell { flex-direction: column; }
    .admin-sidebar { width: 100%; height: auto; position: static; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; }
    .admin-nav .nav-group { display: none; }
    .admin-content { padding: 1.25rem; }
}

/* ---------- Page chrome ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card { border: 1px solid #e6e7ef; border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card > .table { --bs-table-bg: transparent; }
.card > .table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7190; font-weight: 600; background: #fafbff; }
.card > .table td, .card > .table th { padding: .8rem 1rem; }

.empty-state {
    padding: 2.5rem; text-align: center; color: #6b7190;
    border: 2px dashed #dcdcf0; border-radius: 12px; background: #fff;
}

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.stat-card {
    display: flex; flex-direction: column; gap: .2rem;
    padding: 1.25rem; border-radius: 12px; background: #fff; border: 1px solid #e6e7ef;
    text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px -15px rgba(76, 29, 149, .5); color: inherit; }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7190; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-meta { font-size: .8rem; color: #6b7190; }
.stat-card-accent { background: var(--brand-gradient); border: none; color: #fff; }
.stat-card-accent .stat-label, .stat-card-accent .stat-meta { color: rgba(255, 255, 255, .8); }
.stat-card-accent:hover { color: #fff; }

/* Sections composer */
.section-row {
    display: flex; align-items: center; gap: .9rem;
    padding: .85rem 1rem; margin-bottom: .6rem;
    background: #fff; border: 1px solid #e6e7ef; border-radius: 10px;
}
.section-row.is-hidden { opacity: .6; background: #fafafa; }
.min-w-0 { min-width: 0; }

/* Markdown editor */
.md-editor { border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; background: #fff; }
.md-editor textarea { border: none; border-radius: 0; resize: vertical; font-size: .85rem; }
.md-editor textarea:focus { box-shadow: none; }
.md-toolbar { display: flex; align-items: center; gap: .25rem; padding: .35rem .5rem; background: #f8f9fc; border-bottom: 1px solid #e6e7ef; }
.md-toolbar button { border: none; background: transparent; padding: .25rem .7rem; border-radius: 6px; font-size: .82rem; color: #6b7190; }
.md-toolbar button.active { background: #fff; color: #111; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.md-preview { padding: 1rem 1.25rem; min-height: 160px; }

.image-preview { margin-top: .6rem; max-height: 140px; max-width: 100%; border-radius: 8px; border: 1px solid #e6e7ef; background: var(--brand-navy); padding: 4px; }

/* Messages */
.message-row.unread { background: #f6f3ff; }
.message-row.unread .fw-semibold { color: #4c1d95; }
.message-body { white-space: pre-wrap; font-size: 1rem; line-height: 1.7; }
dl dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7190; font-weight: 600; }
dl dd { margin-bottom: .85rem; }

/* Modal */
.modal { overflow-y: auto; }
.modal-content form { max-height: calc(100vh - 3.5rem); }
/* The image picker can open on top of another dialog (the section editor). */
.modal-stacked-backdrop { z-index: 1060; }
.modal-stacked { z-index: 1065; }

/* Media library */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.media-tile { display: flex; flex-direction: column; background: #fff; border: 1px solid #e6e7ef; border-radius: 10px; overflow: hidden; }
.media-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--brand-navy); }
.media-meta { padding: .6rem .75rem .25rem; min-width: 0; }
.media-actions { display: flex; gap: .4rem; padding: .5rem .75rem .75rem; margin-top: auto; }
.media-actions .btn:first-child { flex: 1; }

.min-w-0 { min-width: 0; }
.hero-image-row { display: flex; align-items: flex-start; gap: .6rem; padding: .75rem; margin-bottom: .6rem; border: 1px solid #e6e7ef; border-radius: 10px; background: #fafbff; }

/* Users and account security */
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-top: 1px solid #eef0f6; }
.action-row:first-of-type { border-top: none; }
.temp-password { font-size: 1.05rem; padding: .2rem .5rem; background: #f4f0ff; border-radius: 6px; user-select: all; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem 1rem; padding: .75rem 1rem; list-style: none; font-family: var(--bs-font-monospace); background: #f8f9fc; border-radius: 8px; }

/* Toasts */
.toast-stack { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }
.admin-toast {
    display: flex; align-items: center; gap: 1rem;
    min-width: 280px; max-width: 420px; padding: .8rem 1rem; border-radius: 10px;
    color: #fff; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .35);
    animation: toast-in .2s ease-out;
}
.admin-toast span { flex: 1; }
.admin-toast-success { background: #15803d; }
.admin-toast-error { background: #b91c1c; }
.admin-toast-info { background: var(--brand-indigo); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Validation */
.valid.modified:not([type=checkbox]) { outline: none; }
.invalid { border-color: #dc3545 !important; }
.validation-message { color: #dc3545; font-size: .85rem; margin-top: .25rem; }

/* Login */
.login-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    background:
        radial-gradient(ellipse 60% 50% at 20% 10%, rgba(124, 58, 237, .35), transparent 70%),
        radial-gradient(ellipse 50% 40% at 85% 85%, rgba(79, 70, 229, .3), transparent 70%),
        var(--brand-navy);
}
.login-card {
    width: 100%; max-width: 400px; padding: 2.5rem 2rem;
    background: #fff; border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6);
}
.login-card .brand-name { background: none; color: var(--brand-navy); -webkit-text-fill-color: var(--brand-navy); font-size: 1.05rem; }
.login-card-wide { max-width: 460px; }
.setup-steps { padding-left: 1.2rem; }
.setup-steps li { margin-bottom: .35rem; }
.qr-code { border: 1px solid #e6e7ef; border-radius: 8px; padding: 6px; background: #fff; image-rendering: pixelated; }
.setup-key { font-size: .9rem; word-spacing: .2rem; user-select: all; }
.code-input { font-size: 1.25rem; letter-spacing: .3em; text-align: center; font-family: var(--bs-font-monospace); }

#blazor-error-ui {
    background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 3000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
