@import 'themes.css';

@font-face {
    font-family: 'Armagetronad';
    src: url('Armagetronad.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Legacy Solarized aliases for backward compatibility */
    --base03: var(--bg);
    --base02: var(--bg-alt);
    --base01: var(--border);
    --base00: var(--fg-muted);
    --base0: var(--fg-muted);
    --base1: var(--fg);
    --yellow: var(--warning);
    --orange: var(--warning);
    --red: var(--error);
    --blue: var(--accent);
    --cyan: var(--accent-hover);
    --green: var(--success);
    font-family: 'Armagetronad', "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
}

button,
input,
select,
textarea {
    font-family: inherit;
}

body {
    margin: 0;
    padding: 24px;
    background: var(--bg);
    color: var(--fg);
}

h1 {
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-icon {
    width: 48px;
    height: 48px;
    vertical-align: middle;
}

.header-with-help {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 16px;
    margin-bottom: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.dataset-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.dataset-btn {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--fg);
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dataset-btn:hover {
    background: var(--bg-alt);
    border-color: var(--accent);
    color: var(--accent);
}

.dataset-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: bold;
}

.dataset-btn.active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.help-icon {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--fg);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
}

.help-icon:hover {
    background: var(--bg-alt);
    border-color: var(--accent-hover);
    color: var(--accent-hover);
    transform: scale(1.05);
}

.help-icon:active {
    transform: scale(0.95);
}

.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.help-modal[hidden] {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.help-modal-content {
    background: var(--bg-alt);
    border: 2px solid var(--accent-hover);
    border-radius: 8px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-alt);
    z-index: 1;
}

.help-modal-header h2 {
    color: var(--accent-hover);
    margin: 0;
    font-size: 24px;
}

.help-close {
    background: transparent;
    border: none;
    color: var(--fg);
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
}

.help-close:hover {
    background: var(--border);
    color: var(--error);
}

.help-modal-body {
    padding: 24px;
    color: var(--fg);
    line-height: 1.6;
}

.help-modal-body h3 {
    color: var(--warning);
    margin: 24px 0 12px;
    font-size: 20px;
}

.help-modal-body h3:first-child {
    margin-top: 0;
}

.help-modal-body h4 {
    color: var(--warning);
    margin: 16px 0 8px;
    font-size: 16px;
}

.help-modal-body p {
    margin: 8px 0;
}

.help-modal-body ul {
    margin: 8px 0;
    padding-left: 24px;
}

.help-modal-body li {
    margin: 6px 0;
}

.help-modal-body .formula {
    background: var(--bg);
    border-left: 3px solid var(--accent-hover);
    padding: 12px 16px;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 16px;
}

.help-modal-body strong {
    color: var(--accent-hover);
}

.help-modal-body .value-highlight {
    color: var(--warning);
    font-weight: bold;
}

.panel {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 12px var(--shadow);
}

.controls {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    gap: 6px;
    color: var(--fg-muted);
}

input[type="text"],
input[type="number"],
select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--fg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--fg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 14px;
}

.filter-btn.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    color: var(--accent);
}

.filter-btn:hover {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
}

.errors {
    margin: 12px 0;
    color: var(--warning);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 8px;
    font-size: 14px;
}

thead {
    background: var(--bg-alt);
}

th,
td {
    border: 1px solid var(--border);
    border-top: none;
    border-left: none;
    padding: 10px 8px;
    text-align: left;
}

th:first-child,
td:first-child {
    border-left: 1px solid var(--border);
}

thead tr:first-child th {
    border-top: 1px solid var(--border);
}

th {
    color: var(--fg-muted);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

tbody tr:nth-child(even) {
    background: var(--bg);
}

tbody tr:nth-child(odd) {
    background: var(--bg-elevated);
}

tbody tr:hover {
    background: var(--bg-alt);
}

.summary-row {
    background: var(--bg-alt) !important;
    position: sticky;
    top: 0;
    z-index: 1;
}

.summary-row td {
    font-weight: 500;
    color: var(--accent-hover);
    border-bottom: 2px solid var(--accent-hover);
}

.muted {
    color: var(--fg-muted);
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: color-mix(in srgb, var(--success) 15%, transparent);
    color: var(--success);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
    font-size: 12px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.error-text {
    color: var(--error);
    font-size: 13px;
    min-height: 18px;
}

.logged-player {
    font-weight: 700;
    color: var(--accent);
}

.value-highlight {
    color: var(--success);
    font-weight: 700;
}

.outlier {
    opacity: 0.6;
    font-style: italic;
}

.stats-summary {
    margin: 12px 0;
    font-size: 13px;
    color: var(--fg-muted);
    display: none;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: var(--fg-muted);
}

.pagination button {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--fg);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button:not(:disabled):hover {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
}

@media (max-width: 720px) {
    .header-with-help {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        justify-content: space-between;
        width: 100%;
    }

    .dataset-selector {
        flex: 1;
    }

    .dataset-btn {
        font-size: 13px;
        padding: 6px 10px;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        display: none;
    }

    tbody tr {
        margin: 0 0 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        overflow: hidden;
    }

    td {
        display: grid;
        grid-template-columns: 140px 1fr;
        gap: 8px;
    }

    td::before {
        content: attr(data-label);
        color: var(--fg-muted);
        font-weight: 600;
    }
}

/* Online now link */
.online-now-link {
    color: var(--accent-hover);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-left: 8px;
    padding: 2px 8px;
    border: 1px solid var(--accent-hover);
    border-radius: 4px;
    font-size: 0.9em;
}

.online-now-link:hover {
    background: var(--accent-hover);
    color: var(--bg);
}

/* Online players modal content */
.online-modal-content {
    max-width: 600px;
}

.online-players-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    margin: 0;
    font-family: 'Armagetronad', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
    color: var(--fg);
}

/* ==========================================================================
   THEME DROPDOWN
   ========================================================================== */

.theme-dropdown {
    position: relative;
}

.theme-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 2px solid var(--border);
    color: var(--fg);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.theme-dropdown-toggle:hover {
    background: var(--bg-alt);
    border-color: var(--accent);
    color: var(--accent);
}

.theme-dropdown-toggle .theme-preview {
    display: flex;
    gap: 3px;
}

.theme-dropdown-toggle .chevron {
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.theme-dropdown.open .chevron {
    transform: rotate(180deg);
}

.theme-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 220px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-alt);
    border: 2px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.theme-dropdown.open .theme-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-group-label {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
    border-top: 1px solid var(--border-subtle);
}

.theme-group-label:first-child {
    border-top: none;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    color: var(--fg);
}

.theme-option:hover {
    background: var(--bg-elevated);
}

.theme-option.active {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    color: var(--accent);
}

.theme-preview {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.theme-preview-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
}

.theme-option-name {
    flex: 1;
    font-size: 13px;
}

.theme-option-check {
    opacity: 0;
    color: var(--accent);
    font-size: 14px;
}

.theme-option.active .theme-option-check {
    opacity: 1;
}
