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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

/* Main app container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Video area - 80% */
.video-area {
    flex: 0 0 80%;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
}

/* Video container */
.video-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
}

#video-stream {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Detection canvas */
#detection-canvas, .detection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    display: none;
}

#detection-canvas.active, .detection-canvas.active {
    display: block;
}

/* Video loading */
.video-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Video error */
.video-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-align: center;
}

.error-icon {
    width: 50px;
    height: 50px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

/* Browser capability status */
.browser-capabilities {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.capability-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 14px;
}

.capability-label {
    font-weight: 500;
    color: #b0b0b0;
}

.capability-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.capability-status.success {
    background: #22c55e;
    color: white;
}

.capability-status.warning {
    background: #f59e0b;
    color: white;
}

.capability-status.error {
    background: #ef4444;
    color: white;
}

/* Browser error message */
.browser-error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    text-align: center;
    z-index: 10;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.browser-error-message h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.browser-error-message p {
    margin-bottom: 8px;
    line-height: 1.4;
}

.browser-error-message ul {
    text-align: left;
    margin: 12px 0;
    padding-left: 20px;
}

/* Video overlay indicators */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.recording-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.detection-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(34, 197, 94, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
}

/* Video controls */
.video-controls {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: #0f0f0f;
    border-top: 1px solid #1a1a1a;
}

/* Sidebar - 20% */
.sidebar {
    flex: 0 0 20%;
    min-width: 300px;
    background: #0f0f0f;
    border-left: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Sidebar header */
.sidebar header {
    padding: 24px;
    border-bottom: 1px solid #1a1a1a;
}

.sidebar h1 {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 14px;
    color: #6b7280;
}

/* Sections */
.section {
    padding: 20px 24px;
    border-bottom: 1px solid #1a1a1a;
}

.section h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin-bottom: 12px;
}

/* Input styles */
input[type="text"],
input[type="email"] {
    width: 100%;
    padding: 10px 12px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    transition: all 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus {
    outline: none;
    border-color: #3b82f6;
    background: #1f1f1f;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder {
    color: #6b7280;
}

small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

/* Status grid */
.status-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #1a1a1a;
    border-radius: 6px;
    transition: all 0.2s;
}

.status-item.active {
    background: #1e293b;
    border: 1px solid #3b82f6;
}

.status-label {
    font-size: 13px;
    color: #9ca3af;
}

.status-value {
    font-size: 13px;
    font-weight: 500;
    color: #e0e0e0;
}

/* Training status */
.training-status-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
}

.training-status-text {
    font-size: 14px;
    color: #e0e0e0;
}

.training-spinner {
    display: flex;
    align-items: center;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Progress dots */
.training-progress-dots {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}

.progress-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.dot-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 2px solid #3a3a3a;
    transition: all 0.3s;
}

.progress-dot.active .dot-circle {
    background: #3b82f6;
    border-color: #3b82f6;
}

.progress-dot.completed .dot-circle {
    background: #22c55e;
    border-color: #22c55e;
}

.dot-label {
    font-size: 11px;
    color: #6b7280;
}

/* Sidebar bottom */
.sidebar-bottom {
    margin-top: auto;
}

/* Instructions */
.instructions-list {
    list-style: none;
    counter-reset: item;
}

.instructions-list li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #d1d5db;
    counter-increment: item;
}

.instructions-list li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    width: 18px;
    height: 18px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
}

/* Contact form */
.contact-section {
    background: #1a1a1a;
    border-bottom: none;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Slider styles */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slider-container label {
    font-size: 13px;
    color: #e0e0e0;
    font-weight: 500;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.threshold-slider {
    flex: 1;
    height: 6px;
    background: #1a1a1a;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.threshold-slider::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.threshold-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.threshold-slider::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.threshold-value {
    min-width: 45px;
    font-size: 13px;
    font-weight: 600;
    color: #3b82f6;
    text-align: right;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-secondary {
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #2a2a2a;
}

.btn-secondary:hover:not(:disabled) {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn.recording {
    background: #dc2626;
}

.btn.recording:hover:not(:disabled) {
    background: #b91c1c;
}

.btn.active {
    background: #22c55e;
}

.btn.active:hover:not(:disabled) {
    background: #16a34a;
}

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

/* Message container */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s ease-out;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.message.show {
    transform: translateX(0);
}

.message-success {
    background: #22c55e;
    color: white;
}

.message-error {
    background: #ef4444;
    color: white;
}

.message-info {
    background: #3b82f6;
    color: white;
}

/* Responsive design */
@media (max-width: 1200px) {
    .video-area {
        flex: 0 0 70%;
    }
    
    .sidebar {
        flex: 0 0 30%;
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .video-area {
        flex: 1;
        height: 60vh;
    }
    
    .sidebar {
        flex: 1;
        min-width: auto;
        height: 40vh;
        border-left: none;
        border-top: 1px solid #1a1a1a;
    }
}