/* ====== RESET & GLOBALS ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --dark-bg: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --overlay-bg: rgba(0, 0, 0, 0.7);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
}

/* ====== HEADER ====== */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    background: linear-gradient(90deg, #2196F3, #4CAF50);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.session-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.badge {
    background: rgba(33, 150, 243, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid var(--primary-color);
}

/* ====== CONTROLS PANEL ====== */
.controls-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--border-color);
}

.control-group h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.device-selector,
.processor-selector {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--dark-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.device-selector:hover,
.processor-selector:hover {
    border-color: var(--primary-color);
}

.device-selector:focus,
.processor-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

/* ====== BUTTONS ====== */
.btn {
    width: 100%;
    padding: 14px 20px;
    margin-top: 10px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-start {
    background: linear-gradient(135deg, var(--success-color), #45a049);
    color: white;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(76, 175, 80, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, var(--danger-color), #da190b);
    color: white;
}

.btn-stop:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(244, 67, 54, 0.4);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: #1976D2;
}

/* ====== STATUS INDICATOR ====== */
.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 10px;
    animation: pulse 2s infinite;
}

.status-active {
    background: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
}

.status-inactive {
    background: var(--text-secondary);
}

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

/* ====== VIDEO GRID ====== */
.grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
    min-height: 600px;
}

.grid-item {
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.grid-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(33, 150, 243, 0.3);
}

.video-header {
    background: rgba(33, 150, 243, 0.1);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
}

.video-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.fps-badge {
    background: var(--dark-bg);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.video-wrapper {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.overlay-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 20px;
}

.debug-info {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
}

.debug-info small {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.debug-info span {
    color: var(--primary-color);
    font-weight: bold;
}

/* ====== DEBUG CONSOLE ====== */
.debug-console {
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    padding: 20px;
    max-height: 300px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.console-header h3 {
    color: var(--primary-color);
}

.console-output {
    height: 200px;
    overflow-y: auto;
    background: var(--dark-bg);
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

.console-output p {
    margin-bottom: 5px;
    padding: 4px 8px;
    border-radius: 4px;
}

.log-info {
    color: var(--primary-color);
}

.log-success {
    color: var(--success-color);
}

.log-warning {
    color: var(--warning-color);
}

.log-error {
    color: var(--danger-color);
    background: rgba(244, 67, 54, 0.1);
}

/* Scrollbar customization */
.console-output::-webkit-scrollbar {
    width: 8px;
}

.console-output::-webkit-scrollbar-track {
    background: var(--card-bg);
}

.console-output::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

/* ====== TOAST NOTIFICATIONS ====== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    border-left: 4px solid var(--primary-color);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.4s ease;
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

/* ====== RESPONSIVE DESIGN ====== */
@media (max-width: 1024px) {
    .grid-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .controls-panel {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .session-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .control-group {
        padding: 15px;
    }
    
    .video-header h3 {
        font-size: 0.9rem;
    }
    
    .debug-console {
        max-height: 200px;
    }
    
    .console-output {
        height: 150px;
        font-size: 0.75rem;
    }
}

/* ====== LOADING ANIMATION ====== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* ====== LAYOUT BASE (Header/Footer) ====== */
.header-content {
    text-align: center;
}

.main-content {
    min-height: calc(100vh - 250px);
    padding: 20px 0;
}

.footer {
    background: var(--card-bg);
    padding: 30px 20px;
    margin-top: 40px;
    border-radius: 12px;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.3);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-section {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.3s;
}

.footer-link:hover {
    color: var(--success-color);
}

.footer-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.badge-icon {
    margin-right: 5px;
}

.badge-debug {
    background: rgba(255, 152, 0, 0.2);
    border-color: var(--warning-color);
}

/* ====== LANDING PAGE (index.html) ====== */
.welcome-section {
    max-width: 1200px;
    margin: 0 auto 40px;
}

.welcome-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.welcome-card h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #2196F3, #4CAF50);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.feature-card {
    background: rgba(33, 150, 243, 0.1);
    padding: 30px 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.feature-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(33, 150, 243, 0.2);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: bold;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #1976D2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(33, 150, 243, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--success-color), #45a049);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(76, 175, 80, 0.4);
}

/* ====== STATS SECTION ====== */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.stat-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ====== RESPONSIVE UPDATES ====== */
@media (max-width: 768px) {
    .welcome-card {
        padding: 20px;
    }
    
    .welcome-card h2 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-large {
        width: 100%;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* ====== TOAST NOTIFICATIONS ====== */
.toast {
    min-width: 250px;
    padding: 15px 20px;
    background: var(--card-bg);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    font-size: 0.9rem;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-info {
    border-left-color: #3498db;
}

.toast-success {
    border-left-color: #2ecc71;
}

.toast-warning {
    border-left-color: #f39c12;
}

.toast-error {
    border-left-color: #e74c3c;
}

/* ====== CLEAN VIDEO GRID ====== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
    max-width: 1920px;
    margin: 0 auto;
    height: calc(100vh - 100px);
}

.camera-card {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.camera-card:hover {
    border-color: rgba(33, 150, 243, 0.3);
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.1);
}

/* Camera Controls - Compact */
.camera-controls {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.select-minimal {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-minimal:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

.select-minimal:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.btn-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.btn-icon:hover {
    background: #1976d2;
    transform: scale(1.05);
}

.btn-icon[data-active="true"] {
    background: #f44336;
}

.btn-icon[data-active="true"] .icon::before {
    content: '⏹';
}

/* Botão de captura */
.btn-capture {
    background: #4CAF50;
}

.btn-capture:hover {
    background: #45a049;
}

.btn-capture:disabled {
    background: rgba(76, 175, 80, 0.3);
    cursor: not-allowed;
}

/* Botões de ação sobre o vídeo */
.video-actions {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.btn-action {
    background: rgba(33, 150, 243, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action:hover:not(:disabled) {
    background: rgba(33, 150, 243, 1);
    transform: translateY(-2px);
}

.btn-action:disabled {
    background: rgba(33, 150, 243, 0.3);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Camera Label - Simple */
.camera-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.label-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.label-stat {
    font-size: 0.75rem;
    color: var(--primary-color);
    background: rgba(33, 150, 243, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Video Container - Full Focus */
.video-container {
    position: relative;
    flex: 1;
    background: #000;
    overflow: hidden;
}

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

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.3s ease;
}

.overlay-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.overlay-label {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Video Stats - Minimal Overlay */
.video-stats {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.stat {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Floating Console - Minimized */
.console-float {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 300px;
    max-height: 400px;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
    transition: all 0.3s ease;
}

.console-float.minimized .console-content {
    display: none;
}

.console-header {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.console-header:hover {
    background: rgba(0, 0, 0, 0.7);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.console-float.minimized .toggle-icon {
    transform: rotate(-90deg);
}

.console-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
}

.console-content::-webkit-scrollbar {
    width: 6px;
}

.console-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.console-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Console Line Types */
.console-line {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
    border-left: 2px solid transparent;
}

.console-info {
    border-left-color: #2196F3;
    color: #90CAF9;
}

.console-success {
    border-left-color: #4CAF50;
    color: #A5D6A7;
}

.console-warning {
    border-left-color: #FF9800;
    color: #FFB74D;
}

.console-error {
    border-left-color: #F44336;
    color: #EF5350;
}

/* Responsive - Mobile First */
@media (max-width: 1024px) {
    .video-grid {
        grid-template-columns: 1fr;
        height: auto;
        gap: 0.75rem;
    }
    
    .camera-card {
        min-height: 300px;
    }
    
    .console-float {
        width: calc(100% - 2rem);
        left: 1rem;
        right: 1rem;
    }
}

@media (max-width: 768px) {
    .video-grid {
        padding: 0.5rem;
    }
    
    .camera-controls {
        flex-wrap: wrap;
    }
    
    .select-minimal {
        min-width: 120px;
    }
    
    .overlay-icon {
        font-size: 2rem;
    }
    
    .overlay-label {
        font-size: 0.85rem;
    }
}

/* Clean Header Override for /dev */
body:has(.video-grid) .header {
    padding: 0.75rem 1.5rem;
    background: rgba(26, 26, 26, 0.95);
}

body:has(.video-grid) .header-title {
    font-size: 1.2rem;
    font-weight: 500;
}

body:has(.video-grid) .footer {
    padding: 0.75rem 1.5rem;
    background: rgba(26, 26, 26, 0.95);
}