/* ═══════════════════════════════════════════
   Terminal43 -- Admin Panel Styles
   ═══════════════════════════════════════════ */

.admin-section {
    padding-top: calc(var(--navbar-height) + 2rem);
    padding-bottom: 3rem;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-header h1 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
}

.admin-header h1 small {
    font-size: 0.85rem;
    font-weight: 400;
}

/* Admin Navigation */
.admin-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-nav-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.admin-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.admin-nav-logout {
    color: var(--red);
}

.admin-nav-logout:hover {
    background: var(--red-dim);
    color: var(--red);
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.admin-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    transition: border-color var(--transition);
}

.admin-stat-card:hover {
    border-color: var(--accent-primary);
}

.admin-stat-number {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1;
    margin-bottom: 0.375rem;
}

.admin-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Grid Layout */
.admin-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Panel */
.admin-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.admin-panel h3 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* List Items */
.admin-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.9rem;
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-list-item a {
    color: var(--text-primary);
    font-weight: 500;
}

.admin-list-item a:hover {
    color: var(--accent-primary);
}

/* Badges */
.admin-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.admin-badge-published,
.admin-badge-active {
    background: var(--green-dim);
    color: var(--green);
}

.admin-badge-draft {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.admin-badge-archived {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.admin-badge-unread {
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
}

.admin-badge-coming_soon {
    background: var(--yellow-dim);
    color: var(--yellow);
}

/* Tables */
.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
}

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

.admin-table th {
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
}

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

.admin-table tr:hover td {
    background: var(--bg-tertiary);
}

.admin-table a {
    color: var(--accent-primary);
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Admin Form */
.admin-form {
    max-width: 800px;
}

.admin-editor {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    tab-size: 4;
}

/* Tag Checkboxes */
.tag-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.tag-checkbox input[type="checkbox"] {
    accent-color: var(--accent-primary);
}

/* Contact Messages */
.admin-message {
    margin-bottom: 1rem;
}

.admin-message-unread {
    border-color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
}

.admin-message-header {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.admin-message-subject {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.admin-message-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

.admin-message-actions {
    display: flex;
    gap: 0.5rem;
}

/* ─── Auth Form ─── */
.auth-form-container {
    max-width: 440px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
}

.auth-title {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-links {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-links a {
    color: var(--accent-primary);
}

.auth-links a:hover {
    text-decoration: underline;
}

.auth-links-divider {
    margin: 0 0.5rem;
    color: var(--border-primary);
}

/* ─── Role Selector ─── */
.role-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.role-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition);
}

.role-option:hover {
    border-color: var(--accent-primary);
}

.role-option input[type="radio"] {
    margin-top: 0.25rem;
    accent-color: var(--accent-primary);
}

.role-label {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.role-label strong {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.role-label small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── Dashboard Cards ─── */
.dashboard-card {
    display: block;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all var(--transition);
    text-decoration: none;
}

.dashboard-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.dashboard-card-header {
    margin-bottom: 0.75rem;
}

.dashboard-card-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.dashboard-card-stat {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ─── Platform Badges ─── */
.platform-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.platform-badge-ctf {
    background: rgba(0, 240, 255, 0.12);
    color: #00F0FF;
}

.platform-badge-code {
    background: rgba(168, 85, 247, 0.12);
    color: #A855F7;
}

.platform-badge-os {
    background: rgba(57, 255, 20, 0.12);
    color: #39FF14;
}

/* ─── Link Status Badges ─── */
.link-status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.link-status-pending {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.link-status-confirmed {
    background: var(--green-dim);
    color: var(--green);
}

.link-status-rejected {
    background: var(--red-dim, rgba(239, 68, 68, 0.15));
    color: var(--red);
}

/* ─── Progress Bar ─── */
.progress-bar-track {
    display: inline-block;
    width: 100%;
    max-width: 200px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 0;
}

/* ─── Navbar Auth ─── */
.navbar-link-logout {
    color: var(--red) !important;
}

.navbar-link-logout:hover {
    opacity: 0.8;
}

/* ═══════════════════════════════════════════
   Light Mode -- Glassmorphism & Polish
   Applies globally to all admin-styled pages
   ═══════════════════════════════════════════ */

/* Page background -- subtle gradient */
[data-theme="light"] .page-section,
[data-theme="light"] .admin-section {
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 50%, #f0f4f8 100%);
}

/* Glass panels */
[data-theme="light"] .admin-panel,
[data-theme="light"] .auth-form-container {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Glass stat cards */
[data-theme="light"] .admin-stat-card,
[data-theme="light"] .dashboard-card {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    transition: all 0.25s ease;
}

[data-theme="light"] .admin-stat-card:hover,
[data-theme="light"] .dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: rgba(8, 145, 178, 0.3);
}

/* Glass table wrapper */
[data-theme="light"] .admin-table-wrap {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Glass header bar */
[data-theme="light"] .admin-header {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Glass input fields */
[data-theme="light"] .admin-section input:not([type="radio"]):not([type="checkbox"]),
[data-theme="light"] .admin-section select,
[data-theme="light"] .admin-section textarea,
[data-theme="light"] .auth-form-container input:not([type="radio"]):not([type="checkbox"]),
[data-theme="light"] .auth-form-container select,
[data-theme="light"] .auth-form-container textarea {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-color: rgba(226, 232, 240, 0.8);
}

[data-theme="light"] .admin-section input:not([type="radio"]):not([type="checkbox"]):focus,
[data-theme="light"] .admin-section select:focus,
[data-theme="light"] .admin-section textarea:focus,
[data-theme="light"] .auth-form-container input:not([type="radio"]):not([type="checkbox"]):focus,
[data-theme="light"] .auth-form-container select:focus,
[data-theme="light"] .auth-form-container textarea:focus {
    border-color: #0891B2;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

/* ─── Text contrast on glass backgrounds ─── */
[data-theme="light"] .auth-subtitle {
    color: #475569;
}

[data-theme="light"] .auth-links {
    color: #64748B;
}

[data-theme="light"] .admin-section label,
[data-theme="light"] .auth-form-container label {
    color: #1E293B;
    font-weight: 500;
}

[data-theme="light"] .role-label small {
    color: #475569;
}

[data-theme="light"] .admin-panel h3 {
    color: #0F172A;
}

[data-theme="light"] .admin-panel p {
    color: #475569;
}

[data-theme="light"] .admin-list-item {
    color: #1E293B;
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .admin-list-item a {
    color: #0F172A;
}

[data-theme="light"] .admin-stat-label {
    color: #475569;
}

[data-theme="light"] .dashboard-card-title {
    color: #0F172A;
}

[data-theme="light"] .dashboard-card-stat {
    color: #475569;
}

[data-theme="light"] .admin-nav-link {
    color: #475569;
}

[data-theme="light"] .admin-header h1 {
    color: #0F172A;
}

[data-theme="light"] .admin-section small,
[data-theme="light"] .auth-form-container small {
    color: #64748B;
}

[data-theme="light"] .admin-table td {
    color: #1E293B;
}

[data-theme="light"] .admin-table th {
    color: #475569;
    background: rgba(241, 245, 249, 0.6);
}

/* Badge contrast for light mode */
[data-theme="light"] .platform-badge-ctf {
    color: #0891B2;
    background: rgba(8, 145, 178, 0.12);
}

[data-theme="light"] .platform-badge-code {
    color: #7C3AED;
    background: rgba(124, 58, 237, 0.12);
}

[data-theme="light"] .platform-badge-os {
    color: #059669;
    background: rgba(5, 150, 105, 0.12);
}

[data-theme="light"] .link-status-pending {
    color: #B45309;
    background: rgba(245, 158, 11, 0.15);
}

[data-theme="light"] .link-status-confirmed {
    color: #047857;
    background: rgba(34, 197, 94, 0.15);
}

/* Glass role selector */
[data-theme="light"] .role-option {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-color: rgba(226, 232, 240, 0.8);
}

[data-theme="light"] .role-option:hover {
    border-color: #0891B2;
    box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.08);
}

/* Button polish */
[data-theme="light"] .admin-section .btn-primary,
[data-theme="light"] .auth-form-container .btn-primary {
    background: #0891B2;
    color: #FFFFFF;
    border-color: #0891B2;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.2);
}

[data-theme="light"] .admin-section .btn-primary:hover,
[data-theme="light"] .auth-form-container .btn-primary:hover {
    background: #0E7490;
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

/* Flash messages on glass background */
[data-theme="light"] .flash {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ─── Dark mode glassmorphism for light-first pages ─── */
[data-theme="dark"] .light-first-page .page-section,
[data-theme="dark"] .light-first-page .admin-section {
    background: linear-gradient(135deg, #0A0E1A 0%, #111827 50%, #0A0E1A 100%);
}

[data-theme="dark"] .light-first-page .admin-panel,
[data-theme="dark"] .light-first-page .auth-form-container {
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .light-first-page .admin-stat-card,
[data-theme="dark"] .light-first-page .dashboard-card {
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .light-first-page .admin-stat-card:hover,
[data-theme="dark"] .light-first-page .dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border-color: rgba(0, 240, 255, 0.2);
}

[data-theme="dark"] .light-first-page .admin-table-wrap {
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .light-first-page .admin-header {
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .light-first-page .role-option {
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ─── 3-Column Grid ─── */
.admin-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* ─── 4-Column Grid ─── */
.admin-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

/* ─── Platform Health Dot ─── */
.health-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot-online {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.health-dot-offline {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

.health-dot-unconfigured {
    background: var(--text-muted);
}

/* Platform health cards */
.platform-health-card {
    min-height: 110px;
}

/* ─── Leaderboard ─── */
.leaderboard-section {
    padding-top: calc(var(--navbar-height) + 2rem);
    padding-bottom: 3rem;
    min-height: 100vh;
}

.leaderboard-header {
    text-align: center;
    margin-bottom: 2rem;
}

.leaderboard-header h1 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.leaderboard-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.leaderboard-rank {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    width: 3rem;
    text-align: center;
}

.leaderboard-medal-1 { color: #FFD700; }
.leaderboard-medal-2 { color: #C0C0C0; }
.leaderboard-medal-3 { color: #CD7F32; }

.leaderboard-pts {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.leaderboard-total {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* ─── Broadcast Banners ─── */
.broadcast-banners {
    position: fixed;
    top: var(--navbar-height, 60px);
    left: 0;
    right: 0;
    z-index: 999;
}

.broadcast-banner {
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.12) 0%, rgba(57, 255, 20, 0.08) 100%);
    border-bottom: 1px solid var(--accent-primary-dim);
    padding: 0.625rem 0;
    font-size: 0.85rem;
    color: var(--text-primary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.broadcast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.broadcast-close:hover {
    color: var(--text-primary);
}

[data-theme="light"] .broadcast-banner {
    background: linear-gradient(90deg, rgba(8, 145, 178, 0.08) 0%, rgba(5, 150, 105, 0.06) 100%);
    border-bottom-color: rgba(8, 145, 178, 0.15);
    color: #1E293B;
}

/* ─── Difficulty Badges ─── */
.admin-badge-beginner {
    background: var(--green-dim);
    color: var(--green);
}

.admin-badge-intermediate {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.admin-badge-advanced {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.admin-badge-expert {
    background: rgba(168, 85, 247, 0.15);
    color: #A855F7;
}

/* ─── Stage Builder ─── */
.stage-row {
    display: grid;
    grid-template-columns: 40px 1fr 120px 120px 1fr 80px 80px auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-primary);
}

.stage-row input,
.stage-row select {
    padding: 0.375rem 0.5rem;
    font-size: 0.85rem;
    border-radius: 4px;
    border: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.stage-handle {
    cursor: grab;
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.btn-remove-stage {
    background: none;
    border: 1px solid var(--red);
    color: var(--red);
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-remove-stage:hover {
    background: var(--red-dim, rgba(239, 68, 68, 0.15));
}

/* Responsive */
@media (max-width: 768px) {
    .admin-grid-2 {
        grid-template-columns: 1fr;
    }

    .admin-grid-3 {
        grid-template-columns: 1fr;
    }

    .admin-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .admin-grid-4 {
        grid-template-columns: 1fr;
    }
}
