/* ===================================================
   Admin Page — Login Sessions Table Styles
   =================================================== */

.admin-page-body {
    padding: 1.5rem 2rem;
    max-width: 100%;
    margin: 0;
}

/* --- Toolbar (search + info) --- */
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.admin-search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 480px;
}

.admin-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #888);
    pointer-events: none;
}

.admin-search {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.5rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.5rem;
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-search:focus {
    border-color: var(--accent, #6c63ff);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.admin-pagination-info {
    font-size: 0.82rem;
    color: var(--text-secondary, #888);
    white-space: nowrap;
}

/* --- Table --- */
.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.6rem;
    background: var(--bg-secondary, #1a1a2e);
}

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

.admin-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary, #16213e);
    color: var(--text-secondary, #aaa);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color, #333);
    white-space: nowrap;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Column widths */
.admin-table thead th:nth-child(1) { width: 30%; }
.admin-table thead th:nth-child(2) { width: 30%; }
.admin-table thead th:nth-child(3) { width: 18%; }
.admin-table thead th:nth-child(4) { width: 22%; }

/* Leads table */
.leads-note-cell {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#leads-table tbody tr:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.admin-session-row {
    transition: background 0.15s;
}

.admin-session-row:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.admin-session-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}
.admin-session-row:nth-child(even):hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.admin-cell {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color, #222);
    color: var(--text-primary, #e0e0e0);
    vertical-align: middle;
}

.admin-cell-email {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-cell-time {
    white-space: nowrap;
    color: var(--text-secondary, #aaa);
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}

.admin-cell-ip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.84rem;
    color: var(--text-secondary, #aaa);
}

.admin-cell-ua {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-tertiary, #666);
    font-size: 0.84rem;
}

/* --- Load More --- */
.admin-load-more-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 0.75rem;
}

.admin-load-more-btn {
    padding: 0.55rem 2rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.5rem;
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.admin-load-more-btn:hover:not(:disabled) {
    background: var(--bg-hover, rgba(108, 99, 255, 0.1));
    border-color: var(--accent, #6c63ff);
    transform: translateY(-1px);
}

.admin-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Empty row --- */
.admin-empty-row td {
    border-bottom: none;
}

/* ===================================================
   Admin Tabs
   =================================================== */
.admin-tabs {
    display: flex;
    gap: 0;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color, #333);
    flex-shrink: 0;
}

.admin-tab {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    color: var(--text-secondary, #888);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.admin-tab:hover {
    color: var(--text-primary, #e0e0e0);
}

.admin-tab.active {
    color: var(--accent, #6c63ff);
    border-bottom-color: var(--accent, #6c63ff);
}

.admin-tab svg {
    flex-shrink: 0;
}

/* --- Tab Panels --- */
.admin-tab-panel {
    display: none;
    flex-direction: column;
    min-height: 0;
}

.admin-tab-panel.active {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===================================================
   Sample Reports Grid
   =================================================== */
.admin-reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.admin-report-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.65rem;
    background: var(--bg-secondary, #1a1a2e);
    text-decoration: none;
    color: var(--text-primary, #e0e0e0);
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.admin-report-card:hover {
    border-color: var(--accent, #6c63ff);
    background: var(--bg-hover, rgba(108, 99, 255, 0.06));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.admin-report-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(108, 99, 255, 0.1);
    color: var(--accent, #6c63ff);
}

.admin-report-icon svg {
    width: 22px;
    height: 22px;
}

.admin-report-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.admin-report-title {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-report-meta {
    font-size: 0.78rem;
    color: var(--text-secondary, #888);
}

.admin-report-arrow {
    flex-shrink: 0;
    color: var(--text-tertiary, #555);
    transition: color 0.2s, transform 0.2s;
}

.admin-report-card:hover .admin-report-arrow {
    color: var(--accent, #6c63ff);
    transform: translateX(3px);
}

.admin-reports-loading,
.admin-reports-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary, #888);
    font-size: 0.9rem;
}

/* ===================================================
   Add Report Button
   =================================================== */
.admin-add-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--accent, #6c63ff);
    border-radius: 0.5rem;
    background: rgba(108, 99, 255, 0.1);
    color: var(--accent, #6c63ff);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
}
.admin-add-btn:hover {
    background: rgba(108, 99, 255, 0.2);
    transform: translateY(-1px);
}

/* ===================================================
   Modal Overlay + Dialog
   =================================================== */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.admin-modal {
    width: 100%;
    max-width: 520px;
    background: var(--bg-primary, #0f0f23);
    border: 1px solid var(--border-color, #333);
    border-radius: 0.85rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #333);
}

.admin-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary, #e0e0e0);
}

.admin-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.35rem;
    transition: color 0.2s, background 0.2s;
}
.admin-modal-close:hover {
    color: var(--text-primary, #e0e0e0);
    background: rgba(255, 255, 255, 0.06);
}

/* ===================================================
   Form inside Modal
   =================================================== */
#admin-report-form {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.admin-form-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary, #aaa);
    margin-bottom: 0.3rem;
}

.admin-form-row label .required {
    color: var(--danger, #ef4444);
}

.admin-form-row input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.45rem;
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.admin-form-row input:focus {
    border-color: var(--accent, #6c63ff);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.admin-form-row input::placeholder {
    color: var(--text-tertiary, #555);
}

.admin-form-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.admin-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 0.3rem;
}

.admin-form-cancel {
    padding: 0.55rem 1.2rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary, #aaa);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.admin-form-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #e0e0e0);
}

.admin-form-submit {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--accent, #6c63ff);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.admin-form-submit:hover { opacity: 0.88; }
.admin-form-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-form-error {
    color: var(--danger, #ef4444);
    font-size: 0.82rem;
    margin: 0;
    text-align: center;
}

/* ── Test Runner ─────────────────────────────── */

.test-sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    padding: 0 1rem;
    background: var(--bg-secondary, rgba(255,255,255,0.02));
}

.test-sub-tab {
    padding: 0.6rem 1.25rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.test-sub-tab:hover {
    color: var(--text-primary, #e2e8f0);
}
.test-sub-tab.active {
    color: var(--accent, #f97316);
    border-bottom-color: var(--accent, #f97316);
}

.test-sub-panel {
    display: none;
}
.test-sub-panel.active {
    display: block;
}

.test-summary {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
}
.test-summary-passed { color: #22c55e; }
.test-summary-failed { color: #ef4444; }
.test-summary-skipped { color: #f59e0b; }
.test-summary-total { color: var(--text-secondary, #94a3b8); }
.test-summary-time { color: var(--text-secondary, #94a3b8); font-weight: 400; }

.test-summary-id {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    cursor: default;
}

.test-cases-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.test-category {
    margin-bottom: 0.75rem;
}

.test-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    margin-bottom: 0.35rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #c4b5fd;
}

.test-category:first-child .test-category-header {
    margin-top: 0;
}

.test-cat-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.test-cat-count {
    font-weight: 400;
    font-size: 0.75rem;
}

.test-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.test-play-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    transform: scale(1.1);
}
.test-play-btn:active { transform: scale(0.95); }

.test-case-row {
    display: grid;
    grid-template-columns: 28px 26px 1fr auto auto;
    gap: 0.5rem;
    align-items: start;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s;
}
.test-case-row:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.test-check {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.test-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.test-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary, #e2e8f0);
}

.test-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.4;
}

.test-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 2px 0;
}

.test-meta-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.test-meta-model {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.35);
}

.test-meta-mode {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.test-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 3px;
}

.test-step {
    font-size: 0.67rem;
    color: var(--gray-500, #6b7280);
    white-space: nowrap;
}

.test-status {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 56px;
    text-align: center;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
    color: var(--text-secondary, #94a3b8);
}
.test-status.test-pass {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.test-status.test-fail {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.test-status.test-running {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    animation: test-pulse 1s ease-in-out infinite;
}
.test-status.test-skip {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

@keyframes test-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.test-detail {
    font-size: 0.72rem;
    color: var(--text-secondary, #94a3b8);
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.test-row-pass { border-left: 3px solid #22c55e; }
.test-row-fail { border-left: 3px solid #ef4444; }
.test-row-running { border-left: 3px solid #3b82f6; }

.test-log {
    margin-top: 1rem;
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
}

.test-log-line {
    color: var(--text-secondary, #94a3b8);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Test History ──────────────────────────── */

.test-history {
    margin-top: 1.25rem;
}

.test-hist-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 0.5rem;
}

.test-hist-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: background 0.15s;
}
.test-hist-row:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.test-hist-env {
    min-width: 60px;
    font-size: 0.75rem;
}

.test-hist-time {
    color: var(--text-secondary, #94a3b8);
    min-width: 150px;
    font-size: 0.75rem;
}

.test-hist-user {
    color: var(--text-secondary, #94a3b8);
    min-width: 140px;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.test-hist-empty {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8rem;
    padding: 0.5rem 0;
}

/* ── Test Results Table ───────────────────── */

.test-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.test-results-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}
.test-results-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
    color: var(--text-primary, #e2e8f0);
}
.test-results-table tbody tr:hover td {
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.test-hist-id {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
}

.test-hist-expand {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.15s;
}
.test-hist-expand:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    color: var(--text-primary, #e2e8f0);
}

.test-hist-detail-row td {
    padding: 0 !important;
    background: var(--bg-primary, #0f172a);
}

.test-hist-detail-content {
    padding: 0.75rem 1rem;
}

.test-hist-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.test-hist-detail-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
}
