/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

/* Header Styles */
h2 {
    color: #2d3748;
    font-size: 1.8rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.muted {
    color: #718096;
    margin-bottom: 30px;
}

/* Row Layout */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

/* Card Styles */
.card {
    flex: 1;
    min-width: 300px;
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.card h3 {
    color: #2d3748;
    font-size: 1.3rem;
    margin-bottom: 20px;
}

/* Button Styles - FIXED */
button {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 10px;
    margin-bottom: 10px;
    display: inline-block;
    min-width: 120px;
}

button:hover {
    opacity: 0.9;
}

button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

#btnStart {
    background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
}

#btnStop {
    background: linear-gradient(90deg, #f56565 0%, #e53e3e 100%);
}

#btnLive {
    background: linear-gradient(90deg, #ed8936 0%, #dd6b20 100%);
}

/* Video Styles */
.video-container {
    position: relative;
    width: 100%;
    background: #1a202c;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    aspect-ratio: 4/3;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Form Elements */
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    margin-bottom: 15px;
    background: #f7fafc;
}

/* Result Styles */
.result {
    margin-top: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .app {
        padding: 20px;
        border-radius: 15px;
    }
    
    .card {
        min-width: 100%;
        padding: 20px;
    }
    
    button {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 15px;
    }
    
    .video-container {
        aspect-ratio: 3/4;
    }
}

/* Additional Enhancements */
/* Professional Button Styles */
.primary-button {
    background: linear-gradient(90deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  
  .success-button {
    background: linear-gradient(90deg, #27ae60 0%, #219653 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  
  .danger-button {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  
  .warning-button {
    background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  
  .primary-button:hover, .success-button:hover, .danger-button:hover, .warning-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  }
  
  .primary-button:active, .success-button:active, .danger-button:active, .warning-button:active {
    transform: translateY(0);
  }
  
  .primary-button:disabled, .success-button:disabled, .danger-button:disabled, .warning-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }
  
  /* Video container for professional look */
  .video-container {
    position: relative;
    width: 100%;
    background: #1a202c;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 3px solid #e2e8f0;
    aspect-ratio: 4/3;
  }
  
  .video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  
  /* Professional input styling */
  input[type="file"] {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 10px;
  }
  
  input[type="file"]:hover {
    border-color: #3498db;
    background: #f8fafc;
  }
  
  input[type="file"]:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
  }
  
  /* Professional card enhancements */
  .card {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    transition: transform 0.3s ease;
  }
  
  .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  }
  
  /* Spinner animation */
  .fa-spinner {
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* Professional typography */
  h1, h2, h3, h4 {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    line-height: 1.3;
  }
  
  /* Mobile optimizations */
  @media (max-width: 768px) {
    .professional-header h1 {
      font-size: 1.8rem;
    }
    
    .professional-header .subtitle {
      font-size: 1rem;
      padding: 0 15px;
    }
    
    .card {
      padding: 20px;
    }
    
    .button-group {
      flex-direction: column;
    }
    
    .button-group button {
      width: 100%;
    }
  }

  /* Enhanced Toast System */
.toast {
    padding: 16px 20px;
    border-radius: 12px;
    color: white;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.3s ease forwards;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
    margin-bottom: 10px;
    max-width: 350px;
}

.toast.hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

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

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

.toast.success {
    background: linear-gradient(135deg, #27ae60 0%, #219653 100%);
}

.toast.error {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.toast.info {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.toast.warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.toast-close {
    background: none;
    border: none;
    color: white;
    margin-left: 15px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    transition: transform 0.2s ease;
}

.toast-close:hover {
    transform: scale(1.1);
}

/* Camera Controls */
.camera-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    align-items: center;
}

.camera-selector {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    color: #4a5568;
    font-weight: 500;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.camera-selector:hover {
    border-color: #3498db;
}

.camera-selector:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
}

/* Button States */
.button-state-normal {
    background: linear-gradient(135deg, #27ae60 0%, #219653 100%);
}

.button-state-loading {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    cursor: wait;
}

.button-state-error {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* Mobile Scroll Indicator */
.scroll-indicator {
    text-align: center;
    margin: 10px 0;
    color: #718096;
    animation: bounce 2s infinite;
    display: none;
}

.scroll-indicator i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 5px;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

/* Card Visibility Enhancement */
.card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    scroll-margin-top: 80px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Professional Button Styles */
.primary-button, .success-button, .danger-button, .warning-button {
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.primary-button {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.success-button {
    background: linear-gradient(135deg, #27ae60 0%, #219653 100%);
}

.danger-button {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.warning-button {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.primary-button:hover, .success-button:hover, .danger-button:hover, .warning-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.primary-button:active, .success-button:active, .danger-button:active, .warning-button:active {
    transform: translateY(0);
}

.primary-button:disabled, .success-button:disabled, .danger-button:disabled, .warning-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .scroll-indicator {
        display: block;
    }
    
    .camera-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .camera-selector {
        width: 100%;
        min-width: auto;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .button-group button {
        width: 100%;
        min-width: auto;
    }
    
    .card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .professional-header h1 {
        font-size: 1.8rem;
    }
    
    .toast-root {
        left: 15px;
        right: 15px;
        top: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .professional-header h1 {
        font-size: 1.6rem;
    }
    
    .video-container {
        aspect-ratio: 3/4;
    }
    
    .primary-button, .success-button, .danger-button, .warning-button {
        padding: 16px 20px;
        font-size: 0.95rem;
    }
}

/* Loading Animation */
.fa-spin {
    animation: spin 1s linear infinite;
}

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

/* Mobile Touch Improvements */
@media (max-width: 768px) {
    button, input[type="file"], .camera-switch-btn {
        min-height: 44px !important; /* Apple's recommended touch target size */
        min-width: 44px !important;
    }
    
    /* Improve file input for mobile */
    #fileInput {
        width: 100%;
        padding: 15px;
        border: 2px dashed #3498db;
        border-radius: 10px;
        background: #f8fafc;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Better video display on mobile */
    .video-container video {
        transform: scaleX(-1); /* Mirror for front camera */
    }
    
    /* Larger buttons for mobile */
    .button-group button {
        padding: 15px;
        font-size: 16px;
    }
    
    /* File preview adjustments */
    .file-preview img {
        max-width: 100% !important;
        max-height: 250px !important;
    }
}

/* Prevent text selection on mobile */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection only where needed */
input, textarea, .toast {
    -webkit-user-select: text;
    user-select: text;
}