/* ============================================
   ARK Tracker — Stylesheet
   Dark theme inspired by BattleMetrics
   ============================================ */

:root {
    --bg-primary: #0f1923;
    --bg-secondary: #1a2332;
    --bg-tertiary: #243044;
    --bg-hover: #2a3a50;
    --accent: #00d4aa;
    --accent-hover: #00b894;
    --text-primary: #e0e0e0;
    --text-secondary: #8492a6;
    --text-muted: #5a6a7a;
    --border: #2a3a4a;
    --green: #00d4aa;
    --red: #ff6b6b;
    --yellow: #ffd93d;
    --blue: #4da6ff;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Header ── */
.main-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-header .container {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.logo:hover { color: var(--accent); }
.logo-icon { font-size: 1.5rem; }

.main-nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.nav-search {
    margin-left: auto;
}

.nav-search .search-input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    width: 220px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.nav-search .search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Main Content ── */
main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* ── Page Header ── */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.back-link {
    display: inline-block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.back-link:hover { color: var(--accent); }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}

.stat-card.accent {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.1), var(--bg-secondary));
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 0.25rem;
}

.stat-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ── Panels ── */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Dashboard Grid ── */
.dashboard-grid {
    display: grid;
    gap: 1.5rem;
}

/* ── Info Grid (Server/Player detail) ── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.info-card.card-online {
    border-color: var(--green);
    background: rgba(0, 212, 170, 0.05);
}

.info-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 1rem;
    font-weight: 600;
}

.info-value a { font-weight: 600; }

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.15);
}

td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.row-offline td {
    opacity: 0.6;
}

.full-table {
    min-width: 800px;
}

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* ── Status Dot ── */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.status-dot.offline {
    background: var(--red);
}

.status-col { width: 40px; text-align: center; }

/* ── Player Bar ── */
.player-bar {
    position: relative;
    background: var(--bg-primary);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
    min-width: 100px;
}

.player-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #00b894);
    border-radius: 4px;
    transition: width 0.3s;
    opacity: 0.3;
}

.player-bar span {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge.map { background: #1a2a3e; color: var(--blue); }
.badge.region { background: #2a1a3e; color: #b48eff; }
.badge.mode-pvp { background: #3a1a1a; color: var(--red); }
.badge.mode-pve { background: #1a3a1a; color: var(--green); }

/* ── Maps Grid ── */
.maps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
}

.map-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.map-name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.map-stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Server Link ── */
.server-link { font-weight: 600; }
.server-ip { font-size: 0.75rem; }
.player-link { font-weight: 600; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--accent);
    color: var(--bg-primary);
    text-decoration: none;
}

.btn:hover { background: var(--accent-hover); color: var(--bg-primary); }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-danger { background: var(--red); }
.btn-danger:hover { background: #ff4444; }

.btn-sm, .btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
}

.btn-sm:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm.btn-danger { background: var(--red); color: white; }

/* ── Search ── */
.search-container {
    max-width: 600px;
    margin: 0 auto 2rem;
    position: relative;
}

.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-input-lg {
    flex: 1;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.1rem;
    transition: border-color 0.2s;
}

.search-input-lg:focus {
    outline: none;
    border-color: var(--accent);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
    display: none;
    z-index: 50;
    max-height: 300px;
    overflow-y: auto;
}

.search-suggestions.active {
    display: block;
}

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--bg-hover); }

.suggestion-name { font-weight: 600; }
.suggestion-server { color: var(--text-muted); font-size: 0.85rem; }

.results-count {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ── Filters ── */
.filters {
    margin-bottom: 1.5rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.filter-group {
    flex: none;
}

.filter-input,
.filter-select {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filter-input { width: 200px; }

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

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.5rem 0;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

.page-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
.page-dots { color: var(--text-muted); padding: 0 0.5rem; }

/* ── Alerts ── */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-error { background: #3a1a1a; color: var(--red); border: 1px solid #4a2a2a; }
.alert-success { background: #1a3a2a; color: var(--green); border: 1px solid #2a4a3a; }

/* ── Admin ── */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-form {
    padding: 1rem 1.25rem;
}

.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-row input[type="text"],
.form-row input[type="url"],
.form-row input[type="number"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

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

.form-row textarea {
    resize: vertical;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

/* ── Chart ── */
#playerChart {
    padding: 1rem;
}

/* ── Error Page ── */
.error-page {
    text-align: center;
    padding: 4rem 0;
}

.error-page h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ── Utility Classes ── */
.muted { color: var(--text-muted); }
.mono { font-family: 'Consolas', 'Monaco', monospace; font-size: 0.85rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }

/* ── Footer ── */
.main-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-top: auto;
    text-align: center;
}

.main-footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-sub {
    font-size: 0.75rem !important;
    margin-top: 0.25rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .main-header .container {
        flex-wrap: wrap;
    }

    .main-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-top: 0.5rem;
    }

    .nav-search {
        order: 2;
    }

    .nav-search .search-input {
        width: 150px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .filter-form {
        flex-direction: column;
    }

    .filter-input,
    .filter-select {
        width: 100%;
    }

    .full-table {
        min-width: 600px;
    }
}

/* ── Health Bar ── */
.health-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.hb-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 0.75rem;
    text-align: center;
}

.hb-circle {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hb-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s;
    z-index: 1;
}

.hb-dot.live {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.hb-dot.dead {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

.hb-dot.loading {
    animation: hb-pulse 1.2s ease-in-out infinite;
}

@keyframes hb-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.hb-ring {
    width: 44px;
    height: 44px;
    transform: rotate(-90deg);
}

.hb-ring circle {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 50.27;
    stroke-dashoffset: 50.27;
    stroke-linecap: round;
    animation: hb-countdown 30s linear forwards;
}

@keyframes hb-countdown {
    from { stroke-dashoffset: 50.27; }
    to { stroke-dashoffset: 0; }
}

.hb-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.hb-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.hb-label.live { color: var(--green); }
.hb-label.dead { color: var(--red); }

.logout-form {
    margin-left: auto;
}

.page-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
}

.btn-logout {
    padding: 0.4rem 1.1rem;
    border-radius: 6px;
    border: 1px solid var(--red);
    background: transparent;
    color: var(--red);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--red);
    color: #fff;
}



@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .search-form {
        flex-direction: column;
    }
}

/* EOS Auth Banner */
.eos-auth-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.eos-auth-banner.eos-ok {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.3);
}
.eos-auth-banner.eos-missing {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
}
.eos-manage-link {
    margin-left: auto;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
}
.eos-manage-link:hover {
    text-decoration: underline;
}

/* ── Tracker / Loader ── */
.loader-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
    color: var(--text-secondary);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.tracker-info-body {
    padding: 1.5rem;
}

.row-highlight {
    background: rgba(0, 212, 170, 0.06) !important;
}

.row-highlight td {
    border-bottom-color: rgba(0, 212, 170, 0.15);
}

.info-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Tracker Player Cards ── */
.tracker-player-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.tracker-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tracker-player-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.tracker-player-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tracker-server-list {
    padding: 0;
}

.tracker-server-list table.compact {
    font-size: 0.85rem;
    margin: 0;
}

.tracker-server-list table.compact th,
.tracker-server-list table.compact td {
    padding: 0.4rem 0.75rem;
}

.tracker-player-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}
