:root {
    --bg: #f5f9ff;
    --sidebar: #e8f1ff;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --text: #0f172a;
    --muted: #64748b;
    --border: #c7d2fe;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    transition: transform .25s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
}

.logo img {
    width: 34px;
    height: 34px
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.nav a {
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
}

.nav a:hover,
.nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto
}

/* ===== Main ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

header {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex: 0 0 64px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.content {
    padding: 24px;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* Center the server area and prevent it from touching viewport edges */
#server-area {
    margin: 0 auto;
    box-sizing: border-box;
    padding: 0 6px;
}

.server-card {
    width: 100%;
    box-sizing: border-box;
}

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

.btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
}

.btn:hover {
    background: var(--primary-soft)
}

/* status badge */
.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid transparent;
}

.badge.running {
    background: #e6f4ff;
    color: #0369a1;
    border-color: #bde0ff;
}

.badge.starting {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.badge.exited {
    background: #fff1f2;
    color: #991b1b;
    border-color: #fecaca;
}

.badge.stopped {
    background: #f3f4f6;
    color: #374151;
    border-color: #e5e7eb;
}

.badge.error {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fecaca;
}

.badge.unknown {
    background: #f3f4f6;
    color: #374151;
    border-color: #e5e7eb;
}

.server-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.server-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.server-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.small-muted {
    color: var(--muted);
    font-size: 13px;
}

#srv-address {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#srv-address .srv-address-line {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 14px;
    background: #f4f6fb;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 6px 8px;
    color: var(--text);
}

#srv-address #srv-address-note {
    font-size: 12px;
    line-height: 1.4;
}

pre.console {
    background: #0b1220;
    color: #d1e8ff;
    padding: 12px;
    border-radius: 8px;
    max-height: 240px;
    overflow: auto;
    white-space: pre-wrap;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
    font-size: 13px;
}

/* ===== Tabs ===== */
.tab {
    display: none
}

.tab.active {
    display: block
}

/* ===== Mobile ===== */
@media (max-width:900px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 8px 0 24px rgba(0, 0, 0, .08);
    }

    .sidebar.open {
        transform: translateX(0)
    }

    .hamburger {
        display: inline-flex
    }
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .2);
    z-index: 900;
}

.overlay.show {
    display: block
}

/* Minimal local styles for the console input row */
.console-input-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.console-input-row input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border-radius: 6px;
    color: inherit;
    font-family: monospace;
    font-size: 13px;
}

.console-input-row button {
    padding: 8px 12px;
    border-radius: 6px;
    color: inherit;
    cursor: pointer;
}

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

.server-actions .btn {
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Icon-only share button */
.icon-btn {
    padding: 0 12px;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Optional: make Open in Blockheads stand out */
.btn.primary {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.btn.primary:hover {
    background: #1d4ed8;
}

@media (max-width: 640px) {
    .server-actions {
        flex-direction: column;
        align-items: stretch;
        /* make children take full width */
        gap: 10px;
        margin-top: 12px;
    }

    .server-actions .btn {
        width: 100%;
        box-sizing: border-box;
        justify-content: center;
        /* center contents (text/icon) */
    }

    /* make the icon button look OK when full-width */
    .server-actions .icon-btn {
        padding: 10px 12px;
    }

    .server-actions .icon-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Reduce page padding on small screens so cards don't get clipped */
    .content {
        padding: 12px;
    }

    #server-area {
        padding: 0 4px;
    }

    .server-card {
        padding: 14px;
    }

    /* Hide the 'Last update' text on small screens */
    #srv-last { display: none; }

    /* Ensure Start button in controls matches other buttons in height/alignment */
    .server-controls .btn {
        height: 38px;
        padding: 8px 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        line-height: 1;
        vertical-align: middle;
        font-size: 14px;
        border-width: 1px;
    }
}

/* When `.server-actions` is moved inside `.server-meta` (mobile JS),
   display actions inline next to the Start button */
@media (max-width: 640px) {
    .server-meta .server-actions {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: center;
        margin-left: 8px;
    }

    .server-meta .server-actions .btn {
        width: auto;
        padding: 8px 12px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .server-meta .server-actions .icon-btn {
        padding: 0;
        width: 38px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .server-meta {
        /* ensure meta remains stacked on small screens */
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* Controls container that holds Start + moved actions */
    .server-controls {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* small nudge to vertically align Start with other buttons */
    .server-controls #start-stop {
        transform: translateY(6px);
    }
}
