/* ============================================================
   Architect Panel — dark Minecraft-inspired theme
   ============================================================ */

:root {
    --bg-deep: #0f0f1a;
    --bg: #141420;
    --surface: #1a1a2e;
    --surface-2: #22223a;
    --surface-3: #2a2a44;
    --hairline: rgba(255,255,255,0.06);
    --hairline-strong: rgba(255,255,255,0.12);
    --text: #e8e8f0;
    --text-2: #a0a0b8;
    --text-3: #6a6a82;
    --accent: #2ecc71;
    --accent-dim: rgba(46,204,113,0.12);
    --accent-text: #3ddf82;
    --taken: #f1c40f;
    --taken-dim: rgba(241,196,15,0.12);
    --danger: #e74c3c;
    --danger-dim: rgba(231,76,60,0.12);
    --r-card: 10px;
    --r-control: 6px;
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100dvh;
}

/* ---------- topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--hairline);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-brand {
    color: var(--accent);
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--text-2); font-size: 13px; }

/* ---------- container ---------- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--r-control);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    font-family: var(--font);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover:not(:disabled) { background: #27ae60; }
.btn-success { background: var(--accent); color: #111; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--hairline-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-icon {
    width: 28px; height: 28px; padding: 0;
    background: transparent; border: 1px solid var(--hairline-strong);
    border-radius: var(--r-control); color: var(--text-3); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; transition: background 0.15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* ---------- login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    background: var(--bg-deep);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: 14px;
    padding: 40px 36px;
    text-align: center;
    max-width: 360px;
    width: 100%;
}
.login-icon { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-hint { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }
.login-hint code {
    background: var(--surface-2); padding: 2px 6px;
    border-radius: 4px; font-family: var(--mono);
}
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input {
    text-align: center;
    font-size: 28px;
    letter-spacing: 8px;
    font-family: var(--mono);
    font-weight: 600;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-control);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button[type="submit"] {
    padding: 10px;
    background: var(--accent);
    color: #111;
    border: none;
    border-radius: var(--r-control);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.login-card button[type="submit"]:hover { background: #27ae60; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ---------- builds grid ---------- */
.page-title { font-size: 22px; margin-bottom: 20px; }
.builds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.build-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    transition: border-color 0.2s, transform 0.15s;
}
.build-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.build-closed { opacity: 0.6; }
.build-card-img {
    height: 140px;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--hairline);
}
.build-card-body { padding: 14px 16px; }
.build-card h2 { font-size: 16px; margin-bottom: 4px; }
.build-card-meta { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.build-card-pct { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.badge {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    padding: 2px 6px; border-radius: 4px; vertical-align: middle;
}
.badge-closed { background: var(--danger-dim); color: var(--danger); }
.empty-state { color: var(--text-3); text-align: center; padding: 60px 0; }

/* ---------- progress bar ---------- */
.progress-bar-wrap {
    position: relative;
    height: 6px;
    background: var(--surface-3);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-done {
    position: absolute; left: 0; top: 0; height: 100%;
    background: var(--accent);
    border-radius: 3px;
    z-index: 2;
    transition: width 0.3s;
}
.progress-bar-taken {
    position: absolute; left: 0; top: 0; height: 100%;
    background: var(--taken);
    border-radius: 3px;
    z-index: 1;
    transition: width 0.3s;
}

/* ---------- build page ---------- */
.build-header { margin-bottom: 20px; }
.back-link { color: var(--text-3); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--accent); }
.build-header h1 { font-size: 24px; margin: 8px 0 4px; }
.build-descr { color: var(--text-2); font-size: 13px; margin-bottom: 4px; }
.build-meta { color: var(--text-3); font-size: 12px; }
#buildStatus .badge { margin-top: 8px; display: inline-block; }

/* ---------- toolbar ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.search-input, .filter-select {
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-control);
    color: var(--text);
    font-size: 13px;
    outline: none;
    font-family: var(--font);
}
.search-input { flex: 1; min-width: 180px; }
.search-input:focus, .filter-select:focus { border-color: var(--accent); }
.toolbar-admin { margin-left: auto; }

/* ---------- my tasks ---------- */
.my-tasks-section {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    padding: 16px;
    margin-bottom: 20px;
}
.my-tasks-section h2 { font-size: 15px; margin-bottom: 10px; }
.my-task-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 13px;
}
.my-task-row:last-child { border-bottom: none; }
.my-task-icon { width: 24px; height: 24px; border-radius: 4px; image-rendering: pixelated; }
.my-task-name { flex: 1; }
.my-task-amount { color: var(--text-2); font-family: var(--mono); font-size: 12px; }

/* ---------- resource table ---------- */
.cat-group { margin-bottom: 20px; }
.cat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-2);
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 2px;
}

.res-table {
    width: 100%;
    border-collapse: collapse;
}
.res-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--hairline);
}
.res-table td {
    padding: 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}
.res-table tr:hover td { background: var(--surface); }
.res-table .col-icon { width: 40px; text-align: center; }
.res-table .col-name { min-width: 160px; }
.res-table .col-num {
    font-family: var(--mono);
    font-size: 12px;
    white-space: nowrap;
    text-align: right;
    min-width: 80px;
}
.res-table .col-bar { width: 120px; }
.res-table .col-act { width: 100px; text-align: center; }

.item-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    image-rendering: pixelated;
    vertical-align: middle;
}
.item-icon-fallback {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
    background: var(--surface-2);
    border-radius: 4px;
}

.row-progress {
    position: relative;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
}
.row-progress-done {
    position: absolute; left: 0; top: 0; height: 100%;
    background: var(--accent); z-index: 2;
}
.row-progress-taken {
    position: absolute; left: 0; top: 0; height: 100%;
    background: var(--taken); z-index: 1;
}

.row-done td { opacity: 0.4; }

/* ---------- modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-card {
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: 12px;
    padding: 24px;
    min-width: 320px;
    max-width: 90vw;
}
.modal-card h3 { font-size: 16px; margin-bottom: 4px; }
.modal-card p { color: var(--text-2); font-size: 13px; margin-bottom: 12px; }
.modal-card input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-control);
    color: var(--text);
    font-size: 15px;
    font-family: var(--mono);
    outline: none;
    margin-bottom: 14px;
}
.modal-card input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- ws status dot ---------- */
.ws-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}
.ws-dot.connected { background: var(--accent); }
.ws-dot.disconnected { background: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 700px) {
    .container { padding: 16px 12px 40px; }
    .builds-grid { grid-template-columns: 1fr; }
    .res-table .col-bar { display: none; }
    .res-table .col-num { min-width: 60px; font-size: 11px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-admin { margin-left: 0; }
}
