/* Reset e base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.icon {
    font-size: 1.2em;
    margin-right: 0.5rem;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* App Container */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Connection Status */
.connection-status {
    background: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.connection-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f44336;
}

.connection-indicator.online {
    background: #4caf50;
}

.connection-indicator.lan {
    background: #2196f3;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Video Container */
.video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    aspect-ratio: 16/9;
    max-height: 70vh;
}

.video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(45deg, #333, #555);
    color: white;
    text-align: center;
}

.placeholder-content h3 {
    margin: 1rem 0 0.5rem;
    font-size: 1.5rem;
}

.placeholder-icon {
    font-size: 4rem;
    opacity: 0.7;
}

.video-stream {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Video Controls */
.video-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-icon {
    padding: 0.75rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #333;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-control {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    min-width: 44px;
    min-height: 44px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-control:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Error Message */
.error-message {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    margin-top: 2rem;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.error-content h3 {
    color: #f44336;
    margin-bottom: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #2196f3;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.875rem;
}

.config-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.config-actions .btn {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
}

.toast {
    background: #333;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #4caf50;
}

.toast.error {
    background: #f44336;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 0.75rem;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .video-container {
        border-radius: 8px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }

    .config-actions {
        flex-direction: column;
    }

    .config-actions .btn {
        flex: none;
    }
}

/* Fullscreen styles */
.video-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1500;
    border-radius: 0;
    aspect-ratio: unset;
    max-height: unset;
}

.video-container.fullscreen .video-stream {
    object-fit: cover;
}

/* Landscape orientation for mobile */
@media screen and (orientation: landscape) and (max-width: 768px) {
    .video-container.fullscreen .video-stream {
        object-fit: contain;
    }

    .header {
        display: none;
    }

    .connection-status {
        display: none;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-icon {
        padding: 1rem;
    }

    .video-controls {
        padding: 1rem;
        gap: 1rem;
    }

    .btn-control {
        min-width: 50px;
        min-height: 50px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .video-container {
        -webkit-overflow-scrolling: touch;
    }

    .video-stream {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    .video-container.fullscreen {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 9999;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .loading-spinner {
        border-width: 2px;
    }

    .connection-indicator {
        width: 8px;
        height: 8px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
    }

    .btn {
        transition: none;
    }

    .toast {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #2c2c2c;
        color: white;
    }

    .form-group input {
        background: #3c3c3c;
        border-color: #555;
        color: white;
    }

    .form-group input:focus {
        border-color: #2196f3;
    }

    .btn-secondary {
        background: #3c3c3c;
        color: white;
    }
}
