/* ── Dashboard: MariaDB HA Demo ──────────────────────── */
:root {
    --bg: #0a0c10;
    --panel-bg: #13161f;
    --border: #1e2332;
    --text: #c9d1d9;
    --text-dim: #5a6270;
    --green: #3fb950;
    --green-glow: rgba(63, 185, 80, 0.3);
    --red: #f85149;
    --red-glow: rgba(248, 81, 73, 0.3);
    --blue: #58a6ff;
    --orange: #d2991d;
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.dash {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 12px 16px;
    gap: 10px;
}

/* ── Header ────────────────────────────────────────── */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
}

.header-left { display: flex; flex-direction: column; gap: 2px; }
.dash-title { font-size: 1.35rem; color: #fff; font-weight: 700; letter-spacing: 0.5px; }
.dash-subtitle { font-size: 0.78rem; color: var(--text-dim); }

.header-right { display: flex; gap: 12px; align-items: center; }
.stat-pill {
    background: #1a1f2e;
    border: 1px solid var(--border);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 110px;
    text-align: center;
}
#pill-availability { color: var(--blue); }
#pill-availability.warning { color: var(--red); }
#pill-transactions { color: var(--text); }

/* ── Mode Selector ──────────────────────────────────── */
.mode-select {
    background: #1a1f2e;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    min-width: 160px;
}
.mode-select:focus { border-color: var(--blue); }
.mode-select:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Main Grid ──────────────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1.3fr;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* ── Panels ─────────────────────────────────────────── */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dc-badge {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 1px;
}
.cluster1 { background: rgba(88,166,255,0.2); color: var(--blue); }
.cluster2 { background: rgba(210,153,29,0.2); color: var(--orange); }

/* ── App Panel (compact header + terminal) ──────────── */
.panel-app { align-items: stretch; }
.app-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.circle-mini {
    width: 48px; height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.25s, box-shadow 0.25s;
}
.circle-mini.gray  { background: #2a2f3a; box-shadow: 0 0 12px rgba(42,47,58,0.3); }
.circle-mini.green {
    background: var(--green);
    box-shadow: 0 0 24px var(--green-glow);
    animation: pulse-green 1.5s ease-in-out infinite;
}
.circle-mini.red {
    background: var(--red);
    box-shadow: 0 0 24px var(--red-glow);
    animation: pulse-red 0.8s ease-in-out infinite;
}
.app-status-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.status-label-mini { font-size: 0.85rem; font-weight: 600; }
.status-label-mini.error { color: var(--red); }
.avail-inline {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--blue);
}
.avail-inline.warning { color: var(--red); }

/* ── Server Cards ───────────────────────────────────── */
.server-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.server-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #181c26;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.3s, background 0.3s;
    position: relative;
}
.server-card.primary  { border-color: var(--green); border-left: 3px solid var(--green); }
.server-card.secondary   { border-color: var(--blue); border-left: 3px solid var(--blue); }
.server-card.down    { border-color: var(--red); border-left: 3px solid var(--red); background: rgba(248,81,73,0.08); }
.server-card.loading { opacity: 0.5; }

.server-name { font-size: 0.9rem; font-weight: 600; }
.server-role {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.server-card.primary .server-role { color: var(--green); }
.server-card.secondary  .server-role { color: var(--blue); }
.server-card.down   .server-role { color: var(--red); }

.server-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    transition: background 0.3s;
}
.server-card.primary .server-dot { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.server-card.secondary  .server-dot { background: var(--blue); box-shadow: 0 0 8px rgba(88,166,255,0.3); }
.server-card.down   .server-dot { background: var(--red); box-shadow: 0 0 8px var(--red-glow); animation: pulse-red 1s infinite; }
.server-card.loading .server-dot { background: var(--text-dim); }

/* ── Server Toggle Buttons ──────────────────────────── */
.server-toggle {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--text-dim);
    cursor: pointer;
    transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
    padding: 0;
    outline: none;
    flex-shrink: 0;
}
.server-toggle.on {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 10px var(--green-glow);
}
.server-toggle.off {
    background: var(--red);
    border-color: var(--red);
    box-shadow: 0 0 10px var(--red-glow);
    animation: pulse-red 1.5s ease-in-out infinite;
}
.server-toggle:disabled { opacity: 0.5; cursor: wait; }
.server-toggle:hover:not(:disabled) { transform: scale(1.15); }

/* ── Terminal ────────────────────────────────────────── */
.terminal {
    flex: 1;
    min-height: 0;
    background: #05070a;
    border: 1px solid #141822;
    border-radius: 6px;
    padding: 10px 14px;
    overflow-y: auto;
    font-family: "SF Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.78rem;
    line-height: 1.55;
}
.terminal::-webkit-scrollbar { width: 6px; }
.terminal::-webkit-scrollbar-thumb { background: #1a1f2e; border-radius: 3px; }
.terminal-inner { display: flex; flex-direction: column; }
.term-line { white-space: nowrap; padding: 1px 0; }
.term-line.dim   { color: #3a4050; }
.term-line.ok    { color: #4ade80; }
.term-line.fail  { color: #f87171; font-weight: 700; }

/* ── Animations ──────────────────────────────────────── */
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 20px var(--green-glow); }
    50% { box-shadow: 0 0 40px rgba(63, 185, 80, 0.35); }
}
@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 20px var(--red-glow); }
    50% { box-shadow: 0 0 40px rgba(248, 81, 73, 0.4); }
}

/* ── MaxScale Status ────────────────────────────────── */
.mx-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin-top: 10px;
    background: #181c26;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.mx-label { font-size: 0.8rem; color: var(--text-dim); }
.mx-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
}
.mx-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }

/* ── Action Bar ─────────────────────────────────────── */
.action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.btn-action {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s, background 0.2s;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
.btn-action:hover:not(:disabled) { transform: scale(1.03); }
.btn-action:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn-action:active:not(:disabled) { transform: scale(0.97); }

.btn-init   { background: #1e2332; color: var(--blue); border: 1px solid var(--blue); }
.btn-start  { background: var(--green); color: #000; }
.btn-stop   { background: var(--red); color: #fff; }
.btn-kill   { background: #3d1a1a; color: var(--red); border: 1px solid var(--red); }
.btn-recover { background: #1a2e1a; color: var(--green); border: 1px solid var(--green); }

.action-msg {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-left: auto;
    min-width: 160px;
    text-align: right;
}

/* ── Responsive: stack on small screens ─────────────── */
@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash { height: auto; }
    .action-bar { justify-content: center; }
}
