/* 07-admin.css: admin panel vocabulary (FFLScan admin page shape on the light
   BiometricSource tokens). Loaded after 06-content-pages.css; file order is
   cascade order. */

/* ---------- shell refinements over the 02-shell skeleton ---------- */

.admin-sidebar {
    display: flex;
    flex-direction: column;
}

.admin-nav {
    flex: 1;
    overflow-y: auto;
}

.admin-nav-section {
    display: block;
    padding: 16px 18px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.admin-nav-link.active {
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 600;
    border-right: 3px solid var(--brand-500);
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--brand-500);
    color: var(--text-on-brand);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.admin-sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-user {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---------- page scaffolding ---------- */

.admin-page {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 24px;
    color: var(--brand-900);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- stat cards ---------- */

.header-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--brand-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.stat-item.warn .stat-value {
    color: var(--warning);
}

.stat-item.danger .stat-value {
    color: var(--danger);
}

/* ---------- cards + tables ---------- */

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.dashboard-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.dashboard-card .card-header h3 {
    margin: 0;
    font-size: 15px;
    color: var(--brand-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-count {
    font-size: 12px;
    color: var(--text-muted);
}

.dashboard-card .card-body {
    padding: 18px;
}

.dashboard-card .card-body.no-padding {
    padding: 0;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--brand-50);
}

.data-table tr.row-link {
    cursor: pointer;
}

.data-table .cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.data-table .cell-muted {
    color: var(--text-muted);
}

.cell-time {
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 12px;
}

code.cell-ip {
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    font-size: 12px;
}

.cell-details {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- filters + pager ---------- */

.filters-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filters-bar .form-input,
.filters-bar select.form-input {
    width: auto;
    min-width: 140px;
}

.filters-bar .filter-search {
    flex: 1;
    min-width: 200px;
}

.filters-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---------- status + condition badges (admin contexts) ---------- */

.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge.info {
    background: var(--brand-100);
    color: var(--brand-700);
}

.status-badge.neutral {
    background: var(--bg-subtle);
    color: var(--text-secondary);
}

/* ---------- forms ---------- */

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 18px;
}

.admin-form-grid .form-group.span-2 {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-actions .action-result {
    font-size: 13px;
}

.action-result.ok {
    color: var(--success);
}

.action-result.err {
    color: var(--danger);
}

.field-hint-error {
    color: var(--danger);
    font-size: 12px;
}

.field-hint-ok {
    color: var(--success);
    font-size: 12px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
}

/* editable row lists (spec rows, images, checklist) */
.row-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.row-editor-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-editor-row .form-input {
    flex: 1;
}

.row-editor-row .row-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    flex-shrink: 0;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-icon:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ---------- test connection badges ---------- */

.test-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.test-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
}

.test-badge.ok .dot {
    background: var(--success);
}

.test-badge.fail .dot {
    background: var(--danger);
}

/* ---------- margin display ---------- */

.margin-pos {
    color: var(--success);
    font-weight: 600;
}

.margin-neg {
    color: var(--danger);
    font-weight: 600;
}

.confidential-note {
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- modal + confirm dialog ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 60, 93, 0.45);
    z-index: 90;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 91;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(11, 60, 93, 0.25);
    padding: 22px;
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.confirm-title {
    margin: 0;
    font-size: 17px;
    color: var(--brand-900);
}

.confirm-body {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.confirm-go {
    background: var(--brand-500);
    color: var(--text-on-brand);
    border-color: var(--brand-500);
}

.confirm-go:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tier-danger .confirm-go {
    background: var(--danger);
    border-color: var(--danger);
}

.tier-danger .confirm-body {
    border-left: 3px solid var(--danger);
    padding-left: 12px;
}

.tier-sensitive .confirm-body {
    border-left: 3px solid var(--warning);
    padding-left: 12px;
}

/* ---------- timeline (order history) ---------- */

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline li {
    position: relative;
    padding: 0 0 18px 22px;
    border-left: 2px solid var(--border);
    margin-left: 8px;
}

.timeline li:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.timeline li::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand-500);
    border: 2px solid var(--bg-card);
}

.timeline .timeline-note {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.timeline .timeline-meta {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}

/* ---------- two-column detail layouts ---------- */

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.kv-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    font-size: 13px;
}

.kv-list dt {
    color: var(--text-muted);
    white-space: nowrap;
}

.kv-list dd {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

/* ---------- empty + loading ---------- */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 28px;
    color: var(--border-strong);
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

/* ---------- settings sections ---------- */

.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Secret input + audited reveal button */
.secret-field-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.secret-field-row .form-input {
    flex: 1;
}

.admin-category-parent {
    color: var(--text-muted);
    font-weight: 400;
    margin-right: 4px;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
    .admin-nav-section {
        display: none;
    }

    .nav-badge {
        display: none;
    }

    .dashboard-user {
        display: none;
    }
}
