/* =============================================================
   Exambro v2 - Teacher Monitoring Dashboard
   Premium Dark Theme with Glassmorphism
   ============================================================= */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-danger: linear-gradient(135deg, #ef4444, #f97316);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Header --- */
#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo .version {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    vertical-align: super;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-live {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-live.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 15px rgba(16, 185, 129, 0.4); }
}

.header-right {
    display: flex;
    gap: 12px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 8px 20px;
    min-width: 80px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-alert { color: var(--accent-red); }
.stat-safe { color: var(--accent-green); }

/* --- Main Layout --- */
#app-main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    padding: 20px 28px;
    height: calc(100vh - 72px);
}

/* --- Panels --- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-glass);
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.search-input {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    width: 200px;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* --- Table --- */
.table-container {
    overflow-y: auto;
    max-height: calc(100vh - 160px);
}

#students-table {
    width: 100%;
    border-collapse: collapse;
}

#students-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
}

#students-table tbody tr {
    border-bottom: 1px solid var(--border-glass);
    cursor: pointer;
    transition: var(--transition);
}

#students-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

#students-table tbody tr.selected {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--accent-blue);
}

#students-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
}

.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 16px !important;
}

/* Status badges */
.status-safe {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-investigate {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    animation: blink 1.5s ease-in-out infinite;
}

.status-disqualified {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    animation: blink 0.8s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.risk-bar-fill {
    height: 6px;
    border-radius: 3px;
    width: 60px;
    background: var(--bg-glass);
    overflow: hidden;
}

.risk-bar-fill-inner {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background 0.5s ease;
}

/* Action buttons */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    margin-right: 4px;
}

.btn-action:hover {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.3);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-danger:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-cancel {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

/* --- Right Panel --- */
.panel-details {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
}

.detail-card {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-glass);
}

.detail-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Screenshot */
.screenshot-placeholder {
    background: var(--bg-glass);
    border: 1px dashed var(--border-glass);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screenshot-placeholder img {
    width: 100%;
    border-radius: 8px;
}

/* Event log */
.event-list {
    max-height: 200px;
    overflow-y: auto;
}

.event-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    background: var(--bg-glass);
    border-radius: 8px;
    font-size: 12px;
    transition: var(--transition);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.event-type {
    font-weight: 600;
    color: var(--text-primary);
}

.event-time {
    color: var(--text-muted);
    font-size: 11px;
}

.event-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 13px;
}

/* Heatmap */
.heatmap-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.heatmap-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.heatmap-label {
    font-size: 13px;
    font-weight: 500;
    min-width: 80px;
    color: var(--text-secondary);
}

.heatmap-bar {
    flex: 1;
    height: 24px;
    background: var(--bg-glass);
    border-radius: 6px;
    overflow: hidden;
}

.heatmap-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.heat-low { background: linear-gradient(90deg, #10b981, #34d399); }
.heat-medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.heat-high { background: linear-gradient(90deg, #ef4444, #f97316); }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 28px;
    min-width: 360px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    #app-main {
        grid-template-columns: 1fr;
    }
    .panel-details {
        max-height: none;
    }
}

/* --- Session Status Badges --- */
.session-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.session-not_active {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

.session-active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.session-in_progress {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.session-finished {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.session-warning_loss {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.4);
    animation: pulse-badge 1.5s ease-in-out infinite;
}

.session-force_close {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.session-normally_close {
    background: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* --- Row Animations --- */
.row-warning-loss {
    animation: blink-row 1.2s ease-in-out infinite;
    border-left: 3px solid var(--accent-orange) !important;
}

.row-force-close {
    background: rgba(239, 68, 68, 0.08) !important;
    border-left: 3px solid var(--accent-red) !important;
}

.row-normally-close {
    opacity: 0.6;
    border-left: 3px solid var(--accent-green) !important;
}

@keyframes blink-row {
    0%, 100% { background: rgba(249, 115, 22, 0.05); }
    50% { background: rgba(249, 115, 22, 0.15); }
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

/* --- Tabs & Management --- */
.tab-btn {
    background: var(--bg-glass);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    padding: 8px 16px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-primary);
    color: var(--accent-blue);
    border-bottom: 2px solid var(--accent-blue);
}

.switch-sm {
    width: 36px;
    height: 20px;
}
.switch-sm .slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}
.switch-sm input:checked + .slider:before {
    transform: translateX(16px);
}
