/* Webcam Viewer Styles */
.webcam-container {
    /* No internal max-width: the outer card wrapper (.webcam-viewer) decides
       how wide the viewer may get. This keeps the webcam image flush to the
       left/right edges of the card so no "white frame" sticks out on wide
       viewports. */
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.webcam-image-wrap {
    position: relative;
    background: #f5f5f4;
    /* No border-radius here — the outer card already rounds the corners via
       Tailwind `rounded-2xl overflow-hidden`. A second rounding would create a
       visible white gap between the card edge and the dark image. */
    border-radius: 0;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.webcam-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.webcam-image-wrap .loading {
    opacity: 0.85;
}

.webcam-weather {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 2rem 1.25rem 1.25rem;
    color: white;
}

.webcam-weather-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    font-size: 0.8125rem;
}

.webcam-weather-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.webcam-weather-icon {
    font-size: 1.125rem;
}

.webcam-weather-label {
    opacity: 0.8;
    font-size: 0.6875rem;
}

.webcam-time-display {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Timeline */
.webcam-timeline {
    margin-top: 1rem;
    padding: 0 0.5rem;
}

.webcam-day-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.webcam-day-tab {
    padding: 0.375rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid #d6d3d1;
    background: white;
    color: #57534e;
}

.webcam-day-tab:hover {
    background: #f5f5f4;
}

.webcam-day-tab.active {
    background: #2d5016;
    color: white;
    border-color: #2d5016;
}

/* Step buttons (prev / next) */
.webcam-step-btn {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid #d6d3d1;
    background: white;
    color: #57534e;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}
.webcam-step-btn:hover:not(:disabled) { background: #f5f5f4; }
.webcam-step-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Horizontal time-stripe timeline */
.webcam-track {
    position: relative;
    height: 64px;
    margin-top: 0.5rem;
    padding-top: 16px;       /* room for hour labels */
    padding-bottom: 4px;
    user-select: none;
    cursor: crosshair;
}

/* Tick marks: hour, half-hour, quarter-hour */
.webcam-tick {
    position: absolute;
    top: 16px;
    bottom: 4px;
    width: 1px;
    background: #d6d3d1;
    transform: translateX(-50%);
    pointer-events: none;
}
.webcam-tick--hour {
    width: 2px;
    background: #44403c;
    top: 16px;
}
.webcam-tick--half {
    background: #a8a29e;
    top: 26px;
}
.webcam-tick--quarter {
    background: #e7e5e4;
    top: 32px;
}
.webcam-tick-label {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 500;
    color: #78716c;
    line-height: 1;
}

/* Snapshot stripe — clickable & hoverable */
.webcam-snapshot-stripe {
    position: absolute;
    top: 16px;
    bottom: 4px;
    width: 4px;
    margin-left: -2px;
    background: rgba(45, 80, 22, 0.55);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, width 0.15s;
    border-radius: 1px;
}
.webcam-snapshot-stripe:hover,
.webcam-snapshot-stripe.hovered {
    background: #2d5016;
    width: 6px;
    margin-left: -3px;
}
.webcam-snapshot-stripe.active {
    background: #2d5016;
    width: 6px;
    margin-left: -3px;
    box-shadow: 0 0 0 2px rgba(45, 80, 22, 0.2);
}

/* Hover indicator: thin vertical line + floating time label */
.webcam-hover-indicator {
    position: absolute;
    top: 16px;
    bottom: 4px;
    width: 1px;
    background: #1c1917;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
}
.webcam-hover-label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    background: #1c1917;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .webcam-track { height: 56px; }
    .webcam-snapshot-stripe { width: 6px; margin-left: -3px; }
}

.webcam-no-data {
    text-align: center;
    padding: 3rem;
    color: #a8a29e;
    font-size: 0.875rem;
}

.webcam-auto-refresh {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.6875rem;
    color: #a8a29e;
}

/* ============================================================
   Timelapse Controls — Apple-Style
   Erscheint als zweite Zeile unter den Day-Tabs, wenn aktiv.
   ============================================================ */

/* Start-Button in der Day-Tab-Zeile */
.webcam-timelapse-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border: 1px solid #2d5016;
    background: #2d5016;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    margin-right: 0.5rem;
}
.webcam-timelapse-btn:hover {
    background: #234010;
    border-color: #234010;
    transform: translateY(-1px);
}
.webcam-timelapse-btn__icon {
    font-size: 0.6875rem;
}

/* Day-Tabs deaktiviert im Timelapse-Modus */
.webcam-day-tab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Kontrollleiste */
.webcam-timelapse-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f7 100%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    animation: webcamTlSlide 220ms cubic-bezier(.2,.8,.2,1);
}
@keyframes webcamTlSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

/* Play/Pause-Button (primär) */
.webcam-timelapse-play {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: #2d5016;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 150ms ease, background 150ms ease;
    box-shadow: 0 2px 6px rgba(45, 80, 22, 0.25);
}
.webcam-timelapse-play:hover:not(:disabled) {
    background: #234010;
    transform: scale(1.05);
}
.webcam-timelapse-play:disabled {
    background: #9ca3af;
    cursor: wait;
    box-shadow: none;
}

/* Status-Text + Progress-Bar */
.webcam-timelapse-status {
    flex: 1;
    min-width: 0;
}
.webcam-timelapse-status__main {
    font-size: 0.75rem;
    font-weight: 500;
    color: #1d1d1f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    letter-spacing: -0.005em;
}
.webcam-timelapse-progress {
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
}
.webcam-timelapse-progress__fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9a2f, #2d5016);
    transition: width 120ms linear;
    border-radius: 2px;
}

/* Geschwindigkeits-Segmented-Control */
.webcam-timelapse-speeds {
    display: inline-flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 2px;
    flex-shrink: 0;
}
.webcam-timelapse-speed {
    padding: 0.25rem 0.5rem;
    min-width: 34px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #3c3c43;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    line-height: 1;
}
.webcam-timelapse-speed:hover {
    color: #1d1d1f;
}
.webcam-timelapse-speed.active {
    background: #ffffff;
    color: #2d5016;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Custom-Speed-Eingabe */
.webcam-timelapse-speed--custom {
    position: relative;
    cursor: pointer;
    min-width: 42px;
    text-align: center;
}
.webcam-timelapse-speed__input {
    width: 44px;
    padding: 0 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid #2d5016;
    border-radius: 4px;
    background: #fff;
    color: #1d1d1f;
    outline: none;
    -moz-appearance: textfield;
}
.webcam-timelapse-speed__input::-webkit-inner-spin-button,
.webcam-timelapse-speed__input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Stop-Button (schließt den Modus) */
.webcam-timelapse-stop {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, 0.06);
    color: #3c3c43;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}
.webcam-timelapse-stop:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #1d1d1f;
}

/* Track deaktiviert im Timelapse-Modus (nur Anzeige, keine Interaktion) */
.webcam-track.is-timelapse {
    cursor: default;
    opacity: 0.8;
}
.webcam-track.is-timelapse .webcam-snapshot-stripe {
    pointer-events: none;
}

/* Playhead im Timelapse-Modus — zeigt die aktuelle Position animiert */
.webcam-timelapse-playhead {
    position: absolute;
    top: 14px;
    bottom: 2px;
    width: 2px;
    margin-left: -1px;
    background: #2d5016;
    border-radius: 1px;
    box-shadow: 0 0 0 3px rgba(74, 154, 47, 0.22), 0 0 10px rgba(74, 154, 47, 0.4);
    pointer-events: none;
    z-index: 6;
    transition: left 140ms linear;
}
.webcam-timelapse-playhead::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2d5016;
    box-shadow: 0 0 0 3px rgba(74, 154, 47, 0.25);
}

/* ============================================================
   Video-Download (MediaRecorder + Canvas, client-seitig)
   ============================================================ */

/* Download-Button in der Timelapse-Bar */
.webcam-timelapse-download {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: rgba(45, 80, 22, 0.08);
    color: #2d5016;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, transform 150ms ease, color 150ms ease;
}
.webcam-timelapse-download:hover:not(:disabled) {
    background: #2d5016;
    color: #ffffff;
    transform: scale(1.05);
}
.webcam-timelapse-download:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.webcam-timelapse-download svg {
    display: block;
}

/* Export-Overlay: Modal mittig über dem Viewer */
.webcam-export-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: webcamExpFade 220ms ease forwards;
}
@keyframes webcamExpFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.webcam-export-dialog {
    background: #ffffff;
    border-radius: 18px;
    max-width: 440px;
    width: 100%;
    padding: 1.5rem 1.5rem 1.25rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    animation: webcamExpPop 260ms cubic-bezier(.2,.8,.2,1);
    text-align: center;
}
@keyframes webcamExpPop {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to   { opacity: 1; transform: none; }
}
.webcam-export-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.015em;
    margin: 0 0 0.375rem 0;
}
.webcam-export-sub {
    font-size: 0.8125rem;
    color: #6e6e73;
    margin-bottom: 1.25rem;
    line-height: 1.45;
}
.webcam-export-progress {
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.webcam-export-progress__fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9a2f, #2d5016);
    border-radius: 3px;
    transition: width 160ms linear;
}
.webcam-export-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #3c3c43;
    margin-bottom: 1.25rem;
    font-variant-numeric: tabular-nums;
}
.webcam-export-mime {
    color: #6e6e73;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.webcam-export-error {
    color: #b91c1c;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    background: #fef2f2;
    border-radius: 8px;
    text-align: left;
}
.webcam-export-cancel {
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    border: 1px solid #d6d3d1;
    background: #ffffff;
    color: #3c3c43;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
}
.webcam-export-cancel:hover {
    background: #f5f5f4;
    border-color: #a8a29e;
}
.webcam-export-cancel--primary {
    background: #2d5016;
    color: #ffffff;
    border-color: #2d5016;
}
.webcam-export-cancel--primary:hover {
    background: #234010;
    border-color: #234010;
}

@media (max-width: 640px) {
    .webcam-export-dialog {
        padding: 1.25rem 1.25rem 1rem;
        border-radius: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .webcam-export-overlay,
    .webcam-export-dialog {
        animation: none !important;
    }
    .webcam-export-progress__fill {
        transition: none !important;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .webcam-timelapse-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .webcam-timelapse-status {
        order: -1;
        flex-basis: 100%;
    }
    .webcam-timelapse-speeds {
        gap: 1px;
    }
    .webcam-timelapse-speed {
        padding: 0.25rem 0.375rem;
        min-width: 28px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .webcam-timelapse-bar { animation: none; }
    .webcam-timelapse-play { transition: none; }
    .webcam-timelapse-progress__fill { transition: none; }
}
