/* Global Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --dark: #111827;
    --dark-secondary: #1f2937;
    --dark-tertiary: #374151;
    --light: #f9fafb;
    --light-secondary: #f3f4f6;
    --border: #d1d5db;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --success: #16a34a;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    width: 100%;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 1.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light-secondary);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2);
}

.status-dot.processing {
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.2);
    animation: pulse 2s infinite;
}

.status-dot.error {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2);
}

/* Header Stream Control */
.header-stream-control {
    flex: 1;
}

.header-input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.header-stream-control #streamUrl,
.header-stream-control #description {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    background: var(--light);
    transition: all 0.3s ease;
    outline: none;
    min-width: 200px;
}

.header-stream-control #streamUrl:focus,
.header-stream-control #description:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: white;
}

.header-stream-control .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
    min-width: 140px;
}

/* Combobox Container for custom dropdown */
.combobox-container {
    position: relative;
    display: flex;
    flex: 1;
}

.combobox-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
}

.combobox-container:hover .combobox-arrow {
    color: var(--primary);
}

/* Hide default arrow in WebKit browsers */
.header-stream-control input::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* Dashboard Layout */
.dashboard {
    width: 100%;
    height: calc(100vh - 80px); /* Subtract header height */
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.btn-primary {
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: 180px;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}



/* Main Grid - New Layout */
.main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
    height: calc(100vh - 140px); /* Subtract header height */
    flex: 1;
}

/* Section Styles */
section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--light-secondary);
}

.section-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header i {
    color: var(--primary);
    font-size: 1.25rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--light-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

/* Video Section - Main Stream */
.video-section {
    grid-column: 1;
    grid-row: 1;
}

.video-controls {
    display: flex;
    gap: 0.5rem;
}

.video-container {
    flex: 1;
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--dark);
    min-height: 300px;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--dark);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.video-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: white;
}

.overlay-content i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.overlay-content p {
    font-size: 1.125rem;
    opacity: 0.7;
}

/* Detection Events Section */
.detection-section {
    grid-column: 1;
    grid-row: 2;
}

.detection-content {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
}

.detection-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detection-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--success);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.detection-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Detection thumbnail hover effect */
.detection-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.detection-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

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

.detection-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detection-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detection-description {
    color: var(--text-primary);
    line-height: 1.4;
    font-size: 0.875rem;
}

/* Current Frame Analysis */
.analysis-section {
    grid-column: 2;
    grid-row: 1;
}

.analysis-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.current-frame {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: 180px;
    background: var(--light-secondary);
}

#thumbnail {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
    background: var(--dark);
}

.frame-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--light-secondary);
}

.frame-placeholder i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.frame-placeholder.hidden {
    display: none;
}

/* Latest Description */
.current-description {
    flex: 1;
    background: var(--light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-height: 120px;
}

/* Stats Section */
.stats-section {
    grid-column: 3;
    grid-row: 1;
}

.stats-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-card {
    background: var(--light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Story Summary */
.story-section {
    grid-column: 2 / 4;
    grid-row: 2;
}

.story-content {
    flex: 1;
    background: var(--light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 300px;
}

/* Entry Styles - Simplified without animations */
.analysis-entry, .story-entry {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.entry-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.entry-content {
    color: var(--text-primary);
    line-height: 1.6;
}

/* No Data States */
.no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    height: 100%;
    min-height: 120px;
}

.no-data i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-data p {
    font-size: 0.875rem;
    line-height: 1.5;
}



/* Animations - Minimal and smooth */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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



/* Responsive Design */
@media (max-width: 1400px) {
    .main-grid {
        grid-template-columns: 2fr 1fr;
        grid-template-rows: auto auto auto auto;
    }
    
    .video-section {
        grid-column: 1;
        grid-row: 1;
    }
    
    .detection-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .analysis-section {
        grid-column: 2;
        grid-row: 1;
    }
    
    .stats-section {
        grid-column: 2;
        grid-row: 2;
    }
    
    .story-section {
        grid-column: 1 / 3;
        grid-row: 3;
    }
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto;
    }
    
    .video-section {
        grid-column: 1;
        grid-row: 1;
    }
    
    .detection-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .analysis-section {
        grid-column: 1;
        grid-row: 3;
    }
    
    .stats-section {
        grid-column: 1;
        grid-row: 4;
    }
    
    .story-section {
        grid-column: 1;
        grid-row: 5;
    }
}

@media (max-width: 768px) {
    .dashboard {
        padding: 1rem;
        gap: 1rem;
    }
    
    .header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-stream-control {
        max-width: none;
        width: 100%;
    }
    
    .header-input-wrapper {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn-primary {
        min-width: auto;
    }
    
    section {
        padding: 1rem;
    }
    
    .logo span {
        display: none;
    }
}

/* Dark theme support for system preference */
@media (prefers-color-scheme: dark) {
    .no-data {
        color: var(--text-secondary);
    }
}

        .user-section {
            display: flex;
            align-items: center;
            gap: 1.5rem;
        }
        
        .user-info {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 0.5rem 1rem;
            background: var(--light-secondary);
            border-radius: var(--radius-lg);
        }
        
        .username {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-primary);
        }
        
        .username i {
            color: var(--primary);
        }
        
        .logout-btn {
            width: 32px;
            height: 32px;
            border: none;
            background: var(--danger);
            color: white;
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .logout-btn:hover {
            background: #b91c1c;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
        }
        
        @media (max-width: 768px) {
            .user-section {
                flex-direction: column;
                gap: 1rem;
            }
            
            .username span {
                display: none;
            }
        }

/* Modal styles for full-size image viewing */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--primary-light);
}

.modal-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    backdrop-filter: blur(10px);
}

.modal-timestamp {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.modal-description {
    font-size: 1rem;
    color: white;
}

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