/**
 * Master Application Stylesheet
 * 
 * Design System: DaisyUI 4.x + Tailwind CSS Architecture
 * Standards: ASD-STE100 Compliance, Strict Separation of Concerns, iOS Safari Safe-Area Insets
 */

/* =========================================================================
   1. DESIGN TOKENS & COLOR SYSTEM
   ========================================================================= */
:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-subtle: #f1f5f9;
    --text-main: #09090b;
    --text-muted: #475569;
    --border-color: #e2e8f0;
    --accent-brand: #d97706;
    --accent-brand-hover: #b45309;
    --accent-brand-subtle: rgba(217, 119, 6, 0.10);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html.dark {
    --bg-main: #09090b;
    --bg-card: #121215;
    --bg-card-subtle: #18181b;
    --text-main: #f8fafc;
    --text-muted: #a1a1aa;
    --border-color: #27272a;
    --accent-brand: #f59e0b;
    --accent-brand-hover: #d97706;
    --accent-brand-subtle: rgba(245, 158, 11, 0.12);
}

/* =========================================================================
   2. GLOBAL RESET & BASE TYPOGRAPHY
   ========================================================================= */
body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* iOS Safe Area Padding Helpers */
.header-safe {
    padding-top: max(0.75rem, var(--safe-top));
}

.footer-safe {
    padding-bottom: max(0.75rem, var(--safe-bottom));
}

/* =========================================================================
   3. SURFACE CARDS & LAYOUT UTILITIES
   ========================================================================= */
.surface-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
}

.surface-card-subtle {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
}

.status-badge {
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.consent-card {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card-subtle);
    border-radius: 1rem;
    padding: 1.25rem;
}

.group-header-label {
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--accent-brand);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.75rem;
    margin-bottom: 0.375rem;
    display: block;
}

/* =========================================================================
   4. BUTTONS & INTERACTIVE FORM CONTROLS
   ========================================================================= */
.cta-brand-btn {
    background-color: var(--accent-brand);
    color: #ffffff;
    font-weight: 800;
    border: none;
    transition: all 0.2s ease;
}

html.dark .cta-brand-btn {
    color: #09090b;
}

.cta-brand-btn:hover,
.cta-brand-btn:focus {
    background-color: var(--accent-brand-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

.interactive-card-label {
    cursor: pointer;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card-subtle);
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
}

.interactive-card-label:hover {
    border-color: var(--accent-brand);
    transform: translateY(-1px);
}

.interactive-card-selected {
    border-color: var(--accent-brand) !important;
    background-color: var(--accent-brand-subtle) !important;
}

.selectable-chip {
    cursor: pointer;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card-subtle);
    color: var(--text-main);
    padding: 0.5rem 0.875rem;
    border-radius: 0.75rem;
    font-weight: 700;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
}

.selectable-chip:hover {
    border-color: var(--accent-brand);
}

.selectable-chip-active {
    border-color: var(--accent-brand) !important;
    background-color: var(--accent-brand) !important;
    color: #ffffff !important;
}

html.dark .selectable-chip-active {
    color: #09090b !important;
}

.slot-card-btn {
    cursor: pointer;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card-subtle);
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 56px;
}

.slot-card-btn:hover {
    border-color: var(--accent-brand);
    transform: translateY(-1px);
}

.slot-card-selected {
    border-color: var(--accent-brand) !important;
    background-color: var(--accent-brand-subtle) !important;
}

.slot-card-disabled {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* =========================================================================
   5. CANVAS & VECTOR ANNOTATION TOOLS
   ========================================================================= */
.canvas-container {
    position: relative;
    width: 100%;
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    overflow: hidden;
    touch-action: none;
}

#annotation-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    touch-action: none;
}

.tool-btn {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 700;
    border-radius: 0.5rem;
    padding: 0.375rem 0.75rem;
    transition: all 0.2s ease;
}

.tool-btn-active {
    border-color: var(--accent-brand) !important;
    background-color: var(--accent-brand-subtle) !important;
    color: var(--accent-brand) !important;
}

.color-dot-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.color-dot-btn-active {
    transform: scale(1.15);
    border-color: var(--text-main) !important;
}

.color-red {
    background-color: #ef4444;
}

.color-amber {
    background-color: #f59e0b;
}

/* =========================================================================
   6. AUDIO RECORDER & WAVEFORM VISUALIZER
   ========================================================================= */
.record-btn-trigger {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 9999px;
    background-color: #ef4444;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.4);
    transition: all 0.2s ease;
    cursor: pointer;
    margin: 0 auto;
}

.record-btn-trigger:hover {
    transform: scale(1.05);
    background-color: #dc2626;
}

.waveform-canvas-box {
    width: 100%;
    height: 72px;
    background-color: #0f172a;
    border-radius: 0.75rem;
    overflow: hidden;
}

#voice-waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================================
   7. VIDEO CAPTURE & OPTICAL AR RETICLES
   ========================================================================= */
.video-viewport-box,
.viewfinder-box {
    position: relative;
    width: 100%;
    height: 320px;
    background-color: #0f172a;
    border-radius: 1.25rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-feed,
#video-playback-preview,
#live-camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.record-video-trigger {
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 9999px;
    background-color: #ef4444;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.4);
    transition: all 0.2s ease;
    cursor: pointer;
    border: 4px solid #ffffff;
    margin: 0 auto;
}

.record-video-trigger:hover {
    transform: scale(1.05);
    background-color: #dc2626;
}

.record-video-stop {
    border-radius: 1rem !important;
    background-color: #1e293b !important;
    transform: scale(0.95);
}

.camera-overlay-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
    backdrop-filter: blur(8px);
    background-color: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.camera-timer-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    backdrop-filter: blur(8px);
    background-color: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-family: monospace;
    font-size: 0.875rem;
    font-weight: 800;
}

/* Optical Calibration Guides */
.reticle-guideline {
    position: absolute;
    border: 2px dashed rgba(245, 158, 11, 0.75);
    border-radius: 0.5rem;
    pointer-events: none;
    z-index: 10;
}

.reticle-card-guide {
    bottom: 2rem;
    left: 2rem;
    width: 100px;
    height: 63px;
    background-color: rgba(245, 158, 11, 0.15);
}

.reticle-door-guide {
    top: 1.5rem;
    right: 2rem;
    width: 150px;
    height: 280px;
    border-color: rgba(2, 132, 199, 0.75);
    background-color: rgba(2, 132, 199, 0.1);
}

.step-pill {
    padding: 0.375rem 0.75rem;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card-subtle);
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.step-pill-active {
    border-color: var(--accent-brand) !important;
    background-color: var(--accent-brand-subtle) !important;
    color: var(--accent-brand) !important;
    font-weight: 800 !important;
}

/* =========================================================================
   8. GEOLOCATION MAP & COMPLIANCE BOXES
   ========================================================================= */
.map-display-box {
    position: relative;
    width: 100%;
    height: 220px;
    background-color: #e2e8f0;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.dark .map-display-box {
    background-color: #1e293b;
}

.compliance-box-insurance {
    border: 1px solid #fecaca;
    background-color: #fef2f2;
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
}

html.dark .compliance-box-insurance {
    border-color: rgba(239, 68, 68, 0.4);
    background-color: rgba(69, 10, 10, 0.3);
}

.modal-screen-blur {
    backdrop-filter: blur(8px);
    background-color: rgba(9, 9, 11, 0.75);
}

/* =========================================================================
   9. KEYFRAME ANIMATIONS
   ========================================================================= */
@keyframes ringPulse {
    0% {
        transform: scale(0.96);
        box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.6);
    }
    70% {
        transform: scale(1.04);
        box-shadow: 0 0 0 12px rgba(217, 119, 6, 0);
    }
    100% {
        transform: scale(0.96);
        box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
    }
}

.ring-pulse-brand {
    animation: ringPulse 2s infinite ease-in-out;
}

@keyframes recordPulse {
    0% {
        transform: scale(0.96);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    }
    70% {
        transform: scale(1.06);
        box-shadow: 0 0 0 16px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(0.96);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.record-active-pulse {
    animation: recordPulse 1.6s infinite ease-in-out;
}

@keyframes videoPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 16px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.video-recording-pulse {
    animation: videoPulse 1.5s infinite ease-in-out;
}