/* simplified, colorful, easy-to-navigate styles */

:root {
    --bg: #1e63a0;
    --panel: #ffffff;
    --muted: #6b7280;
    --accent: #0a45c3;
    --accent-2: #10b981;
    --danger: #ef4444;
    --glass: #e6eef8;
    --border: #d1d5db;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family:
        Inter,
        "Segoe UI",
        Roboto,
        system-ui,
        -apple-system,
        "Helvetica Neue",
        Arial;
    background: var(--bg);
    color: #0f172a;
    padding: 0;
}

/* ── App header ─────────────────────────────────────────────────────────── */
.app-header {
    background: linear-gradient(135deg, #658ee7 0%, #4497e0 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
}
.app-header h1 {
    margin: 0;
    font-size: 22px;
    color: white;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.header-nav {
    display: flex;
    gap: 14px;
    align-items: center;
}
.header-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.15s;
}
.header-link:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    align-items: start;
    padding: 16px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Panels ────────────────────────────────────────────────────────────── */
.rs232-area,
.channel-area,
.control-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.channel-area {
    font-size: 0.9rem;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rs232-area h3,
.control-panel h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: #0b1220;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.rs232-area h4,
.control-panel h4 {
    margin: 12px 0 8px 0;
    font-size: 0.95rem;
    color: #1f2937;
    font-weight: 600;
}

/* Packet visualizer */
.packet-stream-container h4 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
}
#packet-stream {
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    height: 130px;
    overflow-y: auto;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    font-family: "Courier New", monospace;
    color: #0b1220;
    font-size: 0.9rem;
}

/* Buttons - simple and colorful */
button {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    background: var(--glass);
    color: #0b1220;
    transition:
        transform 0.08s ease,
        opacity 0.1s ease,
        box-shadow 0.1s ease;
    font-size: 0.9rem;
}
button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
button:active {
    transform: translateY(0px);
}

.btn-connect {
    background: linear-gradient(135deg, var(--accent) 0%, #063fb2 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(10, 69, 195, 0.2);
}
.btn-connect:hover {
    opacity: 0.95;
    box-shadow: 0 4px 8px rgba(10, 69, 195, 0.3);
}

.btn-test {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 1px solid var(--border);
    color: #1f2937;
    flex: 1;
    min-width: 90px;
}

.btn-test:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
}

.btn-flash {
    background: linear-gradient(135deg, var(--accent-2) 0%, #059669 100%);
    color: white;
    width: 100%;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn-flash:hover {
    opacity: 0.95;
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* small muted buttons */
.btn-clear {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 8px;
    font-size: 0.85rem;
}

.btn-clear:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Packet byte chips */
.packet-byte {
    display: inline-block;
    padding: 4px 6px;
    margin: 2px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.byte-preamble {
    background: #dbeafe;
    color: #1e40af;
} /* blue */
.byte-opcode {
    background: #dcfce7;
    color: #065f46;
} /* green */
.byte-param {
    background: #f3e8ff;
    color: #6b21a8;
} /* purple */
.byte-checksum {
    background: #fee2e2;
    color: #991b1b;
} /* red */
.byte-comp {
    background: #f1f5f9;
    color: #475569;
    opacity: 0.85;
}

/* Misc */
.legend {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--muted);
}
input[type="text"] {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    width: 100%;
}
textarea {
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    background: #fff;
    color: #0b1220;
}

/* Editor section styling for commands page */
.editor-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    line-height: 1.6;
}

.editor-section h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.editor-section h3:first-child {
    margin-top: 0;
}

.editor-section h4 {
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--accent);
}

.editor-section p {
    margin: 12px 0;
    color: #374151;
}

.editor-section pre {
    background: #f3f4f6;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: #0b1220;
}

.editor-section ul {
    margin: 12px 0;
    padding-left: 24px;
}

.editor-section li {
    margin: 10px 0;
    line-height: 1.5;
    color: #1f2937;
}

.editor-section b {
    color: var(--accent);
    font-weight: 700;
}

/* ── Serial Terminal Styling (RS232) ───────────────────────────────────── */

/* Terminal container and overall RS232 area */
#all_things_rs232 {
    margin-top: 12px;
}

/* Terminal output display */
#repl-terminal {
    background: #0f1419;
    color: #10b981;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 12px;
    font-family: "Courier New", "JetBrains Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Terminal text - better readability */
#repl-terminal {
    caret-color: #10b981;
}

/* Status bar styling */
#status-bar {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #7dd3fc;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

#status-bar[style*="color: rgb(46, 204, 113)"],
#status-bar[style*="color: #2ecc71"] {
    background: #f0fdf4;
    color: #15803d;
    border-color: #86efac;
}

#status-bar[style*="color: rgb(231, 76, 60)"],
#status-bar[style*="color: #e74c3c"] {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* Control buttons group */
.terminal-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

#connect-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 9px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
    transition: all 0.15s ease;
}

#connect-btn:hover {
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

#connect-btn:active {
    transform: translateY(0);
}

/* File management section */
.file-management {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
}

.file-management h4 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: #0b1220;
    font-weight: 600;
}

#file-selector,
#code-editor {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 8px;
    background: white;
}

#code-editor {
    font-family: "Courier New", monospace;
    min-height: 100px;
    resize: vertical;
    color: #0b1220;
}

#code-editor:focus,
#file-selector:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 69, 195, 0.1);
}

/* Button group styling */
.file-btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.file-btn-group button {
    flex: 1;
    min-width: 100px;
    font-size: 0.85rem;
    padding: 7px 10px;
}

#list-board-files-btn {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid var(--border);
}

#list-board-files-btn:hover {
    background: #e5e7eb;
}

#load-file-btn {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

#load-file-btn:hover {
    background: #bfdbfe;
}

#flash-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

#flash-btn:hover {
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.4);
}

/* Console log area */
#console-log {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    font-family: "Courier New", monospace;
    font-size: 0.85rem;
    max-height: 150px;
    overflow-y: auto;
    color: #1e293b;
}

#console-log > div {
    padding: 4px 0;
    border-bottom: 1px solid #f1f5f9;
    word-break: break-word;
}

#console-log > div:last-child {
    border-bottom: none;
}

/* Scrollbar styling for terminal */
#repl-terminal::-webkit-scrollbar,
#console-log::-webkit-scrollbar {
    width: 6px;
}

#repl-terminal::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 3px;
}

#repl-terminal::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 3px;
}

#repl-terminal::-webkit-scrollbar-thumb:hover {
    background: #059669;
}

#console-log::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#console-log::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#console-log::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }
    .left-column {
        gap: 10px;
    }

    #repl-terminal {
        min-height: 150px;
        max-height: 300px;
    }

    .file-management {
        padding: 10px;
    }

    .terminal-controls {
        gap: 6px;
    }
}

