:root {
    --bg: #0f1117;
    --bg-card: #171a23;
    --border: #2a2e3a;
    --accent: #4a7bff;
    --text: #e4e6eb;
    --text-dim: #8b8f9c;
    --green: #4ade80;
    --red: #f87171;
    --yellow: #facc15;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.2em; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-logo { height: 28px; width: auto; }

.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4em; cursor: pointer; }

.quota-chip {
    font-size: 0.82em;
    color: var(--text-dim);
    background: rgba(74,123,255,0.1);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .nav-menu-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        right: 20px;
        top: 56px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 8px;
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        z-index: 10;
    }
    .nav-links.open { display: flex; }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

h1, h2, h3 { margin-top: 0; }

input[type="text"], input[type="password"], input[type="number"] {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 1em;
    width: 100%;
}

label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 0.9em; }

button, .btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 1em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
button:hover, .btn:hover { opacity: 0.9; text-decoration: none; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--red); }
.btn-sm { padding: 6px 10px; font-size: 0.85em; }

.search-form { display: flex; gap: 10px; margin-bottom: 20px; }
.search-form input { flex: 1; }

.result-list { list-style: none; padding: 0; margin: 0; }
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    border-bottom: 1px solid var(--border);
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: rgba(255,255,255,0.03); }

.badge {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
}
.badge-full { background: #1a3a2a; color: var(--green); }
.badge-partial { background: #3a3a1a; color: var(--yellow); }

.quality-list { list-style: none; padding: 0; margin: 0; }
.quality-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.quality-item.on-plex { opacity: 0.6; }
.quality-item:last-child { border-bottom: none; }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.flash-error { background: #3a1a1a; color: var(--red); border: 1px solid #5a2a2a; }

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 12px 22px;
    border-radius: 8px;
    z-index: 100;
    transition: opacity 0.4s;
}
.toast.fade-out { opacity: 0; }

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.back-link { display: inline-block; margin-bottom: 16px; }

.muted { color: var(--text-dim); }
.center-text { text-align: center; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-size: 0.85em; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.checkbox-row label { margin: 0; color: var(--text); cursor: pointer; }

.user-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
}
.user-row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.user-row-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field-group { min-width: 120px; }

/* ─── Hero section (search page) ─────────────────────────────────────────── */

.hero {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    padding: 88px 38px 62px;
    margin-bottom: 28px;
    margin-left: auto;
    margin-right: auto;
    max-width: 800px;
    text-align: center;
    background:
        radial-gradient(ellipse at top, rgba(74,123,255,0.18) 0%, transparent 60%),
        linear-gradient(180deg, #151826 0%, #0f1117 100%);
    border: 1px solid var(--border);
    isolation: isolate;
}

/* When there's no active search yet, this wrapper fills the remaining
   viewport height and vertically centers the (fixed-size) hero box inside
   it — a proper landing-page feel instead of sitting pinned to the top.
   The hero box itself has a max-width above so it stays a reasonable
   rectangle on large/4K monitors instead of stretching edge to edge. */
.hero-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 57px - 40px - 28px); /* viewport - topbar - container padding - margin */
}

.hero-wrapper .hero { margin-bottom: 0; }

@media (max-width: 640px) {
    .hero-wrapper { min-height: calc(100vh - 57px - 40px - 28px); }
}

.hero-logo-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    max-width: 90%;
    transform: translate(-50%, -50%);
    opacity: 0.08;
    filter: blur(1px) saturate(1.4);
    pointer-events: none;
    z-index: 0;
    animation: float 8s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -52%) scale(1.03); }
}

.hero-text {
    position: relative;
    z-index: 1;
    margin-bottom: 35px;
}

.hero-title {
    font-size: 2.5em;
    font-weight: 800;
    margin: 0 0 12px;
    background: linear-gradient(90deg, #e4e6eb 0%, #9fb8ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.hero-subtitle {
    color: var(--text-dim);
    font-size: 1.3em;
    margin: 0;
}

.quota-pill {
    display: inline-block;
    margin-top: 16px;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--green);
    background: rgba(74,222,128,0.1);
    border: 1px solid rgba(74,222,128,0.3);
    border-radius: 20px;
    padding: 7px 18px;
}
.quota-pill.quota-low { color: var(--yellow); background: rgba(250,204,21,0.1); border-color: rgba(250,204,21,0.3); }
.quota-pill.quota-empty { color: var(--red); background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); }

.hero-search {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
    margin-bottom: 0;
}

.hero-search input[type="text"] {
    padding: 17px 22px;
    font-size: 1.3em;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.hero-search button {
    padding: 17px 30px;
    font-size: 1.15em;
    border-radius: 10px;
    font-weight: 600;
}

@media (max-width: 640px) {
    .hero { padding: 50px 18px 36px; }
    .hero-title { font-size: 1.8em; }
    .hero-subtitle { font-size: 1.1em; }
    .hero-logo-bg { width: 400px; }
    .hero-search { flex-direction: column; }
}
