/**
 * ELRS Web Remote Control Styles
 */

:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FF9800;
    --bg-color: #121212;
    --panel-bg: #1E1E1E;
    --panel-border: #333;
    --text-color: #E0E0E0;
    --text-muted: #999;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 10px;
    border-radius: 8px;
}

.header h1 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--primary-color);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger-color);
}

.status-indicator.connected {
    background: var(--secondary-color);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 10px;
}

/* Joystick Layout */
.joystick-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
}

.joystick-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.joystick-canvas {
    background: #2A2A2A;
    border-radius: 50%;
    border: 2px solid var(--panel-border);
    touch-action: none;
}

.joystick-canvas.disabled {
    opacity: 0.45;
}

.joystick-label {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

/* Switches Section */
.switches-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 250px;
}

.switches-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.switch-btn {
    padding: 15px 10px;
    background: #2A2A2A;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.switch-btn:hover {
    border-color: var(--primary-color);
}

.switch-btn.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

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

.switch-btn:disabled:hover {
    border-color: var(--panel-border);
}

/* Channel Monitor */
.channel-monitor {
    background: #0A0A0A;
    padding: 10px;
    border-radius: 6px;
}

.channel-monitor h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.channel-bars {
    max-height: 200px;
    overflow-y: auto;
}

.channel-bar-container {
    display: grid;
    grid-template-columns: 40px 1fr 50px;
    gap: 5px;
    align-items: center;
    margin-bottom: 4px;
    font-size: 11px;
}

.channel-label {
    color: var(--text-muted);
    text-align: right;
}

.channel-bar-wrapper {
    height: 16px;
    background: #1A1A1A;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.channel-bar {
    position: absolute;
    height: 100%;
    background: var(--primary-color);
    transition: width 0.05s, left 0.05s;
}

.channel-value {
    color: var(--text-color);
    font-family: monospace;
    text-align: right;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 15px;
}

.panel h3 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: var(--primary-color);
    text-transform: uppercase;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.serial-config {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.serial-config-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    background: #2A2A2A;
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(33, 150, 243, 0.1);
}

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

.joystick-disabled .joystick-label {
    color: #666;
}

/* Link Stats */
.link-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    font-family: monospace;
}

.stat-value.good {
    color: var(--secondary-color);
}

.stat-value.warn {
    color: var(--warning-color);
}

.stat-value.bad {
    color: var(--danger-color);
}

/* Telemetry Display */
.telemetry-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.telemetry-item {
    padding: 10px;
    background: #2A2A2A;
    border-radius: 6px;
}

.telemetry-item .label {
    font-size: 11px;
    color: var(--text-muted);
}

.telemetry-item .value {
    font-size: 16px;
    font-weight: 600;
    font-family: monospace;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-buttons .btn {
    width: 100%;
}

/* Gamepad Info */
.gamepad-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gamepad-select {
    width: 100%;
    padding: 10px;
    background: #2A2A2A;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text-color);
}

.gamepad-status {
    padding: 10px;
    background: #2A2A2A;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.gamepad-status.connected {
    color: var(--secondary-color);
}

/* Log */
.log-panel {
    max-height: 150px;
    overflow-y: auto;
}

.log-entry {
    font-family: monospace;
    font-size: 11px;
    padding: 2px 0;
    border-bottom: 1px solid #2A2A2A;
}

.log-entry .timestamp {
    color: var(--text-muted);
    margin-right: 8px;
}

.log-entry .message {
    color: var(--text-color);
}

.build-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 4px;
}

.build-value {
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 1000px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .joystick-layout {
        grid-template-columns: 1fr;
    }

    .switches-section {
        order: -1;
    }

    .switches-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .switches-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .header {
        flex-direction: column;
        gap: 10px;
    }
}
