/* Ported largely verbatim from the reference valheim-server-manager project,
   adapted to HopePatrulla branding and the multi-server grid. */
:root {
    --bg-primary: #0d0d15;
    --bg-card: #16161f;
    --bg-nav: #09090f;
    --border: #2a2a3a;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-muted: #6a6a88;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(ellipse at 50% 0%, rgba(88, 101, 242, 0.07) 0%, transparent 55%), var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.7;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: #f0f0fa;
}

a { color: var(--accent); transition: color 0.15s; }
a:hover { color: #7b86f5; }

::selection { background: rgba(88, 101, 242, 0.35); color: #fff; }

.navbar {
    background: rgba(9, 9, 15, 0.82) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0;
}
.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: filter 0.3s ease, transform 0.3s ease;
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary) !important;
    letter-spacing: -0.03em;
    text-decoration: none;
}
.navbar-brand:hover .brand-logo {
    filter: drop-shadow(0 0 14px rgba(88, 101, 242, 0.5));
    transform: scale(1.08);
}
.nav-link {
    color: var(--text-secondary) !important;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem !important;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-link:hover {
    color: var(--text-primary) !important;
    background: rgba(255,255,255,0.06);
}

.card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 1.25rem;
    font-weight: 600;
    font-size: 0.925rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-body {
    padding: 1.15rem 1.25rem;
}

.ms-auto { margin-left: auto !important; }

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}
.stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.stat-value.code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    letter-spacing: -0.02em;
}

.btn {
    font-weight: 600;
    font-size: 0.825rem;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    border: none;
    transition: all 0.15s;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn:active { transform: translateY(0); }
.btn-success { background: var(--success); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-warning { background: var(--warning); color: #111; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #3a3a4a; color: var(--text-primary); }
.btn-discord {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: 0.55rem 1.4rem;
    border-radius: 8px;
    transition: all 0.15s;
}
.btn-discord:hover {
    background: var(--accent-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(88, 101, 242, 0.45);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-running {
    background: var(--success);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
    animation: pulse 2s infinite;
}
.dot-stopped {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.4);
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.badge {
    font-weight: 500;
    font-size: 0.675rem;
    padding: 0.25em 0.6em;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}
.player-item:last-child { border-bottom: none; }
.player-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}
.player-name {
    font-weight: 500;
    font-size: 0.875rem;
    flex: 1;
}
.player-id {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
}

.empty-state {
    text-align: center;
    padding: 1.5rem 0;
}
.empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.empty-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 75vh;
    text-align: center;
}
.hero-logo {
    width: 96px;
    height: 96px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 28px rgba(88, 101, 242, 0.35));
    animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.hero-title {
    font-size: 2.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #f0f0fa 0%, #a0a0c0 50%, #707090 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0 auto 1.5rem;
    font-weight: 400;
    max-width: 520px;
    line-height: 1.6;
}

#toast {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: toastIn 0.25s ease, toastOut 0.3s ease 3.5s forwards;
}
.toast-success {
    background: linear-gradient(135deg, #0f2618, #1a3a2a);
    border: 1px solid rgba(46, 204, 113, 0.3);
    color: #b0f0c0;
}
.toast-error {
    background: linear-gradient(135deg, #2a1010, #3a1a1a);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #f0b0b0;
}
.toast-icon { font-size: 1.1rem; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(80px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-8px); pointer-events: none; }
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.btn { pointer-events: none; opacity: 0.7; }

.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}
.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border) !important;
    padding: 0.75rem 0.5rem !important;
}
.table td {
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.5rem !important;
    vertical-align: middle;
}
.table-dark { --bs-table-bg: transparent; }

.form-control {
    background: #0d0d15 !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15) !important;
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; }
.form-text { font-size: 0.75rem; }

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    font-size: 0.85rem;
}
.dropdown-item {
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    transition: all 0.1s;
}
.dropdown-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

/* ── HopePatrulla additions ─────────────────────────────── */

.server-card {
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.server-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 28px rgba(88, 101, 242, 0.06);
    border-color: var(--accent) !important;
}
.server-card .card-header { font-size: 1rem; }
.server-name { font-weight: 600; }
.game-icon { font-size: 1.25rem; }
.game-icon-lg { font-size: 1.75rem; }

/* ── Code box (token display) ──────────────────────────── */
.code-box {
    background: var(--bg-primary);
    padding: 10px;
    border-radius: 8px;
    word-break: break-all;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.audit-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}
.audit-item:last-child { border-bottom: none; }

/* ── Health bar ─────────────────────────────────────────── */
.health-bar {
    height: 6px;
    border-radius: 3px;
    margin-top: 0.5rem;
    background: #2a2a3a;
    overflow: hidden;
}
.health-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.health-bar-fill.green  { background: linear-gradient(90deg, #2ecc71, #27ae60); }
.health-bar-fill.amber  { background: linear-gradient(90deg, #f39c12, #e67e22); }
.health-bar-fill.red    { background: linear-gradient(90deg, #e74c3c, #c0392b); }

/* ── Offline banner ─────────────────────────────────────── */
.offline-banner {
    background: linear-gradient(135deg, #2a1010, #3a1a1a);
    border-bottom: 1px solid rgba(231, 76, 60, 0.35);
    color: #f0b0b0;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    animation: bannerIn 0.3s ease;
}
.offline-banner span {
    letter-spacing: -0.01em;
}
@keyframes bannerIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert-danger {
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.35);
    color: #f0b0b0;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .hero-title { font-size: 2rem; }
    .hero-logo { width: 72px; height: 72px; }
    .stat-value { font-size: 0.85rem; }
}