:root {
    --accent: #2b6cb0;
    --accent-dark: #234e7d;
    --border: #d0d5dd;
    --bg: #f5f6f8;
    --text: #1a202c;
    --muted: #6b7280;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Segoe UI, system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100%;
}

h1 {
    font-size: 1.4rem;
    margin: 0 0 1rem 0;
}

code {
    font-family: Consolas, monospace;
}

/* ----- Layout ----- */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #1f2933;
    color: #e4e7eb;
    flex-shrink: 0;
}

.nav-brand {
    padding: 1rem;
    font-weight: 600;
    border-bottom: 1px solid #323f4b;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
}

.nav-link {
    display: block;
    padding: 0.65rem 1rem;
    color: #cbd2d9;
    text-decoration: none;
}

.nav-link:hover {
    background: #323f4b;
    color: #fff;
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.top-row .server-info {
    color: var(--muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.top-row .server-info strong {
    color: var(--text);
}

.server-status-inline {
    font-size: 0.78rem;
    color: var(--muted);
}

.top-row .user-info {
    margin-left: auto;
    font-weight: 600;
}

.logout-form {
    margin: 0;
}

.content {
    padding: 1.25rem;
}

/* ----- Controls ----- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn:hover:not(:disabled) {
    background: #eef2f7;
}

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

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.btn-link {
    border: none;
    background: none;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.muted {
    color: var(--muted);
}

.alert-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
}

/* ----- Split panes (GPIO / Station) ----- */
.split {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.split-left {
    flex: 0 0 380px;
}

.split-right {
    flex: 1;
    min-width: 0;
}

.pin-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.pin-label {
    flex: 0 0 170px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

/* GPIO rows carry an extra label pill, so they need a wider, fixed column
   to keep the High/Low buttons aligned across rows. */
.pin-label.pin-label-wide {
    flex-basis: 280px;
}

.pin-tag {
    padding: 0.05rem 0.45rem;
    background: #eef2f7;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--accent-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pin-status {
    margin-left: 0.75rem;
    font-family: Consolas, monospace;
    font-size: 0.82rem;
    color: var(--muted);
}

.pin-status.error {
    color: #b91c1c;
}

.status-box {
    background: #0f172a;
    color: #e2e8f0;
    padding: 0.75rem;
    border-radius: 6px;
    min-height: 320px;
    white-space: pre-wrap;
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    overflow: auto;
}

/* ----- Camera ----- */
.camera-form {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.form-row label {
    font-weight: 600;
}

.args-box {
    flex: 1;
    min-width: 320px;
    font-family: Consolas, monospace;
}

.photo-frame {
    border: 1px solid var(--border);
    background: #000;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.photo-frame img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.photo-frame .muted {
    color: #94a3b8;
}

/* ----- Login ----- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    display: flex;
    flex-direction: column;
    width: 320px;
    padding: 2rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
    text-align: center;
}

.login-subtitle {
    text-align: center;
    color: var(--muted);
    margin-top: 0;
}

.login-card label {
    margin-top: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.login-card input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 0.25rem;
}

.login-card button {
    margin-top: 1.25rem;
    padding: 0.6rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.login-card button:hover {
    background: var(--accent-dark);
}

.login-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 0.5rem;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
}

/* ----- Server picker ----- */
.server-picker {
    width: 380px;
}

.server-choice-form {
    margin: 0 0 0.6rem 0;
}

.server-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}

.server-choice:hover {
    background: #eef2f7;
    border-color: var(--accent);
}

.server-choice.current {
    border-color: var(--accent);
    background: #eef5fc;
}

.server-choice .server-name {
    font-weight: 600;
    font-size: 1rem;
}

.server-choice .server-url {
    color: var(--muted);
    font-family: Consolas, monospace;
    font-size: 0.85rem;
}

.server-choice .server-badge {
    margin-top: 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-dark);
}

.top-row .change-server {
    margin-left: 0.75rem;
    font-size: 0.85rem;
}

.server-picker-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.server-choice-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.server-choice .server-status {
    font-size: 0.75rem;
    color: var(--muted);
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #9ca3af;
}

.dot.online {
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.dot.offline {
    background: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.dot.checking {
    background: #9ca3af;
    animation: dot-pulse 1s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
