/**
 * Frontend CSS for Dahua Camera Feed Plugin
 * Path: assets/css/frontend.css
 */

/* Camera Container */
.dcf-camera-container {
    position: relative;
    display: inline-block;
    width: 100%;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dcf-camera-container.dcf-responsive {
    width: 100%;
    max-width: 100%;
}

/* Video Player */
.dcf-video-player {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

/* Aspect Ratio Classes */
.dcf-aspect-16-9 {
    aspect-ratio: 16/9;
}

.dcf-aspect-4-3 {
    aspect-ratio: 4/3;
}

.dcf-aspect-1-1 {
    aspect-ratio: 1/1;
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 16/9) {
    .dcf-aspect-16-9::before {
        content: "";
        display: block;
        padding-bottom: 56.25%; /* 16:9 ratio */
    }
    
    .dcf-aspect-4-3::before {
        content: "";
        display: block;
        padding-bottom: 75%; /* 4:3 ratio */
    }
    
    .dcf-aspect-1-1::before {
        content: "";
        display: block;
        padding-bottom: 100%; /* 1:1 ratio */
    }
    
    .dcf-camera-container .dcf-video-player {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* Loading State */
.dcf-camera-container.dcf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.dcf-loading-spinner {
    text-align: center;
    color: #fff;
    z-index: 10;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 8px;
}

.dcf-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: dcf-spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

/* Error State */
.dcf-camera-container.dcf-error {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: #fff;
    min-height: 200px;
}

.dcf-error-message {
    text-align: center;
    padding: 20px;
    z-index: 10;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    border: 2px solid #d63638;
}

.dcf-error-message p {
    margin: 0 0 15px 0;
    color: #fff;
}

.dcf-retry-btn {
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.dcf-retry-btn:hover {
    background: #005a87;
}

/* Overlay Text */
.dcf-overlay-text {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 5;
    pointer-events: none;
}

/* Authentication Messages */
.dcf-auth-required,
.dcf-insufficient-permissions,
.dcf-no-camera,
.dcf-camera-not-found {
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    color: #666;
    margin: 20px 0;
}

.dcf-auth-required {
    border-color: #0073aa;
    background: #e7f3ff;
}

.dcf-insufficient-permissions {
    border-color: #d63638;
    background: #ffe7e7;
}

/* Divi Module Specific Styles */
.dcf-divi-camera-module {
    position: relative;
    width: 100%;
}

.dcf-divi-camera-module.dcf-responsive {
    max-width: 100%;
}

/* Video.js Customizations */
.dcf-camera-container .video-js {
    width: 100% !important;
    height: 100% !important;
}

.dcf-camera-container .video-js .vjs-control-bar {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.dcf-camera-container .video-js .vjs-big-play-button {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #fff;
    border-radius: 50%;
}

.dcf-camera-container .video-js .vjs-big-play-button:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* VLC Plugin Styles */
.dcf-camera-container object,
.dcf-camera-container embed {
    width: 100%;
    height: 100%;
    background: #000;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dcf-camera-container {
        border-radius: 0;
    }
    
    .dcf-overlay-text {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .dcf-loading-spinner,
    .dcf-error-message {
        padding: 15px;
        font-size: 14px;
    }
    
    .dcf-spinner {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .dcf-overlay-text {
        position: static;
        background: rgba(0, 0, 0, 0.9);
        margin: 0;
        border-radius: 0 0 4px 4px;
        text-align: center;
    }
    
    .dcf-loading-spinner,
    .dcf-error-message {
        padding: 10px;
        font-size: 12px;
    }
}

/* Print Styles */
@media print {
    .dcf-camera-container {
        background: #f9f9f9;
        border: 1px solid #ccc;
    }
    
    .dcf-camera-container::after {
        content: "Camera feed not available in print";
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #f9f9f9;
        color: #666;
        font-size: 16px;
    }
    
    .dcf-video-player {
        display: none;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .dcf-camera-container {
        border: 2px solid;
    }
    
    .dcf-loading-spinner {
        background: black;
        color: white;
        border: 2px solid;
    }
    
    .dcf-error-message {
        background: black;
        color: white;
        border: 2px solid;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .dcf-spinner {
        animation: none;
    }
    
    .dcf-retry-btn,
    .dcf-camera-container * {
        transition: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dcf-auth-required,
    .dcf-insufficient-permissions,
    .dcf-no-camera,
    .dcf-camera-not-found {
        background: #2c2c2c;
        border-color: #555;
        color: #ddd;
    }
    
    .dcf-auth-required {
        background: #1a2332;
        border-color: #0073aa;
    }
    
    .dcf-insufficient-permissions {
        background: #321a1a;
        border-color: #d63638;
    }
}