/* admin/assets/css/admin.css */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --admin-navy: #0A2540;
    --admin-navy-light: #0F3558;
    --admin-teal: #009688;
    --admin-teal-deep: #004D44;
    --admin-gold: #C9973B;
    --admin-warm-ivory: #F5F0E8;
    --admin-bg: #f8f9fa;
    --admin-sidebar-width: 260px;
    --bs-body-font-family: 'Plus Jakarta Sans', sans-serif;
    --bs-heading-font-family: 'Instrument Serif', serif;
}

body {
    font-family: var(--bs-body-font-family);
    margin: 0;
    background: var(--admin-bg);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--bs-heading-font-family);
    font-weight: 700;
    color: var(--admin-navy);
}

/* ── Sidebar ──────────────────────────────────────────── */

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--admin-sidebar-width);
    height: 100vh;
    background: var(--admin-navy);
    color: #fff;
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.admin-sidebar .sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-sidebar .sidebar-user {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar .role-badge {
    display: inline-block;
    font-size: 0.675rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 50px;
    background: rgba(0, 150, 136, 0.25);
    color: #5dded3;
    margin-top: 4px;
}

.admin-sidebar .nav {
    flex: 1;
    padding: 0;
}

.admin-sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.admin-sidebar .nav-link:hover {
    color: #fff;
    background: rgba(0, 150, 136, 0.15);
    border-left-color: rgba(0, 150, 136, 0.4);
}

.admin-sidebar .nav-link.active {
    color: #fff;
    background: rgba(0, 150, 136, 0.2);
    border-left-color: var(--admin-teal);
}

.admin-sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

.admin-sidebar .sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
}

/* ── Main content ─────────────────────────────────────── */

.admin-main {
    margin-left: var(--admin-sidebar-width);
    padding: 24px;
    min-height: 100vh;
    background: var(--admin-bg);
}

.admin-main .page-title {
    font-size: 1.75rem;
    margin-bottom: 24px;
    color: var(--admin-navy);
}

/* ── Login gate ───────────────────────────────────────── */

.admin-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--admin-warm-ivory);
}

.admin-login .card {
    border: none;
    border-radius: 12px;
}

/* ── Metric cards ─────────────────────────────────────── */

.metric-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.metric-number {
    font-family: var(--bs-heading-font-family);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--admin-teal);
    line-height: 1.1;
}

.metric-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-top: 4px;
}

.metric-sublabel {
    font-size: 0.75rem;
    color: #adb5bd;
    margin-top: 2px;
}

/* ── Compact stat blocks (dashboard) ─────────────────── */

.stat-compact {
    padding: 12px 0;
}

.stat-compact-number {
    font-family: var(--bs-heading-font-family);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--admin-teal);
    line-height: 1.1;
}

.stat-compact-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-top: 2px;
}

.stat-compact-sub {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: 2px;
}

/* ── Donut chart container ───────────────────────────── */

.donut-container {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-end;
}

.donut-container canvas {
    max-width: 120px;
    max-height: 120px;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #495057;
}

.donut-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Funnel cards (assessment health) ────────────────── */

.funnel-card {
    display: block;
    background: #fff;
    border: 1px solid #e9ecef;
    border-left: 4px solid var(--admin-teal);
    border-radius: 0 10px 10px 0;
    padding: 16px 20px;
    margin-bottom: 0;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    border-bottom: 1px solid #f1f3f5;
}

.funnel-card:last-child {
    border-bottom: none;
}

.funnel-card:hover {
    background: #fafbfc;
    text-decoration: none;
    color: inherit;
}

.funnel-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--admin-navy);
}

.funnel-card-number {
    font-family: var(--bs-heading-font-family);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--admin-teal);
    line-height: 1.1;
}

.funnel-card-number-sm {
    font-size: 1.25rem;
    color: var(--admin-navy);
}

.funnel-card-label {
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

/* ── Funnel bar (category distribution) ──────────────── */

.funnel-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.funnel-bar-segment {
    height: 100%;
    min-width: 2px;
    transition: width 0.3s ease;
}

.funnel-bar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.funnel-bar-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.675rem;
    color: #6c757d;
}

.funnel-bar-legend-swatch {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Action delete button (participants table) ───────── */

.action-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #dc3545;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}

.action-delete:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #a71d2a;
}

.action-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Mass action buttons (data management) ───────────── */

.mass-action-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #dc3545;
    background: #fff;
    border: 1px solid #dc3545;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mass-action-btn:hover {
    background: #dc3545;
    color: #fff;
}

.mass-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Activity feed links ─────────────────────────────── */

.activity-link {
    color: var(--admin-navy);
    font-weight: 700;
    text-decoration: none;
}

.activity-link:hover {
    color: var(--admin-teal);
    text-decoration: underline;
}

/* ── Participant name link (list table) ──────────────── */

.participant-name-link {
    color: var(--admin-navy);
    text-decoration: none;
}

.participant-name-link:hover {
    color: var(--admin-teal);
    text-decoration: underline;
}

/* ── Participant UID row (detail page) ───────────────── */

.participant-uid-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.participant-uid-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
}

.participant-uid-value {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    color: #495057;
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    user-select: all;
}

.participant-uid-copy {
    padding: 2px 6px;
    font-size: 0.7rem;
    line-height: 1;
    border-radius: 4px;
}

/* ── Assessment tab link styling (detail page) ───────── */

.assessment-tab-link {
    cursor: pointer;
    transition: color 0.15s ease;
}

.assessment-tab-link:hover:not(.active) {
    color: var(--admin-teal) !important;
}

/* ── Data table ───────────────────────────────────────── */

.data-table {
    width: 100%;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table thead th {
    background: var(--admin-navy);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    border: none;
    white-space: nowrap;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 24px;
}

.data-table th.sortable::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 8px;
    opacity: 0.4;
    font-size: 0.7rem;
}

.data-table th.sortable.sort-asc::after {
    content: '\f0de';
    opacity: 1;
}

.data-table th.sortable.sort-desc::after {
    content: '\f0dd';
    opacity: 1;
}

.data-table tbody tr {
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.15s ease;
}

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

.data-table tbody tr:hover {
    background: rgba(0, 150, 136, 0.04);
    cursor: pointer;
}

.data-table td {
    padding: 10px 16px;
    font-size: 0.875rem;
    vertical-align: middle;
}

/* ── Activity feed ────────────────────────────────────── */

.activity-feed {
    max-height: 500px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-left: 3px solid transparent;
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.15s ease;
}

.activity-item:hover {
    background: #fafbfc;
}

.activity-item.activity-completion {
    border-left-color: var(--admin-teal);
}

.activity-item.activity-start {
    border-left-color: var(--admin-gold);
}

.activity-item .activity-body {
    flex: 1;
    min-width: 0;
}

.activity-item .activity-timestamp {
    font-size: 0.75rem;
    color: #adb5bd;
    white-space: nowrap;
    margin-left: 12px;
    flex-shrink: 0;
}

/* ── Status badges ────────────────────────────────────── */

.status-badge-active {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 50px;
    background: #d4edda;
    color: #155724;
}

.status-badge-inactive {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 50px;
    background: #fff3cd;
    color: #856404;
}

.status-badge-anonymous {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 50px;
    background: #e9ecef;
    color: #495057;
}

.status-badge-identified {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 50px;
    background: rgba(0, 150, 136, 0.15);
    color: var(--admin-teal-deep);
}

/* ── Provider icons ───────────────────────────────────── */

.provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.6rem;
    color: #fff;
    flex-shrink: 0;
}

.provider-icon.provider-google {
    background: #4285F4;
}

.provider-icon.provider-linkedin {
    background: #0A66C2;
}

.provider-icon.provider-email {
    background: var(--admin-teal);
}

.provider-icon.provider-anonymous {
    background: #6c757d;
}

/* ── Study dots / badges ──────────────────────────────── */

.study-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
}

.study-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 50px;
    color: #fff;
}

/* ── Raw response table ───────────────────────────────── */

.raw-response-table {
    font-size: 0.8rem;
    width: 100%;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.raw-response-table th {
    background: #f8f9fa;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
    color: #495057;
}

.raw-response-table td {
    padding: 8px 12px;
    vertical-align: top;
    border-bottom: 1px solid #f1f3f5;
}

/* ── Score bar ────────────────────────────────────────── */

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

.score-bar .bar-track {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.score-bar .bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--admin-teal);
    transition: width 0.4s ease;
}

.score-bar .bar-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--admin-navy);
    min-width: 32px;
    text-align: right;
}

/* ── Assessment health cards ──────────────────────────── */

.assessment-health-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.assessment-health-card .study-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ── Notes section ────────────────────────────────────── */

.note-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f5;
}

.note-item .note-meta {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 4px;
}

.note-item .note-content {
    font-size: 0.875rem;
}

/* ── Search and filters ───────────────────────────────── */

.admin-search-bar {
    position: relative;
}

.admin-search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
}

.admin-search-bar input {
    padding-left: 36px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    font-size: 0.875rem;
}

.admin-search-bar input:focus {
    border-color: var(--admin-teal);
    box-shadow: 0 0 0 0.2rem rgba(0, 150, 136, 0.15);
}

.filter-row .form-select {
    font-size: 0.875rem;
    border-radius: 8px;
}

/* ── Pagination ───────────────────────────────────────── */

.admin-pagination .page-link {
    color: var(--admin-navy);
    border-radius: 6px;
    margin: 0 2px;
    font-size: 0.875rem;
}

.admin-pagination .page-item.active .page-link {
    background: var(--admin-teal);
    border-color: var(--admin-teal);
    color: #fff;
}

/* ── Participant detail header ────────────────────────── */

.participant-header {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.participant-header .participant-name {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.participant-header .participant-uid {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #6c757d;
    cursor: pointer;
}

.participant-header .participant-uid:hover {
    color: var(--admin-teal);
}

/* ── Tab styling ──────────────────────────────────────── */

.admin-tabs .nav-link {
    color: #495057;
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 16px;
}

.admin-tabs .nav-link.active {
    color: var(--admin-teal);
    border-bottom-color: var(--admin-teal);
    background: transparent;
}

.admin-tabs .nav-link:hover:not(.active) {
    border-bottom-color: #dee2e6;
}

/* ── Loading spinner ──────────────────────────────────── */

.admin-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.admin-spinner .spinner-border {
    color: var(--admin-teal);
}

/* ── Mobile hamburger ─────────────────────────────────── */

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    background: var(--admin-navy);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

/* ── Responsive: collapse sidebar under 992px ─────────── */

@media (max-width: 991.98px) {
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .admin-main {
        margin-left: 0;
        padding: 16px;
        padding-top: 60px;
    }
}
