/**
 * Sentry-Six Electron Styles
 * Modern, responsive design for Tesla dashcam viewer
 */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    user-select: none;
}

/* App Layout */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
    height: 60px;
    flex-shrink: 0;
}

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

.app-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.app-icon {
    width: 24px;
    height: 24px;
}

.app-subtitle {
    font-size: 12px;
    color: #888;
}

.header-center {
    display: flex;
    align-items: center;
}

.playback-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    background: #404040;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 16px;
}

.control-btn:hover {
    background: #505050;
}

.control-btn:active {
    background: #606060;
}

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

.timestamp-display {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    background: #1a1a1a;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #404040;
    min-width: 200px;
    text-align: center;
}

/* Main Content */
.app-main {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 200px;
    max-width: 340px;
    background: #232323;
    color: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #404040;
}

.sidebar-header h3 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #007acc;
    color: white;
}

.btn-primary:hover {
    background: #0066aa;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: #888;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #404040;
    border-top: 2px solid #007acc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.spinner.small {
  width: 18px;
  height: 18px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #0078d7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.clip-list {
    padding: 16px;
}

.no-clips-message {
    text-align: center;
    color: #888;
    padding: 24px;
}

.no-clips-message p {
    margin-bottom: 8px;
}

/* Video Section */
.video-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    flex: 1;
    background: #000;
    padding: 2px;
    min-height: 0; /* Allow grid to shrink */
    overflow: hidden; /* Prevent overflow */
}

.video-container {
    position: relative;
    background: #1a1a1a;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow container to shrink */
    height: 100%; /* Fill grid cell */
}

.video-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
}

.video-container:hover .video-header {
    opacity: 1;
}

.video-container.drag-over {
  outline: 3px dashed #0078d7;
  background: #e6f0fa;
  z-index: 2;
}
.video-container.dragging {
  opacity: 0.5;
  z-index: 3;
}

.camera-label {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.video-controls {
    display: flex;
    gap: 4px;
}

.video-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    color: #ffffff;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.video-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    cursor: grab;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

.video-player:active {
    cursor: grabbing;
}

/* Mirror Tesla cameras that are mirrored in the actual vehicle */
.video-container[data-camera="back"] .video-player,
.video-container[data-camera="left_repeater"] .video-player,
.video-container[data-camera="right_repeater"] .video-player {
    transform: scaleX(-1);
}

/* Ensure mirroring is preserved when zooming */
.video-container[data-camera="back"] .video-player[style*="scale"],
.video-container[data-camera="left_repeater"] .video-player[style*="scale"],
.video-container[data-camera="right_repeater"] .video-player[style*="scale"] {
    transform: scaleX(-1) scale(var(--zoom-level, 1));
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.video-status {
    color: #888;
    font-size: 14px;
    text-align: center;
}

/* Timeline */
.timeline-section {
    background: #2d2d2d;
    border-top: 1px solid #404040;
    padding: 12px 16px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Remove old .timeline-section full width if present */
#app > .timeline-section {
    display: none;
}

.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-label {
    font-size: 12px;
    font-weight: 600;
    color: #888;
}

.timeline-info {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #888;
}

.timeline-track {
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

.timeline-scrubber {
    width: 100%;
    height: 6px;
    background: #404040;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.timeline-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #007acc;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timeline-scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #007acc;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timeline-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Event Markers */
.event-marker {
    position: absolute;
    top: -8px;
    width: 20px;
    height: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    z-index: 10;
    transform: translateX(-50%);
    transition: transform 0.2s ease, filter 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    user-select: none;
}

.event-marker:hover {
    transform: translateX(-50%) scale(1.2);
    filter: brightness(1.2);
    z-index: 15;
}

.event-marker-sentry {
    /* Red exclamation mark for sentry events */
    filter: drop-shadow(0 0 3px rgba(255, 0, 0, 0.6));
}

.event-marker-user_interaction {
    /* Pointing hand for user interaction */
    filter: drop-shadow(0 0 3px rgba(0, 150, 255, 0.6));
}

.event-marker-default {
    /* Bell emoji for default events */
    filter: drop-shadow(0 0 3px rgba(255, 255, 0, 0.6));
}



.timeline-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.speed-control,
.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-control label,
.volume-control label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.speed-select {
    background: #404040;
    border: 1px solid #606060;
    border-radius: 4px;
    color: #ffffff;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.speed-select:focus {
    outline: none;
    border-color: #007acc;
}

.volume-slider {
    width: 80px;
    height: 4px;
    background: #404040;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #007acc;
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #007acc;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-content h2 {
    margin: 16px 0 8px;
    font-size: 24px;
    font-weight: 600;
}

.loading-content p {
    color: #888;
    font-size: 14px;
}

/* Clip Items */
.clip-item {
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.clip-item:hover {
    background: #353535;
    border-color: #505050;
}

.clip-item.active {
    background: #007acc;
    border-color: #0066aa;
}

.clip-item.active .clip-time,
.clip-item.active .clip-type {
    color: #ffffff;
}

.clip-time {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.clip-type {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.clip-cameras {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.camera-badge {
    background: #404040;
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
}

.camera-badge.available {
    background: #28a745;
}

/* Collapsible Sections */
.clip-section {
    margin-bottom: 8px;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #555555;
}

.section-header:hover {
    background: #454545;
}

/* Enhanced sticky header effect */
.section-header.sticky {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background: #404040;
}

/* Export Controls */
.export-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid #555555;
}

.export-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #4a4a4a;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 4px;
}

.export-btn:hover {
    background: #555555;
    transform: translateY(-1px);
}

.export-btn.secondary {
    background: #666666;
    color: #cccccc;
}

.export-btn.secondary:hover {
    background: #777777;
}

.export-btn.primary {
    background: #007acc;
    color: #ffffff;
}

.export-btn.primary:hover {
    background: #0066aa;
}

.export-btn:disabled {
    background: #333333;
    color: #666666;
    cursor: not-allowed;
    transform: none;
}

.export-btn.warning {
    background: #ff6b35;
    border-color: #ff6b35;
}

.export-btn.warning:hover {
    background: #ff5722;
    border-color: #ff5722;
}

/* Export Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2a2a2a;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #444444;
}

.modal-header h2 {
    margin: 0;
    color: #ffffff;
    font-size: 20px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #444444;
    background: #333333;
    border-radius: 0 0 8px 8px;
}

.export-section {
    margin-bottom: 24px;
}

.export-section h3 {
    margin: 0 0 12px 0;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
}

.export-range-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #333333;
    border-radius: 4px;
    color: #cccccc;
}

.quality-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quality-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #333333;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.quality-option:hover {
    background: #3a3a3a;
}

.quality-option input[type="radio"] {
    margin-top: 2px;
}

.quality-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quality-info strong {
    color: #ffffff;
    font-size: 14px;
}

.quality-info span {
    color: #cccccc;
    font-size: 12px;
}

/* Settings Row Layout */
.settings-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.settings-column {
    flex: 1;
    min-width: 0; /* Allows flex items to shrink below their content size */
}

.settings-column h3 {
    margin-bottom: 16px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
}

/* Hardware Acceleration Styles */
.hwaccel-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hwaccel-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #333333;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.hwaccel-option:hover {
    background: #3a3a3a;
}

.hwaccel-option.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hwaccel-option.disabled:hover {
    background: #333333;
}

.hwaccel-option input[type="checkbox"] {
    margin-top: 2px;
}

.hwaccel-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hwaccel-info strong {
    color: #ffffff;
    font-weight: 600;
}

.hwaccel-info span {
    color: #999999;
    font-size: 14px;
}

.hwaccel-info .gpu-detected {
    color: #4CAF50;
}

.hwaccel-info .gpu-not-detected {
    color: #f44336;
}

/* Hardware Acceleration Loading Spinner */
.hwaccel-status-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hwaccel-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #333333;
    border-top: 2px solid #4CAF50;
    border-radius: 50%;
    animation: hwaccel-spin 1s linear infinite;
    flex-shrink: 0;
}

.hwaccel-spinner.hidden {
    display: none;
}

@keyframes hwaccel-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive layout for smaller screens */
@media (max-width: 768px) {
    .settings-row {
        flex-direction: column;
        gap: 16px;
    }
}

/* Flexible Camera Layout System */
.camera-layout-container {
    display: flex;
    gap: 20px;
    background: #333333;
    border-radius: 6px;
    padding: 16px;
    min-height: 300px;
}

/* Free-form camera positioning canvas */
.camera-layout-canvas {
    flex: 1;
    background: #2a2a2a;
    border-radius: 4px;
    border: 2px dashed #555555;
    position: relative;
    min-height: 280px;
    min-width: 400px; /* Ensure minimum width for camera positioning */
    overflow: visible; /* Changed from hidden to visible to show positioned cameras */
}

.camera-layout-canvas.drag-over {
    border-color: #007acc;
    background: #2d3748;
}

.canvas-instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888888;
    text-align: center;
    font-size: 14px;
    pointer-events: none;
    opacity: 0.7;
}

.canvas-instructions.hidden {
    display: none;
}

/* Camera sidebar */
.camera-sidebar {
    width: 220px; /* Slightly wider to accommodate 2 columns */
    background: #3a3a3a;
    border-radius: 4px;
    padding: 12px;
}

.camera-sidebar h4 {
    margin: 0 0 12px 0;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
}

.camera-list {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 columns */
    grid-template-rows: repeat(3, 1fr); /* 3 rows */
    gap: 8px;
    height: 200px; /* Fixed height to maintain grid structure */
}

/* Camera items (both in sidebar and on canvas) */
.camera-item {
    background: #444444;
    border-radius: 4px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 55px;
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: grab;
    user-select: none;
    font-size: 12px; /* Smaller text for grid layout */
}

.camera-item:hover {
    background: #4a4a4a;
    border-color: #007acc;
}

.camera-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.camera-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Camera items positioned on canvas */
.camera-item.positioned {
    position: absolute;
    cursor: move;
    min-width: 100px; /* Increased from 80px for better visibility */
    min-height: 60px; /* Ensure minimum height */
    z-index: 10;
    display: flex; /* Ensure flex display is maintained */
    background: #444444; /* Ensure background color */
    border: 2px solid #007acc; /* Add border to make positioned cameras more visible */
}

.camera-item.positioned:hover {
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.3);
}

/* Drag feedback and snapping */
.snap-guide {
    position: absolute;
    background: rgba(0, 122, 204, 0.3);
    pointer-events: none;
    z-index: 5;
}

.snap-guide.horizontal {
    height: 1px;
    left: 0;
    right: 0;
}

.snap-guide.vertical {
    width: 1px;
    top: 0;
    bottom: 0;
}

.camera-item.snapping {
    box-shadow: 0 0 0 2px #007acc;
}

/* Drop zone indicators */
.drop-zone {
    position: absolute;
    border: 2px dashed #007acc;
    background: rgba(0, 122, 204, 0.1);
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

.camera-label {
    font-size: 11px;
    color: #cccccc;
    text-align: center;
    font-weight: 500;
}

.camera-export-toggle {
    transform: scale(1.2);
}

/* Timestamp Options */
.timestamp-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timestamp-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cccccc;
    cursor: pointer;
}

.timestamp-position {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cccccc;
}

.timestamp-position select {
    background: #444444;
    color: #ffffff;
    border: 1px solid #555555;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 12px;
}

/* Timelapse Options */
.timelapse-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timelapse-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cccccc;
    cursor: pointer;
}

.timelapse-toggle input[type="checkbox"] {
    transform: scale(1.1);
}

.timelapse-settings {
    margin-left: 24px;
    margin-top: 8px;
    padding: 12px;
    background: #333333;
    border-radius: 6px;
    border-left: 3px solid #007acc;
    position: relative;
    z-index: 1;
}

.timelapse-settings.hidden {
    display: none;
}

.timelapse-speed-selection {
    display: block; /* Changed from flex to block for vertical layout */
    margin-bottom: 12px;
    color: #cccccc;
    position: relative;
    z-index: 2;
}

.timelapse-speed-selection label {
    font-weight: 500;
    display: block; /* Label on its own line */
    margin-bottom: 6px; /* Space between label and dropdown */
}

.timelapse-speed-dropdown {
    width: 100%; /* Use full width of the column */
}

.timelapse-speed-selection select {
    background: #444444;
    color: #ffffff;
    border: 1px solid #555555;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    width: 100%; /* Use full width instead of fixed min-width */
    max-width: 100%; /* Prevent overflow */
    box-sizing: border-box; /* Include padding in width calculation */
}

.timelapse-speed-selection select:focus {
    outline: none;
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.timelapse-preview {
    margin-top: 12px;
    clear: both;
}

.timelapse-preview-text {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.3;
    padding: 8px 10px;
    border-radius: 4px;
    background-color: #f8f9fa;
    border: 1px solid #e1e5e9;
    white-space: pre-line;
    color: #495057;
    margin-top: 8px;
    box-sizing: border-box;
    width: 100%;
    display: block;
}

.timelapse-preview-text.success {
    background-color: #1e3a1e;
    border-color: #4caf50;
    color: #81c784;
}

.timelapse-preview-text.warning {
    background-color: #3a2e1e;
    border-color: #ff9800;
    color: #ffb74d;
}

/* Special styling when inside timelapse settings (dark theme) */
.timelapse-settings .timelapse-preview-text {
    background-color: #2a2a2a;
    border-color: #555555;
    color: #cccccc;
}

.timelapse-settings .timelapse-preview-text.success {
    background-color: #1e3a1e;
    border-color: #4caf50;
    color: #81c784;
}

.timelapse-settings .timelapse-preview-text.warning {
    background-color: #3a2e1e;
    border-color: #ff9800;
    color: #ffb74d;
}

.timelapse-preview small {
    color: #999999;
    font-style: italic;
    font-size: 12px;
}

/* Export Information */
.export-info {
    background: #333333;
    border-radius: 6px;
    padding: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    color: #cccccc;
    font-size: 14px;
}

.info-row:not(:last-child) {
    border-bottom: 1px solid #444444;
}

/* Export Progress */
.export-progress {
    background: #333333;
    border-radius: 6px;
    padding: 20px;
    margin-top: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 16px;
}

.progress-percentage {
    color: #007acc;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #444444;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007acc, #0099ff);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-info {
    color: #cccccc;
    font-size: 12px;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary {
    background: #007acc;
    color: #ffffff;
}

.btn.primary:hover {
    background: #0066aa;
}

.btn.secondary {
    background: #555555;
    color: #ffffff;
}

.btn.secondary:hover {
    background: #666666;
}

.btn:disabled {
    background: #333333;
    color: #666666;
    cursor: not-allowed;
}

/* Export Markers */
.export-marker {
    position: absolute;
    top: 0;
    width: 20px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: none;
    z-index: 20;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    transform: translateX(-50%);
}
.export-marker:active {
    cursor: grabbing;
}

.export-marker-start {
    color: #00ff00;
}

.export-marker-end {
    color: #ff4444;
}

.export-range-highlight {
    position: absolute;
    top: 0;
    height: 24px;
    background: rgba(0, 120, 215, 0.25);
    border-radius: 3px;
    z-index: 10;
    pointer-events: none;
}

.section-toggle {
    margin-right: 8px;
    font-size: 12px;
    transition: transform 0.2s;
}

.section-header.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-title {
    font-weight: 600;
    color: #ffffff;
    flex: 1;
}

.section-count {
    font-size: 11px;
    color: #cccccc;
    background: #555555;
    padding: 2px 6px;
    border-radius: 10px;
}

.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.section-content.collapsed {
    max-height: 0;
}

.section-content.expanded {
    max-height: none;
    overflow-y: auto;
    max-height: calc(100vh - 200px); /* Allow scrolling within viewport */
}

.date-group {
    margin: 4px 0;
}

.date-header {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    background: #2d2d2d;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.date-header:hover {
    background: #353535;
}

.date-toggle {
    margin-right: 6px;
    font-size: 10px;
    transition: transform 0.2s;
}

.date-header.collapsed .date-toggle {
    transform: rotate(-90deg);
}

.date-title {
    font-weight: 500;
    color: #e0e0e0;
    flex: 1;
}

.date-count {
    font-size: 10px;
    color: #aaaaaa;
}

.date-clips {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.date-clips.collapsed {
    max-height: 0;
}

.date-clips.expanded {
    max-height: 500px;
}

/* Date Items (Direct Selection) */
.date-item {
    padding: 12px 16px;
    margin: 4px 0;
    background: #2d2d2d;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.date-item:hover {
    background: #353535;
    border-color: #505050;
}

.date-item.active {
    background: #007acc;
    border-color: #0066aa;
}

.date-item.active .date-title,
.date-item.active .date-info {
    color: #ffffff;
}

.date-title {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 4px;
}

.date-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #aaaaaa;
}

.date-duration {
    font-weight: 500;
    color: #4CAF50;
}

.date-count {
    color: #888888;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .sidebar {
        width: 250px;
    }
}

@media (max-width: 900px) {
    .video-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, 1fr);
    }

    .sidebar {
        width: 200px;
    }

    .app-title {
        font-size: 16px;
    }

    .app-subtitle {
        display: none;
    }
}

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

::-webkit-scrollbar-track {
    background: #2d2d2d;
}

::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #505050;
}

/* Debug Panel Styles */
.debug-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 400px;
    max-height: 70vh;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 8px;
    z-index: 1000;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #333;
    border-bottom: 1px solid #555;
    border-radius: 8px 8px 0 0;
    color: #fff;
    font-weight: bold;
}

.debug-toggle {
    background: #ff4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
}

.debug-toggle:hover {
    background: #ff6666;
}

.debug-content {
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
    color: #ccc;
}

.debug-section {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(40, 40, 40, 0.8);
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
}

.debug-section h4 {
    margin: 0 0 8px 0;
    color: #4CAF50;
    font-size: 13px;
}

.debug-item {
    margin: 4px 0;
    padding: 2px 0;
}

.debug-label {
    color: #888;
    display: inline-block;
    width: 120px;
}

.debug-value {
    color: #fff;
}

.debug-gap {
    background: rgba(255, 68, 68, 0.2);
    border-left-color: #ff4444;
}

.debug-warning {
    color: #ffaa00;
}

.debug-error {
    color: #ff4444;
}

.debug-success {
    color: #4CAF50;
}

.debug-btn.active {
    background: #4CAF50;
    color: white;
}

.debug-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #555;
    display: flex;
    gap: 10px;
}

.debug-action-btn {
    background: #007acc;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    flex: 1;
}

.debug-action-btn:hover {
    background: #0066aa;
}



/* Camera Visibility Panel Styles */
.camera-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 300px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.camera-panel.hidden {
    display: none;
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid #444;
    position: relative;
}

.panel-header h3 {
    margin: 0;
    color: #fff;
    font-size: 16px;
}

.panel-content {
    padding: 20px;
}

.camera-toggles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.camera-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.camera-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.camera-toggle input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #666;
    border-radius: 3px;
    margin-right: 12px;
    position: relative;
    transition: all 0.2s;
}

.camera-toggle input[type="checkbox"]:checked + .checkmark {
    background-color: #4CAF50;
    border-color: #4CAF50;
}

.camera-toggle input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.camera-name {
    color: #fff;
    font-size: 14px;
    user-select: none;
}

.panel-actions {
    display: flex;
    gap: 10px;
}

.panel-btn {
    flex: 1;
    padding: 8px 16px;
    background: #444;
    border: 1px solid #666;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.panel-btn:hover {
    background: #555;
    border-color: #777;
}

.panel-btn:active {
    background: #333;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #fff;
}

/* Hidden camera styles */
.video-container.hidden-camera {
    display: none;
}

/* Adjust debug panel position when camera panel is open */
.debug-panel {
    right: 340px; /* Moved left to avoid camera panel */
}

/* Onboarding Modal Styles */
#onboarding-modal.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#onboarding-modal .modal-content {
  color: #222;
  background: #fff;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  padding: 24px 20px 16px 20px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.2);
  text-align: center;
  min-height: 220px;
}
#onboarding-modal .modal-header,
#onboarding-modal .modal-body,
#onboarding-modal .modal-footer {
  color: #222;
}
#onboarding-modal .modal-header h2 {
  color: #222;
  margin: 0;
}
#onboarding-modal .modal-body p,
#onboarding-modal .modal-body ul {
  color: #222;
  margin: 0 0 8px 0;
}
#onboarding-modal .modal-body ul {
  padding-left: 18px;
  text-align: left;
  display: inline-block;
}
#onboarding-modal .modal-footer {
  margin-top: 8px;
}
#onboarding-modal .btn.primary {
  background: #0078d7;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 20px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s;
}
#onboarding-modal .btn.primary:hover {
  background: #005fa3;
}
#onboarding-modal.dark .modal-content {
  background: #23272e;
  color: #f1f1f1;
}
#onboarding-modal.dark .modal-header,
#onboarding-modal.dark .modal-body,
#onboarding-modal.dark .modal-footer {
  color: #f1f1f1;
}
#onboarding-modal.dark .modal-header h2,
#onboarding-modal.dark .modal-body p,
#onboarding-modal.dark .modal-body ul {
  color: #f1f1f1;
}
#onboarding-modal.dark .btn.primary {
  background: #005fa3;
  color: #fff;
}
#onboarding-modal.dark .btn.primary:hover {
  background: #0078d7;
}
#onboarding-modal.dark label {
  color: #f1f1f1;
}
#onboarding-modal.dark .modal-footer {
  background: #181a20;
}

/* Event Tooltip Styles */
.event-tooltip {
    position: fixed;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 0;
    z-index: 2000;
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.event-tooltip.hidden {
    opacity: 0;
    pointer-events: none;
}

.event-tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.event-tooltip-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    background: #2d2d2d;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.event-tooltip-image::before {
    content: "📷";
    font-size: 24px;
    color: #666;
    position: absolute;
    z-index: 1;
}

.event-tooltip-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    position: relative;
    z-index: 2;
    background: #2d2d2d;
}

.event-tooltip-info {
    padding: 12px 15px;
    color: #fff;
}

.event-tooltip-reason {
    font-size: 13px;
    font-weight: 600;
    color: #4CAF50;
    margin-bottom: 6px;
    word-wrap: break-word;
}

.event-tooltip-time {
    font-size: 12px;
    color: #ccc;
    margin-bottom: 4px;
    font-family: 'Courier New', monospace;
}

.event-tooltip-location {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* Responsive adjustments for event markers */
@media (max-width: 900px) {
    .event-marker {
        width: 18px;
        height: 18px;
        font-size: 12px;
        top: -6px;
    }

    .event-tooltip {
        max-width: 250px;
    }

    .event-tooltip-image {
        height: 100px;
    }

    .event-tooltip-info {
        padding: 10px 12px;
    }

    .event-tooltip-reason {
        font-size: 12px;
    }

    .event-tooltip-time {
        font-size: 11px;
    }

    .event-tooltip-location {
        font-size: 10px;
    }
}

/* Duration Loading Indicator */
.duration-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.loading-content {
    background: #2d2d2d;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid #404040;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #404040;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #ffffff;
}

.loading-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
}

.loading-subtitle {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 20px;
    line-height: 1.4;
}

.loading-progress {
    margin-top: 16px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #404040;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    font-size: 12px;
    color: #888;
    font-family: 'Courier New', monospace;
}

/* Responsive adjustments for loading indicator */
@media (max-width: 600px) {
    .loading-content {
        padding: 24px;
        max-width: 320px;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
        margin-bottom: 20px;
    }

    .loading-title {
        font-size: 16px;
    }

    .loading-subtitle {
        font-size: 13px;
    }
}
