/* ============================================================================
 * AI Detection Overlay - Styling
 * Created: 2026-01-22
 * Purpose: Visual styling for AI detection overlays on security and printer cameras
 * Matches existing glassmorphism design from dashboard.html
 * ============================================================================ */

/* Detection Overlay Container */
.ai-detection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

/* SVG Canvas for Bounding Boxes */
.detection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Bounding Box for Person Detection */
.detection-box {
    fill: none;
    stroke: #4a9eff;
    stroke-width: 2;
    opacity: 0.8;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 4px rgba(74, 158, 255, 0.6));
}

.detection-box.high-confidence {
    stroke: #4caf50;
    filter: drop-shadow(0 0 4px rgba(76, 175, 80, 0.6));
}

.detection-box.medium-confidence {
    stroke: #ffeb3b;
    filter: drop-shadow(0 0 4px rgba(255, 235, 59, 0.6));
}

.detection-box.low-confidence {
    stroke: #f44336;
    filter: drop-shadow(0 0 4px rgba(244, 67, 54, 0.6));
}

/* Detection Label */
.detection-label {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    border: 1px solid rgba(74, 158, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    white-space: nowrap;
    transition: all 0.3s ease;
    animation: fadeIn 0.3s ease-out;
}

.detection-label.high-confidence {
    border-color: rgba(76, 175, 80, 0.6);
}

.detection-label.medium-confidence {
    border-color: rgba(255, 235, 59, 0.6);
}

.detection-label.low-confidence {
    border-color: rgba(244, 67, 54, 0.6);
}

/* Detection Statistics Panel */
.detection-stats {
    position: absolute;
    top: 75px;
    right: 16px;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    font-size: 12px;
    color: #fff;
    min-width: 150px;
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.detection-stats.active {
    opacity: 1;
}

.detection-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 4px 0;
    gap: 12px;
}

.detection-stats-label {
    color: #999;
    font-size: 11px;
}

.detection-stats-value {
    font-weight: 600;
    color: #4a9eff;
}

.detection-stats-value.high {
    color: #4caf50;
}

.detection-stats-value.medium {
    color: #ffeb3b;
}

.detection-stats-value.low {
    color: #f44336;
}

/* Print Failure Detection Overlay */
.failure-detection-overlay {
    position: absolute;
    top: 75px;
    left: 16px;
    right: 16px;
    background: rgba(244, 67, 54, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 16px 20px;
    border-radius: 12px;
    border: 2px solid #f44336;
    box-shadow: 0 8px 32px rgba(244, 67, 54, 0.6),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 20;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.failure-detection-overlay.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.failure-detection-overlay.warning {
    background: rgba(255, 152, 0, 0.95);
    border-color: #ff9800;
    box-shadow: 0 8px 32px rgba(255, 152, 0, 0.6),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.failure-detection-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.failure-detection-icon {
    font-size: 28px;
    line-height: 1;
    animation: pulse 1.5s ease-in-out infinite;
}

.failure-detection-title {
    flex: 1;
    font-size: 16px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.failure-detection-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto;
}

.failure-detection-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.failure-detection-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.failure-detection-type {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
}

.failure-confidence-meter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.failure-confidence-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    min-width: 70px;
}

.failure-confidence-bar-container {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.failure-confidence-bar {
    height: 100%;
    background: linear-gradient(90deg, #fff 0%, #fff 100%);
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.failure-confidence-value {
    font-size: 14px;
    font-weight: 700;
    color: white;
    min-width: 45px;
    text-align: right;
}

.failure-auto-pause-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-top: 4px;
}

.failure-auto-pause-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s;
    pointer-events: auto;
}

.toggle-switch.active {
    background: #4caf50;
}

.toggle-switch-handle {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch.active .toggle-switch-handle {
    transform: translateX(22px);
}

/* AI Status Indicator (bottom-right corner) */
.ai-status-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(74, 158, 255, 0.3);
    font-size: 11px;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-status-indicator.active {
    opacity: 1;
}

.ai-status-dot {
    width: 6px;
    height: 6px;
    background: #4caf50;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.ai-status-dot.offline {
    background: #f44336;
    animation: none;
}

.ai-status-dot.connecting {
    background: #ff9800;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.95);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .detection-stats {
        top: 60px;
        right: 12px;
        padding: 8px 12px;
        min-width: 120px;
    }

    .failure-detection-overlay {
        top: 60px;
        left: 12px;
        right: 12px;
        padding: 12px 16px;
    }

    .failure-detection-title {
        font-size: 14px;
    }

    .failure-detection-icon {
        font-size: 24px;
    }
}

/* Hide overlay in fullscreen mode */
.camera-container:-webkit-full-screen .ai-detection-overlay {
    display: none;
}

.camera-container:-moz-full-screen .ai-detection-overlay {
    display: none;
}

.camera-container:fullscreen .ai-detection-overlay {
    display: none;
}
