/* ── VoteBot Dashboard ─────────────────────────────────────────────── */

:root {
    --accent: #7c5cfc;
    --accent-hover: #6a4ce0;
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --muted: #6b7280;
    --surface: #1a1b23;
    --surface-raised: #22232e;
    --surface-hover: #2a2b38;
    --border: #2e2f3e;
    --text: #e2e4ea;
    --text-dim: #9ca3af;
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 150ms ease;
}

/* Override Pico defaults */
[data-theme="dark"] {
    --pico-background-color: #111118;
    --pico-card-background-color: var(--surface);
    --pico-card-border-color: var(--border);
    --pico-primary: var(--accent);
    --pico-primary-hover: var(--accent-hover);
    --pico-muted-border-color: var(--border);
}

body {
    background: #111118;
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Nav ──────────────────────────────────────────────────────────── */

nav.container-fluid {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

nav .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    text-decoration: none;
}

nav .brand svg {
    width: 22px;
    height: 22px;
}

nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}

nav a:hover, nav a.active {
    color: var(--text);
    background: var(--surface-hover);
}

nav .user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    background: var(--surface-hover);
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Main ─────────────────────────────────────────────────────────── */

main.container {
    max-width: 1100px;
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}

footer.container {
    text-align: center;
    padding: 1.5rem 0 2rem;
    color: var(--muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ── Headings ─────────────────────────────────────────────────────── */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ── Stats Row ────────────────────────────────────────────────────── */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

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

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

.stat-card.stat-green .stat-value { color: var(--green); }
.stat-card.stat-red .stat-value { color: var(--red); }
.stat-card.stat-yellow .stat-value { color: var(--yellow); }
.stat-card.stat-accent .stat-value { color: var(--accent); }

/* ── Cards / Articles ─────────────────────────────────────────────── */

article, .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    margin-bottom: 1rem;
}

article header, .card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-raised);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

article header strong, .card-header strong {
    font-size: 0.9rem;
}

.card-body {
    padding: 1rem;
}

/* ── Add Player Form ──────────────────────────────────────────────── */

.add-form {
    padding: 1rem;
}

.add-form fieldset {
    margin: 0;
    border: 0;
    padding: 0;
}

.add-form input {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.add-form button {
    white-space: nowrap;
}

/* ── Player Card ──────────────────────────────────────────────────── */

.player-card {
    margin-bottom: 1rem;
}

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

.player-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-header h3 a {
    color: var(--text);
    text-decoration: none;
}

.player-header h3 a:hover {
    color: var(--accent);
}

.player-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.player-actions button, .btn {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
}

.player-actions button:hover, .btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--text-dim);
}

.btn-primary {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

.btn-primary:hover {
    background: var(--accent-hover) !important;
}

.btn-danger {
    color: var(--red) !important;
    border-color: color-mix(in srgb, var(--red) 40%, transparent) !important;
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--red) 12%, transparent) !important;
    border-color: var(--red) !important;
}

.btn-success {
    color: var(--green) !important;
    border-color: color-mix(in srgb, var(--green) 40%, transparent) !important;
}

.btn-success:hover {
    background: color-mix(in srgb, var(--green) 12%, transparent) !important;
    border-color: var(--green) !important;
}

/* ── Site Grid ────────────────────────────────────────────────────── */

.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.6rem;
    padding: 0.85rem 1rem;
}

.site-status {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    transition: border-color var(--transition);
    position: relative;
}

.site-status::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.site-success::before { background: var(--green); }
.site-already_voted::before { background: var(--yellow); }
.site-error::before, .site-captcha_failed::before { background: var(--red); }
.site-paused { opacity: 0.45; }

.site-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.site-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.site-success .site-badge { color: var(--green); }
.site-already_voted .site-badge { color: var(--yellow); }
.site-error .site-badge, .site-captcha_failed .site-badge { color: var(--red); }

.site-meta {
    font-size: 0.68rem;
    color: var(--text-dim);
}

.fail-count {
    font-size: 0.68rem;
    color: var(--red);
    font-weight: 600;
}

.fail-warning { border-color: color-mix(in srgb, var(--orange) 50%, transparent) !important; }
.fail-critical { border-color: color-mix(in srgb, var(--red) 50%, transparent) !important; }

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-grey { background: #333; color: #999; }
.badge-green { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge-yellow { background: color-mix(in srgb, var(--yellow) 15%, transparent); color: var(--yellow); }
.badge-red { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.badge-accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

/* ── Pending Approval ─────────────────────────────────────────────── */

.pending-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
}

.pending-row:last-child { border-bottom: 0; }

.pending-row strong {
    font-size: 0.9rem;
}

.pending-row small {
    color: var(--text-dim);
    flex: 1;
}

/* ── Tables ───────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0;
}

thead {
    background: var(--surface-raised);
}

thead th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }

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

tbody tr.row-paused { opacity: 0.45; }
tbody tr.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
tbody tr.row-critical td:first-child { box-shadow: inset 3px 0 0 var(--red); }

/* Status pills in tables */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill.pill-success { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.status-pill.pill-cooldown { background: color-mix(in srgb, var(--yellow) 15%, transparent); color: var(--yellow); }
.status-pill.pill-error { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.status-pill.pill-captcha { background: color-mix(in srgb, var(--orange) 15%, transparent); color: var(--orange); }
.status-pill.pill-pending { background: #333; color: #888; }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.pill-success .status-dot { background: var(--green); }
.pill-cooldown .status-dot { background: var(--yellow); }
.pill-error .status-dot { background: var(--red); }
.pill-captcha .status-dot { background: var(--orange); }
.pill-pending .status-dot { background: #666; }

td .msg-text {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    color: var(--text-dim);
    font-size: 0.8rem;
}

td .time-text {
    white-space: nowrap;
    color: var(--text-dim);
    font-size: 0.8rem;
}

td .duration-text {
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    font-size: 0.8rem;
}

td a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

td a:hover {
    text-decoration: underline;
}

/* ── Filter Bar ───────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-bar select, .filter-bar input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
    flex: 1;
    min-width: 140px;
}

.filter-bar button {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* ── Pagination ───────────────────────────────────────────────────── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0;
    font-size: 0.85rem;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.pagination a:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.pagination .page-current {
    color: var(--text-dim);
    font-weight: 500;
}

/* ── Live Indicator ───────────────────────────────────────────────── */

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

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

/* ── Login Page ───────────────────────────────────────────────────── */

.login-card {
    max-width: 400px;
    margin: 6rem auto 2rem;
    text-align: center;
}

.login-card .login-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: var(--accent);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card h2 {
    font-size: 1.3rem;
    margin: 0 0 0.5rem;
}

.login-card p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.discord-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: #5865f2;
    color: #fff;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: background var(--transition);
    border: none;
    cursor: pointer;
}

.discord-btn:hover {
    background: #4752c4;
    color: #fff;
}

.discord-btn svg {
    width: 20px;
    height: 20px;
}

.error-text {
    color: var(--red);
    margin-top: 1rem;
    font-size: 0.85rem;
}

/* ── Toast / Live Update Flash ────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: toast-in 300ms ease forwards;
    pointer-events: auto;
    max-width: 360px;
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-info { border-left: 3px solid var(--accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .site-grid { grid-template-columns: 1fr 1fr; }
    .player-header { flex-direction: column; align-items: flex-start; }
    .player-actions { width: 100%; }
    td .msg-text { max-width: 160px; }
}

@media (max-width: 480px) {
    .site-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    nav.container-fluid { padding: 0.5rem 0.75rem; }
    nav a { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
}
