/* ═══════════════════════════════════════════════════════════════════════
   CineSearch – Stylesheet
   Dark theme · tag badges · action buttons
   ═══════════════════════════════════════════════════════════════════════ */

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

:root {
    --bg: #0f1117;
    --bg-card: #181a20;
    --bg-input: #1e2028;
    --border: #2a2d38;
    --border-hover: #3a3f4b;
    --text: #e4e6ed;
    --text-dim: #8b8fa3;
    --text-url: #5a5e70;
    --text-name: #e8dcc8;
    --accent: #6c8dfa;
    --accent-hover: #8ba4fb;
    --radius: 10px;
    --radius-sm: 6px;
    --max-width: 760px;
}

/* Light Theme Variables */
:root[data-theme="light"] {
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --text: #1f2937;
    --text-dim: #6b7280;
    --text-url: #4b5563;
    --text-name: #111827;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Utilities ─────────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Container ─────────────────────────────────────────────────────── */
.container {
    position: relative;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 48px 20px 60px;
}

/* ── Header ────────────────────────────────────────────────────────── */
#site-header {
    text-align: center;
    margin-bottom: 32px;
}

.theme-toggle {
    position: absolute;
    top: 24px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .theme-toggle {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .theme-toggle:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.theme-toggle svg {
    display: block;
}

#brand {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

#brand span {
    color: var(--accent);
}

.tagline {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.owner-link {
    font-size: 1rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.owner-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
}

.owner-link a:hover {
    text-decoration: underline;
}

/* ── Search Box ────────────────────────────────────────────────────── */
#search-form {
    margin-bottom: 24px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--accent);
}

.search-icon {
    flex-shrink: 0;
    margin-left: 16px;
    color: var(--text-dim);
    opacity: 0.6;
}

#search-input {
    flex: 1;
    padding: 14px 14px;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
}

#search-input::placeholder {
    color: var(--text-dim);
}

/* ── Search Stats ──────────────────────────────────────────────────── */
.search-stats {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 8px;
    margin-bottom: 24px;
}

/* ── Status Messages ───────────────────────────────────────────────── */
.filters-panel {
    margin-bottom: 24px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filters-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.filters-heading h2 { margin: 0; font-size: 1rem; font-weight: 600; }
#filter-count { color: var(--accent); font-size: 0.8rem; }
.filters-help { color: var(--text-dim); font-size: 0.78rem; margin: 10px 0 12px; }
.filter-group { border-top: 1px solid var(--border); padding: 10px 0; }
.filter-group:last-child { padding-bottom: 0; }
.filter-group summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.filter-options { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 12px 0 0; margin: 0; min-width: 0; }
.filter-option { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.78rem; }
.filter-option:has(input:checked) { border-color: var(--accent); background: var(--bg-input); color: var(--accent); }
.filter-option:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-option input { width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; }

.status {
    text-align: center;
    padding: 20px 0;
    color: var(--text-dim);
    font-size: 0.95rem;
}

.status.error {
    color: var(--danger);
}

/* ── Results ───────────────────────────────────────────────────────── */
#results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item {
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: border-color 0.2s;
}

.result-item:hover {
    border-color: var(--border-hover);
}

/* Filename — warm tone like the sample image */
.result-name {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.55;
    margin-bottom: 8px;
    color: var(--text-name);
}

/* MIME type + date */
.result-meta {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 12px;
}

/* ── Action Buttons Row ────────────────────────────────────────────── */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

/* Tags Wrapper (Inline on desktop, wraps on mobile) */
.tags-group {
    display: contents;
}

/* URL under buttons */
.result-url {
    font-size: 0.72rem;
    color: var(--text-url);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ── Sentinel / Loader ─────────────────────────────────────────────── */
.sentinel {
    height: 20px;
}

.bottom-status {
    text-align: center;
    padding: 24px 0;
    color: var(--text-dim);
    font-size: 0.85rem;
    min-height: 24px;
}

.spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* ── Responsive ────────────────────────────────────────────────────── */
.results-column { min-width: 0; }

@media (min-width: 1024px) {
    .container {
        max-width: 100%;
        display: grid;
        grid-template-columns: minmax(230px, 1fr) minmax(0, 2.6fr) minmax(230px, 1fr);
        column-gap: 24px;
        padding-top: 24px;
        align-items: start;
    }

    #site-header { grid-column: 2; grid-row: 1; position: relative; padding: 0 44px; }
    .theme-toggle { top: 0; right: 0; }
    #search-form { grid-column: 2; grid-row: 2; min-width: 0; }
    .results-column { grid-column: 2; grid-row: 3; }

    .filters-panel {
        grid-column: 1;
        grid-row: 1 / 4;
        position: sticky;
        top: 24px;
        max-height: calc(100vh - 48px);
        overflow-y: auto;
        scrollbar-width: thin;
        margin-bottom: 0;
    }

    .filters-right { grid-column: 3; }
    .filters-heading { flex-wrap: wrap; }
    .filter-options { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .container {
        padding: 32px 14px 48px;
    }

    #brand {
        font-size: 1.65rem;
    }

    .result-item {
        padding: 14px 14px;
    }

    .result-meta {
        font-size: 0.74rem;
    }

    .result-actions {
        gap: 6px;
    }

    /* Force tags to break to a new line on mobile */
    .tags-group {
        display: flex;
        flex-basis: 100%;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 2px;
    }
}
