/* ==========================================================================
   admin-base.css — Shared Admin Page Styles
   Cards, Alerts, Buttons, Tables, Forms, Toggles
   ========================================================================== */

/* ── Page Layout ──────────────────────────────────────────────────── */
.admin-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: calc(var(--header-height, 100px) + 2rem) 2rem 6rem;
    animation: adminFadeIn 0.35s ease-out;
}

body.iframe-mode .admin-wrap,
body.iframe-mode .upload-wrap,
body.iframe-mode .word-wrap,
body.iframe-mode .analytics-container,
body.iframe-mode .page-wrap {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

/* Clear the fixed session-timer footer (components.css .aaa-footer is
   position:fixed; bottom:0) that overlays the bottom of the admin shell's
   iframe, so the last row of content — e.g. a submit button or a log — is
   not hidden behind it. Matches the 6rem bottom padding used on regular
   (non-iframe) admin pages for the same reason. */
body.iframe-mode .admin-wrap {
    padding-bottom: 6rem;
}

/* Keep iframe-loaded admin pages from expanding beyond the viewport.
   Wide tables handle their own overflow with an internal horizontal
   scrollbar (see the Tabulator tableholder) instead of widening the page. */
body.iframe-mode .admin-wrap,
body.iframe-mode .upload-wrap,
body.iframe-mode .word-wrap,
body.iframe-mode .analytics-container,
body.iframe-mode .page-wrap {
    max-width: 100%;
}

.admin-wrap--wide {
    max-width: 100%;
}

/* Keep the "Open Applicant:" search bar pinned to the top of the iframe
   viewport so it stays visible while scrolling the page below. */
.iframe-header-search-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

@keyframes adminFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Page Header ──────────────────────────────────────────────────── */
.admin-header {
    margin-bottom: 1.75rem;
}

.admin-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary-navy, #002B51);
    margin: 0 0 0.35rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--color-primary-blue, #0079A3);
}

.admin-subtitle {
    margin: 0.75rem 0 0;
    color: var(--color-text-secondary, #5B5B63);
    font-size: 0.95rem;
}

/* ── Alerts ───────────────────────────────────────────────────────── */
.admin-alert {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-lg, 0.75rem);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    animation: adminSlideIn 0.3s ease-out;
}

@keyframes adminSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.admin-alert--success {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
}

.admin-alert--error {
    background: #ffebee;
    color: #b71c1c;
    border: 1px solid #ef9a9a;
}

.admin-alert--info {
    background: #e3f2fd;
    color: #0d47a1;
    border: 1px solid #90caf9;
}

.admin-alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.admin-alert--success .admin-alert-icon {
    background: #2e7d32;
    color: #fff;
}

.admin-alert--error .admin-alert-icon {
    background: #c62828;
    color: #fff;
}

.admin-alert--info .admin-alert-icon {
    background: #1565c0;
    color: #fff;
}

/* ── Card ─────────────────────────────────────────────────────────── */
.admin-card {
    background: #fff;
    border-radius: var(--radius-xl, 1rem);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.admin-card-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem 2rem;
    background: var(--color-primary-navy, #002B51);
    color: #fff;
}

.admin-card-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 0.1rem;
}

.admin-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.25rem;
}

.admin-card-desc {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

.admin-card-desc strong {
    color: #fff;
}

.admin-card-body {
    padding: 1.5rem 2rem;
}

.admin-card-actions {
    padding: 1.25rem 2rem;
    background: #f7f9fc;
    border-top: 1px solid #e8ecf0;
}

/* ── Plain Card (no navy header) ──────────────────────────────────── */
.admin-card-plain {
    background: #fff;
    border-radius: var(--radius-xl, 1rem);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 2rem;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--color-primary-blue, #0079A3);
    border: none;
    border-radius: var(--radius-md, 0.5rem);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.admin-btn:hover {
    background: var(--color-primary-navy, #002B51);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 43, 81, 0.2);
    color: #fff;
    text-decoration: none;
}

.admin-btn:active {
    transform: translateY(0);
}

.admin-btn:focus-visible {
    outline: 2px solid var(--color-primary-blue, #0079A3);
    outline-offset: 2px;
}

.admin-btn--secondary {
    background: #475569;
}

.admin-btn--secondary:hover {
    background: #1e293b;
}

.admin-btn--danger {
    background: #dc2626;
}

.admin-btn--danger:hover {
    background: #b91c1c;
}

.admin-btn--sm {
    padding: 0.4rem 1.2rem;
    font-size: 0.82rem;
}

.admin-btn--block {
    width: 100%;
    justify-content: center;
}

/* ── Tables ───────────────────────────────────────────────────────── */
.admin-table-wrap {
    overflow-x: auto;
}

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

.admin-table thead th {
    background: var(--color-primary-blue, #0079A3);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.85rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    text-align: left;
}

.admin-table tbody td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #eef0f4;
    vertical-align: middle;
}

.admin-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.admin-table tbody tr:hover {
    background: #eef6ff;
}

/* ── Form Controls ────────────────────────────────────────────────── */
.admin-form-group {
    margin-bottom: 1rem;
}

.admin-form-label {
    display: block;
    font-weight: 600;
    color: var(--color-primary-navy, #002B51);
    font-size: 0.88rem;
    margin-bottom: 0.35rem;
}

.admin-form-control {
    width: 100%;
    padding: 0.55rem 0.9rem;
    border: 2px solid #d0d8e0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.admin-form-control:focus {
    outline: none;
    border-color: var(--color-primary-blue, #0079A3);
    box-shadow: 0 0 0 3px rgba(0, 121, 163, 0.12);
}

.admin-form-control::placeholder {
    color: #94a3b8;
}

textarea.admin-form-control {
    font-family: 'Courier New', monospace;
}

/* ── Toggle Switch ────────────────────────────────────────────────── */
.admin-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 36px;
    height: 22px;
    cursor: pointer;
}

.admin-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.admin-toggle-knob {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 22px;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
}

.admin-toggle-knob::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.admin-toggle input:checked + .admin-toggle-knob {
    background: var(--color-primary-blue, #0079A3);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.admin-toggle input:checked + .admin-toggle-knob::after {
    transform: translateX(14px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.admin-toggle input:focus-visible + .admin-toggle-knob {
    outline: 2px solid var(--color-primary-blue, #0079A3);
    outline-offset: 2px;
}

/* ── Checkbox (larger, styled) ────────────────────────────────────── */
.admin-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary-blue, #0079A3);
}

/* ── Status Badge ─────────────────────────────────────────────────── */
.admin-badge {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
}

.admin-badge--active { background: #e8f5e9; color: #2E7D32; }
.admin-badge--inactive { background: #ffebee; color: #C62828; }
.admin-badge--pending { background: #fff3e0; color: #E65100; }
.admin-badge--warning { background: #fff8e1; color: #B26A00; }

/* ── Tab System (vanilla) ─────────────────────────────────────────── */
.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0;
}

.admin-tab {
    padding: 0.65rem 1.75rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: #4a6a7a;
    background: #e8f4f9;
    border: 1px solid #c8dce6;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}

.admin-tab:hover {
    background: #d4eaf3;
    color: var(--color-primary-navy, #002B51);
}

.admin-tab.active {
    background: var(--color-primary-blue, #0079A3);
    color: #fff;
    border-color: var(--color-primary-blue, #0079A3);
}

.admin-tab-content {
    display: none;
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 0 0 12px 12px;
    border: 1px solid #e2e8f0;
    border-top: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.admin-tab-content.active {
    display: block;
}

/* ── Modal (vanilla) ──────────────────────────────────────────────── */
.admin-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.admin-modal-overlay.active {
    display: flex;
}

.admin-modal {
    background: #fff;
    border-radius: var(--radius-xl, 1rem);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: adminModalIn 0.2s ease-out;
}

@keyframes adminModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.admin-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid #eef0f4;
}

.admin-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary-navy, #002B51);
    margin: 0;
}

.admin-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.25rem;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.admin-modal-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.admin-modal-body {
    padding: 1.5rem 1.75rem;
}

.admin-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.75rem;
    border-top: 1px solid #eef0f4;
    background: #f8fafc;
}

/* ── Misc utilities ───────────────────────────────────────────────── */
.admin-text-muted {
    color: var(--color-text-secondary, #5B5B63);
    font-size: 0.85rem;
}

.admin-text-center { text-align: center; }

@media (max-width: 768px) {
    .admin-wrap {
        padding: calc(var(--header-height, 100px) + 1rem) 1rem 6rem;
    }

    .admin-card-head {
        flex-direction: column;
        padding: 1.25rem;
    }

    .admin-card-body,
    .admin-card-actions {
        padding: 1rem 1.25rem;
    }

    .admin-card-plain {
        padding: 1.25rem;
    }

    .admin-tab-content {
        padding: 1.25rem;
    }

    .admin-btn--block-mobile {
        width: 100%;
        justify-content: center;
    }
}
