/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

/* Prevent the whole page from scrolling; panels will scroll individually */
body {
    overflow: hidden;
}

/* Dark Mode (Default) */
:root {
    --bg-primary: #1a1d2e;
    --bg-secondary: #22283a;
    --bg-tertiary: #2a3142;
    --accent-primary: #4a90e2;
    --accent-success: #00d9a3;
    --accent-warning: #ffc107;
    --accent-danger: #ff4757;
    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #3a4152;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Light Mode */
body.light-mode {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --accent-primary: #4a90e2;
    --accent-success: #00d9a3;
    --accent-warning: #ffc107;
    --accent-danger: #ff4757;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #d1d5db;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden; /* prevent whole page scroll; panels will scroll */
}

/* ===== Header ===== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    height: 72px;
}

.header-content {
    max-width: 1920px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.logo svg {
    color: var(--accent-primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Logo and Action Buttons Container */
.logo-and-actions {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* Header Action Buttons */
.header-action-buttons {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.header-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.header-action-btn:hover {
    color: var(--accent-primary);
}

.header-action-btn svg {
    flex-shrink: 0;
    stroke: currentColor;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* Header Actions Group (Theme Toggle + Settings) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10;
}

.theme-toggle:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
    stroke: var(--text-primary);
}

.theme-toggle .sun-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.theme-toggle .moon-icon {
    position: absolute;
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.light-mode .theme-toggle .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.light-mode .theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.date-range-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    flex-shrink: 1;
    min-width: 0;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.3s ease;
}

.date-input:hover {
    border-color: var(--accent-primary);
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.date-separator {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.filter-btn,
.clear-filter-btn {
    background: var(--accent-primary);
    border: none;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.clear-filter-btn {
    background: var(--accent-danger);
    padding: 0.5rem;
}

.clear-filter-btn:hover {
    background: #e63946;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 217, 163, 0.1);
    border: 1px solid var(--accent-success);
    border-radius: 2rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

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

.status-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}



/* ===== Main Container ===== */
.main-container {
    max-width: 1920px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 300px 300px;
    gap: 1.5rem;
    height: calc(100vh - 72px); /* full viewport minus header */
    overflow: hidden; /* prevent page scrolling */
}

/* ===== Panel Styles ===== */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.panel-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.count-badge {
    background: var(--accent-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar */
.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* ===== Left Panel - Unknown Faces ===== */
.unknown-panel .panel-header h2 svg {
    color: var(--accent-warning);
}

.unknown-panel .count-badge {
    background: var(--accent-warning);
}

.face-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    padding: 1rem;
    align-items: start;
}

.face-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.face-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-warning);
}

.face-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.face-card-info {
    padding: 0.75rem;
}

.face-card-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

/* Unknown Face Cards with Actions */
.unknown-face-card {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 0.75rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.unknown-face-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 193, 7, 0.3);
}

.unknown-face-card.critical-zone {
    border: 2px solid var(--accent-danger);
    background: rgba(255, 71, 87, 0.05);
}

.unknown-face-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.unknown-face-avatar {
    width: 100%;
    max-width: 100%;
    min-height: 140px;
    max-height: 200px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--accent-warning);
    background: var(--bg-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.unknown-face-avatar img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.unknown-face-card.critical-zone .unknown-face-avatar {
    border-color: var(--accent-danger);
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.5);
}

.unknown-face-actions-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.unknown-face-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.unknown-face-name-input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.unknown-face-name-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.unknown-face-name-input::placeholder {
    color: var(--text-muted);
}

.unknown-face-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.btn-approve,
.btn-reject {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-approve {
    background: var(--accent-success);
    color: white;
}

.btn-approve:hover {
    background: #00c291;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 217, 163, 0.4);
}

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

.btn-reject:hover {
    background: #e63946;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.btn-approve svg,
.btn-reject svg {
    width: 18px;
    height: 18px;
}

/* ===== Center Panel - Attendance ===== */
.center-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.attendance-panel .panel-header {
    flex-shrink: 0;
}

.attendance-content {
    padding: 1rem;
    overflow-y: auto;
}

/* Attendance Statistics */
.attendance-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    padding: 1.25rem 1rem;
    border-radius: 0.875rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:nth-child(1) {
    background: rgba(255, 182, 193, 0.5);
}

.stat-card:nth-child(1):hover {
    background: rgba(255, 182, 193, 0.6);
    transform: translateY(-2px);
}

.stat-card:nth-child(2) {
    background: rgba(230, 230, 250, 0.5);
}

.stat-card:nth-child(2):hover {
    background: rgba(230, 230, 250, 0.6);
    transform: translateY(-2px);
}

.stat-card:nth-child(3) {
    background: rgba(144, 238, 144, 0.5);
}

.stat-card:nth-child(3):hover {
    background: rgba(144, 238, 144, 0.6);
    transform: translateY(-2px);
}

.stat-card:hover {
    border-color: rgba(74, 144, 226, 0.25);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1;
}

/* Attendance Filters */
.attendance-filters {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1rem;
}

.filters-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 120px;
}

.filter-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.filter-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.filter-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #3a7bc8;
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--accent-success);
    color: white;
}

.btn-success:hover {
    background: #00c291;
}

/* Attendance Table */
.attendance-table-container {
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    flex: 1;
    overflow-y: auto;
}

.attendance-table {
    width: 100%;
    border-collapse: collapse;
}

.attendance-table thead {
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.attendance-table th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.attendance-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.attendance-table tbody tr:hover {
    background: var(--bg-secondary);
}

.name-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.name-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.time-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.duration-cell {
    font-weight: 600;
    color: var(--accent-primary);
}

.status-badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 1.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-active {
    background: rgba(255, 193, 7, 0.25);
    color: #ffc107;
}

.status-completed {
    background: rgba(0, 217, 163, 0.25);
    color: #00d9a3;
}

.control-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

/* ===== Settings Dropdown ===== */
.settings-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 10000;
    display: none;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: block;
}

.dropdown-item {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.dropdown-item:hover svg {
    opacity: 1;
    stroke: var(--accent-primary);
}

/* Top settings button in header */
.header-settings {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: all 0.15s ease;
}

.header-settings:hover {
    background: rgba(255,255,255,0.02);
    transform: translateY(-2px);
}

/* ===== Right Panel - Detected Faces ===== */
.right-panel .panel-header h2 svg {
    color: var(--accent-success);
}

.right-panel .count-badge {
    background: var(--accent-success);
}

.face-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
}

.detected-face-card {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 0.65rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.detected-face-card:hover {
    background: rgba(74, 144, 226, 0.05);
    border-color: rgba(74, 144, 226, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.detected-face-card.critical-zone {
    border-left: 4px solid var(--accent-danger);
    background: rgba(255, 71, 87, 0.05);
}

.detected-face-card.critical-zone:hover {
    background: rgba(255, 71, 87, 0.1);
}

/* Expand Button (Chevron) */
.detected-face-expand-btn {
    position: absolute;
    top: 1rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 5;
}

.detected-face-expand-btn:hover {
    background: var(--bg-secondary);
    color: var(--accent-primary);
}

.detected-face-expand-btn svg {
    transition: transform 0.3s ease;
}

/* Expanded Content */
.detected-face-expanded-content {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    margin-top: 0;
}

.detected-face-card.expanded .detected-face-expanded-content {
    max-height: 300px;
    opacity: 1;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.expanded-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
}

.expanded-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.action-btn {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.action-btn.danger {
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

.action-btn.danger:hover {
    background: var(--accent-danger);
    color: white;
}

.critical-badge {
    display: inline-block;
    margin-right: 0.25rem;
    font-size: 1rem;
    animation: pulse-warning 2s ease-in-out infinite;
}

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

.detected-face-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--accent-success);
    overflow: hidden;
}

.detected-face-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detected-face-avatar svg {
    color: var(--accent-success);
    width: 30px;
    height: 30px;
}

.detected-face-info {
    flex: 1;
    min-width: 0;
    padding-right: 2.5rem;
}

.detected-face-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detection-count {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent-primary);
    margin-left: 0.25rem;
}

.detected-face-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

/* Grouped Detections Container */
.detected-face-group {
    margin-bottom: 0.35rem;
}

/* Other Detections (Collapsed by default) */
.other-detections {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Detection Summary Section */
.detection-summary {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0.5rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.8rem;
}

.summary-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.summary-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-value {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

/* Detections List Container */
.detections-list {
    margin-top: 0.5rem;
}

/* Compact Detection Card */
.compact-detection {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-success);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem auto 0 auto;
    max-width: 90%;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.compact-detection:hover {
    background: rgba(0, 217, 163, 0.05);
    transform: scale(1.02);
}

.compact-detection.critical-zone {
    border-left-color: var(--accent-danger);
    background: rgba(255, 71, 87, 0.03);
}

.compact-detection-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--accent-success);
    overflow: hidden;
}

.compact-detection-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.compact-detection-avatar svg {
    color: var(--accent-success);
}

.compact-detection.critical-zone .compact-detection-avatar {
    border-color: var(--accent-danger);
}

.compact-detection.critical-zone .compact-detection-avatar svg {
    color: var(--accent-danger);
}

.compact-detection-info {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

.compact-detection-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    text-align: center;
}

.critical-badge-small {
    font-size: 0.8rem;
    margin-right: 0.25rem;
}

.detected-face-confidence {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    white-space: nowrap;
}

.confidence-high {
    background: rgba(0, 217, 163, 0.2);
    color: var(--accent-success);
}

.confidence-medium {
    background: rgba(255, 193, 7, 0.2);
    color: var(--accent-warning);
}

.confidence-low {
    background: rgba(255, 71, 87, 0.2);
    color: var(--accent-danger);
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.875rem;
}

/* ===== Floating Action Button ===== */
/* Floating action button removed */

/* ===== Responsive Design ===== */
@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 1fr 280px 280px;
    }
    
    .date-range-filter {
        padding: 0.5rem;
    }
    
    .date-input {
        font-size: 0.7rem;
        padding: 0.3rem 0.4rem;
    }
    
    .attendance-stats {
        gap: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 1200px) {
    .header-status {
        gap: 0.75rem;
    }
    
    .date-range-filter {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem;
    }
    
    .logo-and-actions {
        gap: 1rem;
    }
    
    .header-action-buttons {
        gap: 1rem;
    }
    
    .header-action-btn span {
        display: none;
    }
    
    .attendance-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        overflow-y: auto;
    }
    
    .center-panel {
        order: 1;
        min-height: 400px;
        max-height: 500px;
    }
    
    .right-panel {
        order: 2;
        max-height: 400px;
    }
    
    .unknown-panel {
        order: 3;
        max-height: 400px;
    }
    
    .face-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .attendance-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .logo-and-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .header-action-buttons {
        gap: 1rem;
    }
    
    .header-status {
        gap: 1rem;
    }
    
    .main-container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .center-panel {
        min-height: 350px;
    }
    
    .face-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .attendance-stats {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem 0.5rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .filters-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .attendance-table-container {
        overflow-x: auto;
    }
    
    .attendance-table {
        min-width: 500px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1rem;
    }
    
    .status-indicator,
    .fps-counter {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .panel-header {
        padding: 1rem;
    }
    
    .panel-header h2 {
        font-size: 0.875rem;
    }
    
    .face-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .attendance-stats {
        grid-template-columns: 1fr;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.face-card,
.detected-face-card {
    animation: fadeIn 0.3s ease;
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Notification Toast ===== */
.notification-toast {
    position: fixed;
    top: 100px;
    right: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 10000;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.notification-toast.hiding {
    animation: slideOutRight 0.3s ease;
}

.notification-toast.success {
    border-left: 4px solid var(--accent-success);
}

.notification-toast.error {
    border-left: 4px solid var(--accent-danger);
}

.notification-toast.info {
    border-left: 4px solid var(--accent-primary);
}

.notification-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.notification-icon.success {
    color: var(--accent-success);
}

.notification-icon.error {
    color: var(--accent-danger);
}

.notification-icon.info {
    color: var(--accent-primary);
}

.notification-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}


/* ===== Image Viewer Modal ===== */
.image-viewer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.image-viewer-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.image-viewer-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10000;
    animation: zoomIn 0.3s ease;
}

.image-viewer-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10001;
}

.image-viewer-close:hover {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
    color: white;
    transform: rotate(90deg);
}

#image-viewer-img {
    max-width: 90vw;
    max-height: 70vh;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 3px solid var(--border-color);
    object-fit: contain;
}

.image-viewer-info {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    margin-top: 1rem;
    min-width: 300px;
    box-shadow: var(--shadow-md);
}

.image-viewer-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.image-viewer-info-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.image-viewer-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.image-viewer-value {
    color: var(--text-primary);
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Make avatars clickable */
.clickable-image {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.clickable-image:hover {
    transform: scale(1.08);
}
