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

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-green: #00ff00;
    --accent-red: #ff3333;
    --accent-blue: #4a9eff;
    --border-color: #333;
    --btn-bg: #2a2a2a;
    --btn-hover: #3a3a3a;
    --btn-active: #4a4a4a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.title {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 0.9rem;
}

.viewer-count {
    color: var(--text-secondary);
}

#viewer-count {
    color: var(--accent-green);
    font-weight: 600;
}

.health-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

#health-dot.healthy {
    background: var(--accent-green);
    box-shadow: 0 0 5px var(--accent-green);
}

#health-dot.unhealthy {
    background: var(--accent-red);
    box-shadow: 0 0 5px var(--accent-red);
}

.github-link {
    color: var(--accent-blue);
    text-decoration: none;
}

.github-link:hover {
    text-decoration: underline;
}

/* Main grid layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    grid-template-rows: auto auto 1fr;
    gap: 1rem;
    min-height: calc(100vh - 120px);
}

/* Video section */
.video-section {
    grid-column: 1;
    grid-row: 1 / 4;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.video-player {
    width: 100%;
    height: 100%;
    max-height: 70vh;
    background: #000;
}

/* Control section */
.control-section {
    grid-column: 2;
    grid-row: 1;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.camera-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.hardware-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.control-btn {
    background: var(--btn-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 48px;
}

.control-btn:hover:not(:disabled) {
    background: var(--btn-hover);
    border-color: var(--accent-blue);
}

.control-btn:active:not(:disabled) {
    background: var(--btn-active);
    transform: scale(0.98);
}

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

.control-btn-special {
    background: linear-gradient(135deg, var(--btn-bg), var(--btn-hover));
}

.status-display {
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    min-height: 60px;
}

.status-message {
    color: var(--accent-green);
}

.status-message.error {
    color: var(--accent-red);
}

.status-message.info {
    color: var(--accent-blue);
}

/* Sensor section */
.sensor-section {
    grid-column: 2;
    grid-row: 2;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
}

.sensor-display {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    color: var(--accent-green);
}

.sensor-loading {
    color: var(--text-secondary);
}

/* Chat section */
.chat-section {
    grid-column: 2;
    grid-row: 3;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    min-height: 200px;
    max-height: 300px;
}

.chat-message {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.chat-username {
    color: var(--accent-blue);
    font-weight: 600;
}

.chat-text {
    color: var(--text-primary);
}

.chat-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.chat-placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.chat-input-form {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.chat-send {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.chat-send:hover {
    opacity: 0.9;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .video-section {
        grid-column: 1;
        grid-row: 1;
        min-height: 250px;
    }
    
    .control-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .sensor-section {
        grid-column: 1;
        grid-row: 3;
    }
    
    .chat-section {
        grid-column: 1;
        grid-row: 4;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .control-btn {
        min-height: 60px;
        font-size: 1rem;
    }
}

/* Loading states */
.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s infinite;
}

/* Chat error/success messages */
.chat-error {
    color: var(--accent-red);
    padding: 0.5rem;
    margin: 0.5rem 0;
    border: 1px solid var(--accent-red);
    border-radius: 4px;
    background: rgba(255, 51, 51, 0.1);
    text-align: center;
}

.chat-success {
    color: var(--accent-green);
    padding: 0.5rem;
    margin: 0.5rem 0;
    border: 1px solid var(--accent-green);
    border-radius: 4px;
    background: rgba(0, 255, 0, 0.1);
    text-align: center;
}
