/* Ladorian Camera Analytics - PWA v2.4 Styles */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100vw; 
    height: 100vh; 
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0a0a0a; 
    color: #fff;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

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

/* Video Panel */
.video-panel {
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    background: #000; 
    position: relative;
}

.video-wrapper {
    position: relative;
    display: inline-block;
}

#video {
    display: block;
    max-width: 100%;
    max-height: 100vh;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* Side Panel */
.side-panel {
    width: 260px; 
    min-width: 260px; 
    height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    display: flex; 
    flex-direction: column; 
    border-left: 1px solid #333;
    overflow-y: auto;
}

/* Panel Header */
.panel-header {
    padding: 15px; 
    background: rgba(0,0,0,0.3); 
    border-bottom: 1px solid #333;
}

.panel-header h1 { 
    font-size: 15px; 
    color: #00d4ff; 
    margin-bottom: 3px; 
}

.panel-header .version { 
    font-size: 10px; 
    color: #666; 
}

/* Server Section - NEW */
.server-section {
    padding: 10px 15px;
    background: rgba(0, 100, 150, 0.1);
    border-bottom: 1px solid #333;
}

.section-title {
    font-size: 11px;
    color: #00d4ff;
    margin-bottom: 6px;
    font-weight: 600;
}

.server-info {
    font-size: 11px;
    color: #aaa;
    line-height: 1.6;
}

.server-info small {
    color: #666;
    font-family: monospace;
    font-size: 9px;
}

/* Counters Section */
.counters-section { 
    padding: 15px; 
    background: rgba(0,0,0,0.2); 
}

.counter-row {
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    padding: 12px 15px; 
    margin-bottom: 8px;
    background: rgba(0,0,0,0.3); 
    border-radius: 8px;
}

.counter-row.male { 
    border-left: 4px solid #00d4ff; 
}

.counter-row.female { 
    border-left: 4px solid #ff69b4; 
}

.counter-label { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 14px; 
}

.counter-icon { 
    font-size: 20px; 
}

.counter-value { 
    font-size: 26px; 
    font-weight: bold; 
}

.counter-row.male .counter-value { 
    color: #00d4ff; 
}

.counter-row.female .counter-value { 
    color: #ff69b4; 
}

/* Info Section */
.info-section { 
    padding: 12px 15px; 
    border-top: 1px solid #333; 
    font-size: 11px; 
}

.info-row { 
    display: flex; 
    justify-content: space-between; 
    padding: 4px 0; 
}

.info-row .label { 
    color: #666; 
}

.info-row .value { 
    color: #aaa; 
    font-family: monospace; 
    font-size: 10px; 
}

/* Status Section */
.status-section {
    padding: 10px 15px; 
    background: rgba(0,0,0,0.3); 
    border-top: 1px solid #333;
}

.status-indicator { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 12px; 
}

.status-dot { 
    width: 8px; 
    height: 8px; 
    border-radius: 50%; 
    background: #666; 
}

.status-dot.active { 
    background: #4ecdc4; 
    animation: pulse 1.5s infinite; 
}

.status-dot.loading { 
    background: #ffd93d; 
    animation: pulse 0.8s infinite; 
}

.status-dot.error { 
    background: #ff6b6b; 
}

.status-dot.warning { 
    background: #ff9800; 
    animation: pulse 2s infinite; 
}

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

/* Stats Section */
.stats-section { 
    padding: 12px 15px; 
    flex: 1; 
}

.stats-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 8px; 
}

.stat-box { 
    background: rgba(0,0,0,0.3); 
    padding: 10px; 
    border-radius: 6px; 
    text-align: center; 
}

.stat-label { 
    font-size: 9px; 
    color: #666; 
    text-transform: uppercase; 
    margin-bottom: 3px; 
}

.stat-value { 
    font-size: 14px; 
    font-weight: bold; 
    color: #aaa; 
}

/* Settings Section */
.settings-section { 
    border-top: 1px solid #333; 
}

.settings-toggle { 
    padding: 10px 15px; 
    background: rgba(0,0,0,0.2); 
}

.settings-btn {
    width: 100%; 
    padding: 8px; 
    background: rgba(255,255,255,0.05);
    border: 1px solid #333; 
    border-radius: 6px; 
    color: #888;
    font-size: 11px; 
    cursor: pointer;
}

.settings-btn:hover { 
    background: rgba(255,255,255,0.1); 
    color: #fff; 
}

.settings-drawer { 
    display: none; 
    padding: 12px 15px; 
    background: rgba(0,0,0,0.4); 
}

.settings-drawer.open { 
    display: block; 
}

.setting-row { 
    margin-bottom: 12px; 
}

.setting-label { 
    font-size: 10px; 
    color: #666; 
    margin-bottom: 4px; 
}

.setting-control { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.setting-control input[type="range"] {
    flex: 1; 
    height: 4px; 
    -webkit-appearance: none; 
    background: #333; 
    border-radius: 2px;
}

.setting-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; 
    width: 14px; 
    height: 14px;
    background: #00d4ff; 
    border-radius: 50%; 
    cursor: pointer;
}

.setting-control input[type="range"]::-moz-range-thumb {
    width: 14px; 
    height: 14px;
    background: #00d4ff; 
    border-radius: 50%; 
    cursor: pointer;
    border: none;
}

.setting-value { 
    font-size: 11px; 
    color: #00d4ff; 
    min-width: 40px; 
    text-align: right; 
}

/* Settings Section Title */
.settings-section-title {
    font-size: 10px;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 15px 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.settings-section-title:first-child {
    margin-top: 0;
}

/* Settings Select */
.setting-select {
    width: 100%;
    padding: 5px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300d4ff' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 25px;
}

.setting-select:focus {
    outline: none;
    border-color: #00d4ff;
}

.setting-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Disabled state for controls */
.setting-control input[type="range"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Refresh Button - NEW */
.refresh-btn {
    padding: 6px 12px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid #00d4ff;
    border-radius: 4px;
    color: #00d4ff;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: rgba(0, 212, 255, 0.2);
}

.refresh-btn:active {
    transform: scale(0.95);
}

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

/* Panel Footer */
.panel-footer {
    padding: 8px 15px; 
    background: rgba(0,0,0,0.4);
    border-top: 1px solid #333; 
    font-size: 9px; 
    color: #444; 
    text-align: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh;
    background: rgba(0,0,0,0.95); 
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center; 
    z-index: 1000;
}

.loading-overlay.hidden { 
    display: none; 
}

.loading-spinner {
    width: 50px; 
    height: 50px; 
    border: 3px solid #333;
    border-top-color: #00d4ff; 
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 
    to { transform: rotate(360deg); } 
}

.loading-text { 
    margin-top: 20px; 
    color: #888; 
    font-size: 14px; 
}

.loading-progress { 
    margin-top: 8px; 
    color: #00d4ff; 
    font-size: 12px; 
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .side-panel {
        width: 200px;
        min-width: 200px;
    }
    
    .counter-value {
        font-size: 22px;
    }
    
    .panel-header h1 {
        font-size: 13px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .app-container {
        flex-direction: column;
    }
    
    .side-panel {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .video-panel {
        height: 60vh;
    }
    
    .counters-section {
        display: flex;
        gap: 10px;
    }
    
    .counter-row {
        flex: 1;
        margin-bottom: 0;
    }
    
    .server-section {
        padding: 8px 12px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }
}