/* PicoTel Drawing Interface Styles */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Spline+Sans+Mono:wght@500;600&display=swap');

:root {
    --accent: #50C878;
    --accent-dark: #2E8B57;
    --accent-bright: #7EF3B1;
    --bg-dark: #0f1426;
    --bg-darker: #0b101f;
    --surface-1: #151d36;
    --surface-2: #10182f;
    --surface-3: #0c1326;
    --text-light: #edf3f7;
    --text-muted: #9aa8c5;
    --border-color: #28314d;
    --radius: 14px;
    --shadow-soft: 0 18px 40px rgba(8, 12, 24, 0.45);
    --shadow-glow: 0 12px 30px rgba(80, 200, 120, 0.3);
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 22px;
}

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

body {
    font-family: 'Space Grotesk', 'Trebuchet MS', sans-serif;
    background:
        radial-gradient(800px 400px at 10% -10%, rgba(80, 200, 120, 0.25), transparent 60%),
        radial-gradient(900px 600px at 110% 10%, rgba(46, 139, 87, 0.22), transparent 60%),
        linear-gradient(180deg, #0f1426 0%, #0c1222 50%, #090e1a 100%);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(12px, 2vw, 24px);
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.container {
    max-width: 960px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: var(--space-4);
}

header h1 {
    color: var(--accent-bright);
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    margin-bottom: var(--space-2);
    letter-spacing: 0.6px;
}

.connection-panel {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--space-2);
    box-shadow: var(--shadow-soft);
}

#device-select {
    padding: 10px 44px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--surface-3);
    color: var(--text-light);
    font-size: 15px;
    min-height: 44px;
    min-width: min(260px, 100%);
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
        linear-gradient(135deg, var(--text-muted) 50%, transparent 50%),
        linear-gradient(to right, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%,
        calc(100% - 36px) 50%;
    background-size: 6px 6px, 6px 6px, 1px 60%;
    background-repeat: no-repeat;
}

#device-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(80, 200, 120, 0.2);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.status.disconnected {
    background: rgba(231, 76, 60, 0.16);
    color: #ff6b5a;
}

.status.connecting {
    background: rgba(243, 156, 18, 0.18);
    color: #f6b04d;
}

.status.connected {
    background: rgba(39, 174, 96, 0.2);
    color: #4be38f;
}

main {
    background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-2) 100%);
    border-radius: var(--radius);
    padding: clamp(16px, 2vw, 26px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}

/* Tab Navigation */
.tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: var(--space-3);
    background: var(--surface-3);
    border-radius: calc(var(--radius) - 4px);
    padding: 6px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.tab-btn:hover {
    color: var(--accent-bright);
    border-color: rgba(126, 243, 177, 0.4);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-bright));
    border-color: rgba(126, 243, 177, 0.6);
    color: #0a1511;
    box-shadow: var(--shadow-glow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.draw-layout {
    display: grid;
    gap: var(--space-3);
    align-items: start;
}

.canvas-container {
    display: flex;
    justify-content: center;
    padding: var(--space-3);
    background: linear-gradient(145deg, rgba(13, 19, 38, 0.95), rgba(10, 15, 30, 0.95));
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#led-canvas {
    background: #000;
    border-radius: 10px;
    cursor: crosshair;
    image-rendering: pixelated;
    width: 100%;
    max-width: 520px;
    height: auto;
    touch-action: none;
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.45), 0 0 24px rgba(80, 200, 120, 0.15);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.control-group {
    display: grid;
    grid-template-columns: minmax(90px, 150px) 1fr;
    align-items: center;
    gap: 12px;
    padding: var(--space-2);
    background: var(--surface-2);
    border-radius: calc(var(--radius) - 4px);
    border: 1px solid var(--border-color);
}

.control-group label {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    min-width: 0;
}

.control-group.buttons {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tool-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-color);
}

.tool-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    border-radius: 999px;
    padding: 10px 12px;
    cursor: pointer;
    min-height: 44px;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    color: var(--text-light);
}

.tool-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-bright));
    color: #0a1511;
    box-shadow: var(--shadow-glow);
}

#brightness-slider {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-3);
    -webkit-appearance: none;
    appearance: none;
    accent-color: var(--accent);
}

#brightness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-bright);
    cursor: pointer;
    border: 2px solid var(--surface-2);
    box-shadow: 0 0 0 6px rgba(80, 200, 120, 0.15);
}

#brightness-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-bright);
    cursor: pointer;
    border: 2px solid var(--surface-2);
    box-shadow: 0 0 0 6px rgba(80, 200, 120, 0.15);
}

#brightness-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 2px 8px;
    margin-left: 6px;
    border-radius: 999px;
    background: rgba(80, 200, 120, 0.18);
    color: var(--accent-bright);
    font-size: 12px;
    font-weight: 600;
}

.btn {
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-3);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
    min-height: 44px;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: rgba(126, 243, 177, 0.6);
    box-shadow: 0 10px 20px rgba(9, 15, 30, 0.35);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-bright));
    border: none;
    color: #0a1511;
    box-shadow: var(--shadow-glow);
}

.btn-ghost {
    background: transparent;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(80, 200, 120, 0.25);
}

footer {
    text-align: center;
    margin-top: var(--space-3);
    color: var(--text-muted);
    font-size: clamp(12px, 2.5vw, 13px);
    font-family: 'Spline Sans Mono', monospace;
}

/* Messages Tab */
.message-input {
    margin-bottom: var(--space-3);
}

.message-input input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface-3);
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 10px;
}

.message-input input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(80, 200, 120, 0.2);
}

.message-input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.char-count {
    color: var(--text-muted);
    font-size: 13px;
}

.queue-status {
    text-align: center;
    padding: 10px;
    background: var(--surface-3);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    color: var(--accent-bright);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.message-history {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid var(--border-color);
    max-height: min(40vh, 340px);
    overflow-y: auto;
}

.message-history h3 {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.message-history ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-history li {
    padding: 10px 12px;
    background: var(--surface-3);
    border-radius: 10px;
    border: 1px solid rgba(40, 49, 77, 0.7);
    font-size: 14px;
    color: var(--text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.message-history .msg-text {
    flex: 1;
    word-break: break-word;
}

.message-history .msg-time {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 10px;
    white-space: nowrap;
    font-family: 'Spline Sans Mono', monospace;
}

.message-history .empty-msg {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Screen Saver Tab */
.ss-controls {
    padding: 10px 0;
}

.ss-controls h3 {
    color: var(--accent-bright);
    font-size: 16px;
    margin-bottom: 6px;
}

.ss-description {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

.ss-group {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.ss-group h4 {
    color: var(--accent);
    font-size: 14px;
    margin-bottom: 10px;
}

.ss-group > .ss-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 10px;
    display: block;
}

.ss-control {
    margin-bottom: 12px;
}

.ss-control:last-child {
    margin-bottom: 0;
}

.ss-control label {
    display: block;
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 6px;
}

.ss-control label span {
    color: var(--accent-bright);
    font-weight: 600;
}

.ss-control input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-3);
    -webkit-appearance: none;
    appearance: none;
    accent-color: var(--accent);
}

.ss-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-bright);
    cursor: pointer;
    border: 2px solid var(--surface-2);
    box-shadow: 0 0 0 5px rgba(80, 200, 120, 0.12);
}

.ss-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-bright);
    cursor: pointer;
    border: 2px solid var(--surface-2);
    box-shadow: 0 0 0 5px rgba(80, 200, 120, 0.12);
}

.ss-control .ss-hint {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
    font-style: italic;
}

.ss-actions {
    text-align: center;
    margin-top: 20px;
}

/* Responsive adjustments */
@media (min-width: 900px) {
    .draw-layout {
        grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
    }
}

@media (max-width: 700px) {
    body {
        align-items: flex-start;
    }

    .connection-panel {
        box-shadow: none;
    }

    .tabs {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .control-group.buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 500px) {
    .connection-panel {
        flex-direction: column;
        align-items: stretch;
    }

    #device-select {
        width: 100%;
    }

    .control-group {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .message-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn,
    .tool-btn {
        width: 100%;
    }
}
