/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --bg:          #0d1117;
    --surface:     #161b22;
    --surface-2:   #21262d;
    --border:      #30363d;
    --text:        #e6edf3;
    --text-muted:  #8b949e;
    --accent:      #58a6ff;
    --accent-dim:  #1f6feb;
    --high:        #3fb950;
    --mid:         #e3b341;
    --low:         #f85149;
    --sidebar-w:   230px;
    --radius:      8px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
ul { list-style: none; }

.muted { color: var(--text-muted); }
.bold  { font-weight: 600; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    z-index: 100;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
}

.page-inner {
    padding: 2rem 2.5rem;
    max-width: 1200px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.brand-icon { font-size: 2rem; line-height: 1; }
.brand-name { font-weight: 700; font-size: 1.05rem; }

.bot-status {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

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

.bot-status.online { color: var(--high); }
.bot-status.offline { color: var(--text-muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; padding: 0 0.75rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background: var(--accent-dim);
    color: var(--text);
}

.nav-icon { font-size: 1.1rem; }

/* ── Page title ──────────────────────────────────────────────────────────────── */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Stats grid ──────────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ── Dashboard grid ──────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

.span-2 { grid-column: 1; }
.side-cards { display: flex; flex-direction: column; gap: 1rem; }

/* ── Review feed ─────────────────────────────────────────────────────────────── */
.review-feed { padding: 0.5rem 0; }

.feed-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--surface-2); }

.feed-poster {
    width: 40px;
    height: 56px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--surface-2);
}

.feed-poster img { width: 100%; height: 100%; object-fit: cover; }
.feed-poster.small { width: 32px; height: 46px; }

.poster-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    background: var(--surface-2);
}

.poster-placeholder.small { font-size: 1rem; }

.feed-info { flex: 1; min-width: 0; }

.feed-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-title a { color: var(--text); }
.feed-title a:hover { color: var(--accent); text-decoration: none; }

.feed-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
}

/* ── Highlight block ──────────────────────────────────────────────────────────── */
.highlight-block {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.big-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

.big-name:hover { color: var(--accent); text-decoration: none; }

/* ── Simple list ─────────────────────────────────────────────────────────────── */
.simple-list { padding: 0.5rem 0; }

.simple-list li {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.simple-list li:last-child { border-bottom: none; }
.simple-list li a { color: var(--text); }
.simple-list li a:hover { color: var(--accent); text-decoration: none; }
.simple-list .muted { font-size: 0.8rem; margin-top: 0.1rem; }

/* ── Rating badge ─────────────────────────────────────────────────────────────── */
.rating-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text);
    white-space: nowrap;
}

.rating-badge.high { background: #1a4a1f; color: var(--high); }
.rating-badge.mid  { background: #3d2f0a; color: var(--mid); }
.rating-badge.low  { background: #3d0e0a; color: var(--low); }
.rating-badge.large { font-size: 1rem; padding: 0.25rem 0.75rem; }

/* ── User link ───────────────────────────────────────────────────────────────── */
.user-link { color: var(--accent); font-weight: 500; }
.user-link:hover { text-decoration: underline; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    background: var(--accent-dim);
    color: var(--text);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; text-decoration: none; }

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

.btn.small { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    align-items: center;
}

.filter-input {
    flex: 1;
    min-width: 200px;
    padding: 0.45rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}

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

.filter-select {
    padding: 0.45rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

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

.results-count { font-size: 0.85rem; margin-bottom: 1rem; }

/* ── Title card grid ─────────────────────────────────────────────────────────── */
.title-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.25rem;
}

.title-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: block;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s;
    text-decoration: none;
}

.title-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
}

.card-poster-wrap {
    position: relative;
    aspect-ratio: 2/3;
    background: var(--surface-2);
    overflow: hidden;
}

.card-poster {
    width: 100%; height: 100%;
    object-fit: cover;
}

.card-poster-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem;
}

.card-rating-badge {
    position: absolute;
    bottom: 0.5rem; right: 0.5rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(0,0,0,0.75);
    color: var(--text);
}

.card-rating-badge.high { color: var(--high); }
.card-rating-badge.mid  { color: var(--mid); }
.card-rating-badge.low  { color: var(--low); }

.card-body { padding: 0.65rem 0.75rem; }
.card-title { font-weight: 600; font-size: 0.88rem; line-height: 1.3; }
.card-year  { font-size: 0.8rem; margin-top: 0.1rem; }
.card-meta  { font-size: 0.78rem; margin-top: 0.25rem; line-height: 1.4; }

.genre-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.4rem; }

.genre-tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ── Title hero ──────────────────────────────────────────────────────────────── */
.title-hero {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.hero-poster {
    width: 200px;
    flex-shrink: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.hero-poster-placeholder {
    width: 200px;
    aspect-ratio: 2/3;
    flex-shrink: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem;
}

.hero-info { flex: 1; }

.hero-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.year-label { font-weight: 400; font-size: 1.3rem; }
.hero-aka { font-size: 0.9rem; margin-bottom: 1rem; }

.hero-meta { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }

.meta-item { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.meta-label { color: var(--text-muted); min-width: 100px; }

/* ── Reviews in title page ───────────────────────────────────────────────────── */
.season-block { border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
.season-block:last-child { border-bottom: none; }

.season-label {
    padding: 0.75rem 1.25rem 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.review-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.review-row:last-child { border-bottom: none; }
.reviewer-name { font-weight: 600; color: var(--text); min-width: 120px; }
.reviewer-name:hover { color: var(--accent); text-decoration: none; }

.review-note {
    width: 100%;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.3rem 0 0 0;
    border-left: 2px solid var(--border);
    padding-left: 0.75rem;
    margin-top: 0.25rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.ext-link { font-size: 0.8rem; color: var(--text-muted); }
.ext-link:hover { color: var(--accent); }

/* ── Leaderboard table ───────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

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

.data-table tr.top-row td { background: rgba(88, 166, 255, 0.04); }

.rank-cell { font-size: 1.1rem; text-align: center; width: 50px; }
.number-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* ── User page ───────────────────────────────────────────────────────────────── */
.user-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.user-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.user-name { font-size: 1.6rem; font-weight: 700; }

.user-stats-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.divider { color: var(--border); }

/* ── Top list ─────────────────────────────────────────────────────────────────── */
.top-list { padding: 0.5rem 0; }

.top-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.top-list li:last-child { border-bottom: none; }

.top-rank { font-size: 1.1rem; flex-shrink: 0; min-width: 28px; }

.top-title {
    flex: 1;
    color: var(--text);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-title:hover { color: var(--accent); text-decoration: none; }

/* ── Two column layout ───────────────────────────────────────────────────────── */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ── Usage bars ─────────────────────────────────────────────────────────────── */
.usage-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.usage-bar-row:last-child { margin-bottom: 0; }

.usage-bar-label {
    min-width: 110px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.usage-bar-track {
    flex: 1;
    height: 22px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--accent-dim);
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.3s ease;
}

.usage-bar-count {
    min-width: 40px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Active filter button ──────────────────────────────────────────────────── */
.active-filter {
    background: var(--accent-dim);
    color: var(--text);
    border-color: var(--accent);
}

/* ── Sidebar footer ─────────────────────────────────────────────────────────── */
.sidebar-footer {
    margin-top: auto;
    padding: 0 0.75rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

/* ── Flash messages ─────────────────────────────────────────────────────────── */
.flash {
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: var(--surface);
}

.flash.success { border-color: var(--high); color: var(--high); background: #1a4a1f; }
.flash.error   { border-color: var(--low);  color: var(--low);  background: #3d0e0a; }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 360px;
}

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

.login-header h1 { font-size: 1.3rem; font-weight: 700; }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ── Admin edit form ────────────────────────────────────────────────────────── */
.edit-form { padding: 1.25rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* ── Admin buttons ──────────────────────────────────────────────────────────── */
.admin-btn { margin-left: auto; }

.btn-danger {
    background: #3d0e0a;
    color: var(--low);
    border: 1px solid var(--low);
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.15s;
}

.btn-danger:hover { opacity: 0.85; }

/* ── Search form ────────────────────────────────────────────────────────────── */
.sidebar-search {
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.sidebar-search form { display: flex; }

.sidebar-search .filter-input {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius);
}

/* ── Needs attention ────────────────────────────────────────────────────────── */
.attention-badge {
    display: inline-block;
    background: #3d2f0a;
    color: var(--mid);
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Mobile responsive ─────────────────────────────────────────────────────── */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.5rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    line-height: 1;
}

@media (max-width: 768px) {
    .mobile-toggle { display: block; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 150;
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 140;
    }

    .sidebar-overlay.open { display: block; }

    .main-content { margin-left: 0; }

    .page-inner { padding: 1rem; padding-top: 3.5rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem; }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .two-col { grid-template-columns: 1fr; }

    .title-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }

    .title-hero { flex-direction: column; gap: 1rem; }
    .hero-poster { width: 140px; }
    .hero-poster-placeholder { width: 140px; }
    .hero-title { font-size: 1.4rem; }

    .filter-bar { flex-direction: column; }
    .filter-input { min-width: 0; }
    .filter-select { width: 100%; }

    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 0.5rem 0.6rem; }

    .user-header { flex-direction: column; text-align: center; }

    .review-row { font-size: 0.85rem; }
    .reviewer-name { min-width: auto; }

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

    .usage-bar-label { min-width: 80px; font-size: 0.8rem; }
}
