/**
 * Face Search Modal Styles
 * MLAIS-94: Face-Based Search Upload
 */

/* =============================================
   Base Styles
   ============================================= */

body.iframe-mode {
    background: transparent;
}

body.iframe-mode header {
    display: none;
}

/* =============================================
   Progress Steps
   ============================================= */

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 3px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #9ca3af;
    transition: all 0.3s ease;
}

.step-circle.active {
    background: #fbbf24;
    border-color: #fbbf24;
    color: #1f2937;
}

.step-circle.completed {
    background: #000000;
    border-color: #000000;
    color: #fbbf24;
}

.step-label {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

/* =============================================
   Upload Zone
   ============================================= */

.upload-zone {
    border: 3px dashed #d1d5db;
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #fbbf24;
    background: #fffbeb;
}

.upload-zone.has-file {
    border-color: #10b981;
    background: #ecfdf5;
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: #9ca3af;
}

.upload-zone:hover .upload-icon,
.upload-zone.dragover .upload-icon {
    color: #fbbf24;
}

/* =============================================
   Image Preview
   ============================================= */

.image-preview-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    min-height: 200px;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 16px;
}

.image-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    object-fit: contain; /* Fix: prevent image squishing */
}

/* Button Section Background */
.button-section {
    background: linear-gradient(to bottom, transparent, #f9fafb);
    padding: 24px 0 0;
    margin-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.remove-image-btn:hover {
    transform: scale(1.1);
}

/* =============================================
   Canvas & Detection
   ============================================= */

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 16px;
    overflow: hidden;
}

.detection-canvas {
    max-width: 100%;
    max-height: 500px;
    width: auto !important;
    height: auto !important;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* =============================================
   Person Cards
   ============================================= */

.person-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
}

.person-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #fbbf24;
}

.person-face {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #fbbf24;
}

.score-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.score-high {
    background: #d1fae5;
    color: #065f46;
}

.score-medium {
    background: #fef3c7;
    color: #92400e;
}

.score-low {
    background: #fee2e2;
    color: #991b1b;
}

/* =============================================
   Quality Indicators
   ============================================= */

.quality-meter {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.quality-meter-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.quality-good .quality-meter-fill {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.quality-medium .quality-meter-fill {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.quality-poor .quality-meter-fill {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* =============================================
   Form Elements
   ============================================= */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-label .required {
    color: #ef4444;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    transition: all 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}

.form-control:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

/* =============================================
   Camera Selection
   ============================================= */

.camera-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
}

.camera-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.camera-option:hover {
    background: #f9fafb;
}

.camera-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: #fbbf24;
}

.camera-option.selected {
    background: #fffbeb;
}

/* =============================================
   Buttons
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #000000;
    color: #fbbf24;
}

.btn-primary:hover:not(:disabled) {
    background: #1f2937;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #d1d5db;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* =============================================
   Info Cards
   ============================================= */

.info-card {
    background: linear-gradient(135deg, #000000 0%, #1f2937 100%);
    border: 1px solid #fbbf24;
    border-radius: 12px;
    padding: 20px;
    color: white;
}

.info-card .label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-card .value {
    font-size: 20px;
    font-weight: 700;
    margin-top: 4px;
}

.info-card .value.highlight {
    color: #fbbf24;
    font-size: 28px;
}

/* =============================================
   Status Badges
   ============================================= */

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-success {
    background: #10b981;
    color: white;
}

.status-pending {
    background: #f59e0b;
    color: white;
}

.status-failed {
    background: #ef4444;
    color: white;
}

/* =============================================
   Loading & Spinners
   ============================================= */

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #fbbf24;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================
   Sidebar Content
   ============================================= */

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 16px;
}

.sidebar-prose {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
}

.sidebar-prose h4 {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 16px 0 8px;
}

.sidebar-prose ul {
    margin: 8px 0;
    padding-left: 20px;
}

.sidebar-prose li {
    margin: 4px 0;
}

.sidebar-prose code {
    font-size: 12px;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* =============================================
   Validation Messages
   ============================================= */

.validation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 14px;
}

.validation-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.validation-icon.pass {
    background: #d1fae5;
    color: #065f46;
}

.validation-icon.fail {
    background: #fee2e2;
    color: #991b1b;
}

.validation-icon.pending {
    background: #e5e7eb;
    color: #6b7280;
}

/* =============================================
   Cropping Guide Overlay
   ============================================= */

.crop-guide {
    position: absolute;
    border: 2px dashed #10b981;
    background: rgba(16, 185, 129, 0.1);
    pointer-events: none;
}

.crop-guide-label {
    position: absolute;
    top: -24px;
    left: 0;
    font-size: 12px;
    font-weight: 600;
    color: #10b981;
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
}

/* =============================================
   Results Section
   ============================================= */

.result-card {
    display: flex;
    gap: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.result-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-thumbnail {
    width: 80px;
    height: 80px;
    background: #e5e7eb;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #6b7280;
}

.result-details {
    flex: 1;
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 1024px) {
    .step-label {
        display: none;
    }

    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .upload-zone {
        padding: 32px 16px;
    }

    .person-card {
        flex-direction: column;
        text-align: center;
    }
}

/* =============================================
   Horizontal Calendar (Mi Camera Style)
   ============================================= */

.calendar-date {
    min-width: 64px;
    padding: 12px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.calendar-date:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);
}

.calendar-date .date-number {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
}

.calendar-date .date-weekday {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Available date (has recordings) */
.calendar-date.available {
    border-color: #fbbf24;
    background: #fffbeb;
}

.calendar-date.available:hover {
    background: #fef3c7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

/* Selected date */
.calendar-date.selected {
    background: #fbbf24;
    border-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
}

.calendar-date.selected .date-number {
    color: #000000;
}

.calendar-date.selected .date-weekday {
    color: #1f2937;
}

/* Disabled date (no recordings) */
.calendar-date.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #e5e7eb;
    background: #f9fafb;
}

.calendar-date.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Today dot indicator */
.today-dot {
    display: block;
    width: 6px;
    height: 6px;
    background: #000000;
    border-radius: 50%;
    margin: 4px auto 0;
}

.calendar-date.selected .today-dot {
    background: #1f2937;
}

/* Available dot indicator (green = has recordings) */
.available-dot {
    display: block;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    margin: 4px auto 0;
}

.calendar-date.selected .available-dot {
    background: #065f46;
}

/* Scrollbar styling for calendar container */
#calendar-container::-webkit-scrollbar {
    height: 6px;
}

#calendar-container::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

#calendar-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#calendar-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Small spinner for loading */
.spinner-sm {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #fbbf24;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* =============================================
   Duration Chips (Time Range Selection)
   ============================================= */

.duration-chip {
    padding: 10px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
    text-align: center;
}

.duration-chip:hover {
    border-color: #fbbf24;
    background: #fffbeb;
}

.duration-chip.selected {
    background: #fbbf24;
    border-color: #fbbf24;
    color: #000000;
}

.duration-chip:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);
}

/* Time Stepper Buttons */
.time-stepper-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-stepper-btn:hover {
    border-color: #fbbf24;
    background: #fffbeb;
}

.time-stepper-btn:active {
    background: #fbbf24;
    color: #000;
}

.time-stepper-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);
}

/* Time Display Input */
.time-display-input {
    width: 80px;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 18px;
    font-weight: 600;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px;
    background: white;
}

.time-display-input:focus {
    outline: none;
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

/* =============================================
   NVR Timeline - Industrial/Security Aesthetic
   ============================================= */

.nvr-timeline {
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border: 1px solid #374151;
    border-radius: 12px;
    padding: 16px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.nvr-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #374151;
}

.nvr-timeline-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #9ca3af;
    text-transform: uppercase;
}

.nvr-timeline-duration-badge {
    background: #fbbf24;
    color: #000000;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
}

.nvr-timeline-track {
    position: relative;
    padding: 8px 0;
}

.nvr-hour-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.nvr-hour-label {
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
}

.nvr-availability-row {
    display: flex;
    height: 32px;
    background: #1f2937;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.nvr-hour-block {
    flex: 1;
    height: 100%;
    border-right: 1px solid #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nvr-hour-block:last-child {
    border-right: none;
}

.nvr-hour-block.available {
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
}

.nvr-hour-block.available:hover {
    background: linear-gradient(180deg, #fcd34d 0%, #fbbf24 100%);
    transform: scaleY(1.1);
}

.nvr-hour-block.empty {
    background: #111827;
}

.nvr-density-row {
    display: flex;
    height: 20px;
    align-items: flex-end;
    margin-top: 4px;
}

.nvr-density-bar {
    flex: 1;
    margin: 0 1px;
    border-radius: 2px 2px 0 0;
    opacity: 0.7;
    min-height: 2px;
    transition: opacity 0.15s ease;
}

.nvr-density-bar:hover {
    opacity: 1;
}

.nvr-density-bar.density-high {
    background: #fbbf24;
}

.nvr-density-bar.density-medium {
    background: #f59e0b;
}

.nvr-density-bar.density-low {
    background: #92400e;
}

.nvr-selection-window {
    position: absolute;
    top: 0;
    height: 32px;
    background: rgba(251, 191, 36, 0.25);
    border: 2px solid #fbbf24;
    border-radius: 4px;
    pointer-events: none;
    transition: left 0.15s ease, width 0.15s ease;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.nvr-selection-window.invalid {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.nvr-timeline-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nvr-time-range {
    font-size: 16px;
    font-weight: 700;
    color: #fbbf24;
}

.nvr-separator {
    color: #4b5563;
}

.nvr-segment-count,
.nvr-camera-count {
    font-size: 12px;
    color: #9ca3af;
}

/* Loading state */
.nvr-timeline-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    color: #6b7280;
    font-size: 12px;
}

.nvr-timeline-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #374151;
    border-top-color: #fbbf24;
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

/* No data message */
.nvr-no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    color: #ef4444;
    font-size: 12px;
}

/* =============================================
   Upload Zone - Disabled State
   ============================================= */

.upload-zone-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
    background-color: #f9fafb !important;
}

.upload-zone-disabled:hover {
    border-color: #e5e7eb !important;
    background-color: #f9fafb !important;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .nvr-timeline {
        padding: 12px;
    }

    .nvr-availability-row {
        height: 40px;
    }

    .nvr-selection-window {
        height: 40px;
    }

    .nvr-density-row {
        height: 16px;
    }

    .nvr-timeline-footer {
        flex-direction: column;
        gap: 4px;
    }

    .nvr-separator {
        display: none;
    }
}

/* Touch-friendly on mobile */
@media (pointer: coarse) {
    .nvr-hour-block {
        min-height: 44px;
    }

    .nvr-availability-row {
        height: 44px;
    }

    .nvr-selection-window {
        height: 44px;
    }
}
