/* ── Hide Alpine elements until ready ────────────── */
[x-cloak] { display: none !important; }

/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0e0e1a;
    --bg-card: #161627;
    --bg-hover: #1e1e35;
    --bg-input: #1a1a2e;
    --border: #2a2a44;
    --border-focus: #4a4a6a;
    --text: #d4d4e0;
    --text-dim: #7a7a9a;
    --text-bright: #eeeef4;
    --gold: #c4a35a;
    --gold-dim: #8a7340;
    --accent: #5865F2;
    --accent-hover: #4752C4;
    --green: #57F287;
    --green-dim: #2d6b44;
    --red: #ED4245;
    --red-dim: #6b2123;
    --yellow: #FEE75C;
    --radius: 8px;
    --radius-sm: 4px;
    --sidebar-w: 220px;
    --header-h: 52px;
    --nav-h: 61px;    /* shared site header height */
}

html { overflow-x: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    width: 100vw;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Admin Layout ────────────────────────────────── */
.admin-layout {
    display: flex;
    min-height: calc(100vh - var(--nav-h));
}

.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 90;
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
}

.sidebar-brand-sub {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--bg-hover);
    color: var(--text-bright);
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-nav a.active svg {
    opacity: 1;
}

/* sidebar-footer removed — profile/logout is now in the shared site header */

.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 28px 32px;
    min-width: 0;
}

/* ── Page Header ─────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
}

/* ── Stat Cards ──────────────────────────────────── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

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

.stat-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.stat-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-bright);
}

.stat-card-value.gold { color: var(--gold); }

/* ── Charts ──────────────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

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

.chart-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.chart-card canvas {
    width: 100% !important;
    max-height: 260px;
}

/* ── Data Tables ─────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    font-weight: 600;
}

.data-table td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table tr.clickable { cursor: pointer; }

.data-table tr.selected td {
    background: var(--bg-hover);
}

.data-table .text-dim { color: var(--text-dim); }
.data-table .text-gold { color: var(--gold); }
.data-table .text-green { color: var(--green); }
.data-table .text-red { color: var(--red); }

.data-table .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-runes { background: var(--gold-dim); color: var(--gold); }
.badge-inventory { background: rgba(88, 101, 242, 0.2); color: var(--accent); }
.badge-active { background: var(--green-dim); color: var(--green); }
.badge-inactive { background: var(--red-dim); color: var(--red); }

/* ── Forms & Inputs ──────────────────────────────── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
}

input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.checkbox-row label {
    font-size: 13px;
    color: var(--text);
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s, opacity 0.15s;
}

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

.btn-primary {
    background: var(--accent);
    color: white;
}

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

.btn-gold {
    background: var(--gold);
    color: var(--bg);
}

.btn-gold:hover:not(:disabled) { background: #d4b36a; }

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-danger:hover:not(:disabled) { background: #d93436; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--border-focus);
    color: var(--text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ── Inline Actions ──────────────────────────────── */
.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.inline-form input {
    width: 100px;
}

.inline-form .reason-input {
    width: 200px;
}

/* ── Modal / Dialog ──────────────────────────────── */
.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 {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 18px;
}

/* ── Player Detail Panel ─────────────────────────── */
.detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.detail-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-bright);
}

.detail-meta {
    font-size: 12px;
    color: var(--text-dim);
}

.detail-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.detail-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.detail-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
}

.detail-section {
    margin-top: 18px;
}

.detail-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Inventory List (in player detail) ───────────── */
.inv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.inv-row:last-child { border-bottom: none; }

.inv-row-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inv-row-name {
    font-size: 13px;
    font-weight: 600;
}

.inv-row-type {
    font-size: 11px;
    color: var(--text-dim);
}

/* ── Test Console ────────────────────────────────── */
.test-console {
    background: #0a0a14;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.7;
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
}

.test-line {
    padding: 1px 0;
}

.test-line-pass { color: var(--green); }
.test-line-fail { color: var(--red); }
.test-line-running { color: var(--yellow); }
.test-line-cleanup { color: #b8a9c9; }
.test-line-dim { color: var(--text-dim); }

.test-line-prefix {
    display: inline-block;
    width: 36px;
    text-align: right;
    margin-right: 8px;
    font-weight: 600;
}

/* ── Log Console ────────────────────────────────── */
.log-console {
    max-height: calc(100vh - 280px);
    min-height: 400px;
    font-size: 12px;
    line-height: 1.6;
}

.log-ts {
    color: var(--text-dim);
    margin-right: 8px;
    white-space: nowrap;
}

.log-level {
    display: inline-block;
    width: 72px;
    font-weight: 600;
    margin-right: 4px;
}

.log-level-error { color: var(--red); }
.log-level-warn  { color: var(--yellow); }
.log-level-info  { color: var(--green); }
.log-level-debug { color: var(--text-dim); }

.log-line-warn { color: var(--yellow); }

.log-logger {
    color: var(--accent);
    margin-right: 8px;
}
.log-logger::after { content: ':'; }

.log-source-toggle {
    display: inline-flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2px;
}
.log-source-toggle button {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.log-source-toggle button.active {
    background: var(--accent);
    color: white;
}

.test-summary {
    margin-bottom: 12px;
}

.test-summary-bar {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 14px;
}

.test-bar-pass {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid var(--green);
}

.test-bar-fail {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid var(--red);
}

/* ── Pagination ──────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination-info {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Filter Bar ──────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-bar .form-group {
    margin-bottom: 0;
}

/* ── Toast ───────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 300;
}

.toast-success { background: var(--green); color: var(--bg); }
.toast-error { background: var(--red); color: white; }

/* ── Loading / Empty ─────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

/* .login-prompt and .btn-discord are in nav.css */

/* ── Maintenance Banner ─────────────────────────── */
.maintenance-banner {
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    transition: background 0.2s, border-color 0.2s;
}

.maintenance-on {
    background: rgba(237, 66, 69, 0.08);
    border: 1px solid var(--red);
}

.maintenance-off {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.maintenance-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.maintenance-banner-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
}

.maintenance-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-on {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
    animation: pulse-dot 2s ease-in-out infinite;
}

.dot-off {
    background: var(--green);
}

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

.maintenance-banner-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ── Stripe Setup Banner ─────────────────────────── */
.stripe-setup-banner {
    background: rgba(88, 101, 242, 0.08);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stripe-setup-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
}

/* ── Shortfall Banner ─────────────────────────────── */
.shortfall-banner {
    background: rgba(254, 231, 92, 0.08);
    border: 1px solid var(--yellow);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shortfall-banner-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--yellow);
}

/* ── Shortfall Modal Rows ────────────────────────── */
.shortfall-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.shortfall-row:last-of-type {
    border-bottom: none;
}

.shortfall-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.shortfall-player {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
}

.shortfall-detail {
    font-size: 12px;
    color: var(--text-dim);
}

.shortfall-resolve-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.shortfall-resolve-form input {
    width: 180px;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
    .chart-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; padding: 20px 16px; }
}

/* ── Tab bar ────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tab-bar button {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab-bar button:hover {
    color: var(--text);
}

.tab-bar button.active {
    border-bottom-color: var(--accent);
    color: var(--text-bright);
}

/* Testing Tools card */
.testing-card {
    margin-top: 28px;
    padding: 20px;
    background: var(--bg-card, #1a1a2e);
    border: 2px solid #2d6a3f;
    border-radius: 8px;
}

.testing-card h2 {
    margin: 0 0 12px 0;
    color: #4ade80;
    font-size: 18px;
}

.testing-banner {
    background: #1a472a;
    border: 1px solid #2d6a3f;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-family: monospace;
    font-size: 13px;
    color: #4ade80;
}

.testing-banner .label {
    color: #86efac;
    font-weight: bold;
    margin-right: 6px;
}

.testing-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.testing-control {
    flex: 1;
    min-width: 280px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #333;
    border-radius: 6px;
}

.testing-control h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--text-bright, #e4e4e7);
}

.testing-control input[type="text"],
.testing-control input[type="number"],
.testing-control select {
    margin-right: 6px;
    margin-bottom: 6px;
}

.testing-result {
    background: #1e1e2e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
    font-family: monospace;
    font-size: 12px;
    max-height: 260px;
    overflow-y: auto;
    white-space: pre-wrap;
    color: #ccc;
}

.testing-sub-select {
    margin-bottom: 16px;
}

.testing-sub-select select {
    width: 100%;
    max-width: 480px;
}

.testing-danger-zone {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #333;
}

.testing-danger-zone button {
    background: #dc2626;
}
