/* piNail2 — Dark theme dashboard */

:root {
    --bg: #1a1a1a;
    --bg-card: #252525;
    --bg-input: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #cccccc;
    --accent-orange: #d35400;
    --accent-orange-hover: #e65c00;
    --accent-orange-deep: #a84300;
    --accent-teal: #d35400;
    --accent-blue: #d35400;
    --accent-red: #e74c3c;
    --accent-green: #2ecc71;
    --border: #333333;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    background: radial-gradient(circle at 20% 0%, #222 0%, #1a1a1a 35%, #000 100%);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: #000;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
}

.brand-logo {
    height: 100%;
    width: auto;
    max-width: 56vw;
    border: none;
    border-radius: 0;
    object-fit: contain;
}

.conn-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    background: #111;
}

.mode-btn {
    background: transparent;
    color: var(--text-dim);
    border: none;
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.mode-btn.active {
    background: var(--accent-orange);
    color: #fff;
}

.install-btn {
    background: var(--accent-orange);
    color: #fff;
    border: 1px solid var(--accent-orange);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.install-btn:hover {
    background: var(--accent-orange-hover);
    border-color: var(--accent-orange-hover);
}

.backend-status {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.last-ack {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.last-ack.ok {
    color: var(--accent-green);
}

.last-ack.err {
    color: var(--accent-red);
}

.backend-status.online { color: var(--accent-green); }
.backend-status.reconnecting { color: var(--accent-orange); }
.backend-status.offline { color: var(--accent-red); }

header h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-dot.connected { background: var(--accent-green); }
.status-dot.disconnected { background: var(--accent-red); }

/* Main */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

body.ui-simple main {
    max-width: 760px;
}

body.ui-simple .advanced-only {
    display: none !important;
}

.simple-only {
    display: none;
}

body.ui-simple .simple-only {
    display: grid;
}

body.ui-simple .hero,
body.ui-simple .chart-section,
body.ui-simple .controls-setpoint,
body.ui-simple .app-footer {
    display: none;
}

.dual-simple {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.simple-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.simple-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.simple-temp {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.simple-line {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.simple-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.power-mini {
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    padding: 8px 12px;
    font-weight: 700;
}

.power-mini.on {
    color: var(--accent-green);
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.15);
}

/* Hero: temp + power */
.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 30px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.temp-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.temp-main {
    display: flex;
    align-items: baseline;
}

.wall-clock {
    font-size: 0.92rem;
    color: var(--accent-orange);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
}

.temp-value {
    font-size: 4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    transition: color 0.3s;
}

.temp-unit {
    font-size: 1.5rem;
    color: var(--text-dim);
    margin-left: 4px;
}

.temp-good { color: var(--accent-green); }
.temp-warming { color: var(--accent-orange); }
.temp-cold { color: var(--accent-blue); }

.error-stats {
    font-size: 0.74rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.hero-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.autotune-pill {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    letter-spacing: 0.02em;
}

.autotune-pill.idle {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
}

.mode-pill {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
}

.mode-pill.takeoff {
    color: #111;
    background: var(--accent-orange);
    border-color: var(--accent-orange);
}

.mode-pill.cruise {
    color: #111;
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.mode-pill.descent {
    color: #111;
    background: #f39c12;
    border-color: #f39c12;
}

.mode-pill.grounded {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
}

.mode-eta {
    font-size: 0.78rem;
    color: var(--text-dim);
}

.sched-time-list {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sched-time-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #1a1a1a;
    color: var(--text);
    font-size: 0.78rem;
}

#sched-time-input {
    width: 122px;
    text-align: center;
}

.sched-del {
    border: none;
    background: transparent;
    color: var(--accent-red);
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.autotune-pill.running {
    color: #111;
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    animation: autotunePulse 1.2s infinite;
}

.autotune-pill.done {
    color: #111;
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.autotune-pill.error {
    color: #fff;
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.setpoint-display {
    font-size: 1.1rem;
    color: var(--accent-teal);
}

.power-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.power-btn.off {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.power-btn.on {
    background: rgba(46, 204, 113, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.3);
}

.power-btn:hover { opacity: 0.8; }
.power-btn:active { transform: scale(0.95); }

/* Safety Banner */
.safety-banner {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius);
    padding: 12px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--accent-red);
    font-weight: 600;
}

.safety-banner.hidden { display: none; }

.safety-banner button {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.action-banner {
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-weight: 600;
}

.action-banner.hidden { display: none; }
.action-banner.info { border-color: var(--accent-blue); color: var(--accent-blue); }
.action-banner.success { border-color: var(--accent-green); color: var(--accent-green); }
.action-banner.error { border-color: var(--accent-red); color: var(--accent-red); }

/* Chart */
.chart-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 12px;
    margin-bottom: 12px;
    height: 280px;
}

.chart-section {
    box-shadow: inset 0 0 0 1px rgba(211, 84, 0, 0.12);
}

.chart-section canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Controls */
.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.controls-setpoint {
    grid-template-columns: 1fr;
}

.controls-advanced-row {
    grid-template-columns: 1fr 1fr;
}

.control-group {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
}

.control-group h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

/* Setpoint controls */
.setpoint-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.adj-btn {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.adj-btn:hover { background: var(--accent-orange-deep); color: #fff; }
.adj-btn:active { transform: scale(0.95); }

input[type="number"] {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 4px;
    width: 80px;
    text-align: center;
    font-size: 1rem;
    font-family: inherit;
}

select {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

select:focus {
    outline: none;
    border-color: var(--accent-teal);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-teal);
}

.apply-btn {
    background: var(--accent-teal);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
}

.apply-btn:hover { background: var(--accent-orange-hover); opacity: 1; }
.apply-btn:active { transform: scale(0.95); }

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

/* Presets */
.presets {
    margin-top: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    background: var(--bg-input);
    color: var(--accent-teal);
    border: 1px solid var(--accent-teal);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.preset-btn:hover {
    background: var(--accent-teal);
    color: #000;
}

/* PID controls */
.pid-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.pid-controls label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--text-dim);
    gap: 4px;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.checkbox-label input {
    width: auto;
}

.autotune-controls {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.autotune-status {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 600;
}

.autotune-status.idle {
    color: var(--text-dim);
}

.autotune-status.running {
    color: var(--accent-orange);
    animation: autotunePulse 1.2s infinite;
}

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

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

@keyframes autotunePulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.pid-controls input {
    width: 70px;
}

/* Status Bar */
.status-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.status-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.status-item .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.status-item .value {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.app-footer {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-dim);
    font-size: 0.78rem;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.relay-on { color: var(--accent-green); }
.relay-off { color: var(--text-dim); }
.tc-ok { color: var(--accent-green); }
.tc-err { color: var(--accent-red); }

/* Mobile responsive */
@media (max-width: 600px) {
    .hero {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 16px;
    }

    .brand-logo {
        height: 100%;
        max-width: 62vw;
    }

    header h1 {
        display: none;
    }

    .app-footer {
        flex-direction: column;
        text-align: center;
    }

    .hero-right {
        align-items: center;
    }

    .temp-value {
        font-size: 3rem;
    }

    .temp-display {
        align-items: center;
    }

    .error-stats {
        text-align: center;
    }

    .power-btn {
        width: 64px;
        height: 64px;
        font-size: 1rem;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .dual-simple {
        grid-template-columns: 1fr;
    }

    .chart-section {
        height: 220px;
    }

    .setpoint-controls {
        justify-content: center;
    }

    .pid-controls {
        justify-content: center;
    }

    .status-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
