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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    height: 44px;
}

.logo { font-size: 18px; font-weight: bold; color: #e94560; }

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #666;
}
.status-dot.online { background: #00d26a; box-shadow: 0 0 6px #00d26a; }
.status-dot.offline { background: #e94560; }

.user-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }

/* Modal */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.active { display: flex; }

.modal-content {
    background: #16213e;
    padding: 30px;
    border-radius: 8px;
    width: 360px;
    border: 1px solid #0f3460;
}
.modal-content h2 { margin-bottom: 20px; color: #e94560; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; margin-bottom: 4px; color: #aaa; }
.form-group input, .form-group select {
    width: 100%;
    padding: 8px 12px;
    background: #0f3460;
    border: 1px solid #1a1a2e;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #e94560;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
}

.error-msg { color: #e94560; font-size: 12px; margin-top: 10px; min-height: 16px; }

/* Buttons */
button {
    cursor: pointer;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    transition: opacity 0.2s;
}
button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: #e94560; color: white; }
.btn-warn { background: #f9a826; color: #1a1a2e; }
.btn-danger { background: #c0392b; color: white; }
.btn-success { background: #00d26a; color: #1a1a2e; }
.btn-link { background: transparent; color: #e94560; text-decoration: underline; padding: 4px 8px; }
.btn-small { padding: 5px 12px; font-size: 12px; }

/* Main Layout: 3 columns */
.main-layout {
    display: flex;
    height: calc(100vh - 44px);
}

/* Resizable splitter */
.splitter {
    width: 6px;
    background: #0f3460;
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    z-index: 10;
}
.splitter:hover,
.splitter.dragging {
    background: #e94560;
}

/* Left Panel */
.left-panel {
    width: 260px;
    min-width: 200px;
    max-width: 500px;
    background: #16213e;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px;
    gap: 10px;
    flex-shrink: 0;
}

.panel-section {
    background: #0f3460;
    border-radius: 6px;
    padding: 12px;
    flex-shrink: 0;
}
.panel-section h3, .panel-section h4 {
    font-size: 13px;
    color: #e94560;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* File button styling */
.file-btn {
    display: inline-block;
    padding: 6px 16px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #1a1a2e;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    width: 100%;
    transition: background 0.2s, border-color 0.2s;
}
.file-btn:hover {
    background: #16213e;
    border-color: #e94560;
}
.file-name-hint {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    word-break: break-all;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.loading-box {
    background: #16213e;
    padding: 24px 32px;
    border-radius: 8px;
    border: 1px solid #0f3460;
    text-align: center;
    min-width: 240px;
}
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #0f3460;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    font-size: 14px;
    color: #e0e0e0;
    margin-bottom: 12px;
}
.loading-progress-bar {
    width: 100%;
    height: 6px;
    background: #0a0a14;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}
.loading-progress-fill {
    height: 100%;
    background: #e94560;
    width: 0%;
    transition: width 0.2s;
}
.loading-detail {
    font-size: 11px;
    color: #888;
    margin-bottom: 12px;
}

/* Drone List */
.drone-list {
    list-style: none;
    max-height: 160px;
    overflow-y: auto;
}
.drone-list li {
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    background: #1a1a2e;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.drone-list li:hover { background: #16213e; }
.drone-list li.active {
    background: #e94560;
    color: white;
}
.drone-list li .drone-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #666;
}
.drone-list li .drone-status.running { background: #00d26a; }
.drone-list li .drone-status.queued {
    width: auto;
    height: auto;
    padding: 1px 6px;
    border-radius: 10px;
    background: #f9a826;
    color: #1a1a2e;
    font-size: 10px;
    font-weight: bold;
}

.drone-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.drone-stop-btn {
    background: transparent;
    color: #e94560;
    border: 1px solid #e94560;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
}
.drone-stop-btn:hover {
    opacity: 1;
    background: rgba(233, 69, 96, 0.15);
}
.drone-list li.active .drone-stop-btn {
    color: #fff;
    border-color: #fff;
}
.drone-list li.active .drone-stop-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Status Card */
.status-card { font-size: 12px; }
.status-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #1a1a2e;
}
.status-item span:first-child { color: #888; }
.status-item span:last-child { color: #e0e0e0; font-family: monospace; }

/* Log Output */
.log-output {
    height: 120px;
    background: #0a0a14;
    border-radius: 4px;
    padding: 6px;
    font-family: monospace;
    font-size: 11px;
    overflow-y: auto;
    color: #888;
    -webkit-overflow-scrolling: touch;
}
.log-output .log-info { color: #3498db; }
.log-output .log-warn { color: #f9a826; }
.log-output .log-error { color: #e94560; }

/* Viewport */
.viewport {
    flex: 1;
    position: relative;
    background: #0a0a14;
    overflow: hidden;
}
#canvas-container {
    width: 100%; height: 100%;
}
#canvas-container canvas {
    display: block;
}

.viewport-overlay {
    position: absolute;
    top: 10px; left: 10px;
    pointer-events: none;
}
.overlay-info {
    background: rgba(0,0,0,0.6);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    gap: 20px;
}

/* Mission */
.mission-info {
    font-size: 12px;
    color: #ccc;
    background: #0a0a14;
    padding: 6px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* WS Config */
.ws-config {
    margin-bottom: 10px;
}
.ws-config-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}
.ws-config-row label {
    width: 60px;
    color: #aaa;
    flex-shrink: 0;
}
.ws-config-row input {
    flex: 1;
    padding: 5px 8px;
    background: #0a0a14;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #e0e0e0;
    font-family: monospace;
    font-size: 12px;
}
.ws-config-row input:focus {
    outline: none;
    border-color: #e94560;
}
.ws-status {
    flex: 1;
    font-size: 11px;
    color: #888;
}
.ws-status.connecting { color: #f9a826; }
.ws-status.connected { color: #00d26a; }

/* Right Panel: WS Terminal */
.right-panel {
    width: 300px;
    min-width: 200px;
    max-width: 600px;
    background: #16213e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}
.right-panel .panel-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    border-radius: 0;
    background: transparent;
}

.ws-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
}
.ws-opt {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #aaa;
    cursor: pointer;
}
.ws-opt input { cursor: pointer; }

.ws-log {
    flex: 1;
    background: #0a0a14;
    border-radius: 4px;
    padding: 6px;
    font-family: monospace;
    font-size: 11px;
    overflow-y: auto;
    color: #888;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 8px;
}

.ws-item {
    margin-bottom: 6px;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.ws-item.sent {
    background: rgba(233, 69, 96, 0.08);
    border-left: 2px solid #e94560;
}
.ws-item.recv {
    background: rgba(0, 210, 106, 0.06);
    border-left: 2px solid #00d26a;
}
.ws-item.info {
    background: rgba(52, 152, 219, 0.06);
    border-left: 2px solid #3498db;
}
.ws-item.info .ws-item-header { color: #3498db; }
.ws-item-header {
    font-size: 10px;
    margin-bottom: 2px;
}
.ws-item.sent .ws-item-header { color: #e94560; }
.ws-item.recv .ws-item-header { color: #00d26a; }
.ws-item-time { color: #666; margin-left: 4px; }
.ws-item-body {
    color: #ccc;
    white-space: pre-wrap;
    word-break: break-word;
}
.ws-item-body pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.ws-send-row {
    display: flex;
    gap: 6px;
}
.ws-send-row input {
    flex: 1;
    padding: 6px 8px;
    background: #0a0a14;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #e0e0e0;
    font-family: monospace;
    font-size: 12px;
}
.ws-send-row input:focus {
    outline: none;
    border-color: #e94560;
}

/* JSON syntax highlighting */
.json-key { color: #9cdcfe; }
.json-string { color: #ce9178; }
.json-number { color: #b5cea8; }
.json-bool { color: #569cd6; }
.json-null { color: #569cd6; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0f3460; }
::-webkit-scrollbar-thumb { background: #e94560; border-radius: 3px; }
