/* === magneticow HandleIT custom dark theme v2 === */

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

:root {
    --bg: #0d1117;
    --bg-card: #161b22;
    --bg-hover: #1c2333;
    --border: #30363d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --red: #f85149;
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }

/* === App Header === */
.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo { font-size: 1.2rem; font-weight: 700; white-space: nowrap; }
.logo b { color: var(--accent); }
.logo sup { font-size: 0.55rem; color: var(--text-muted); }

.search-form {
    flex: 1;
    max-width: 440px;
}
.search-form input {
    width: 100%;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.12);
}
.search-form input::placeholder { color: var(--text-muted); }

.header-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.count-badge {
    background: var(--bg);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    border: 1px solid var(--border);
}

/* === Category Navigation === */
.cat-nav {
    display: flex;
    gap: 0.35rem;
    padding: 1rem 1.5rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 52px;
    z-index: 99;
}
.cat-tab {
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: var(--font);
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.cat-tab:hover { color: var(--text); border-color: var(--text-muted); }
.cat-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.cat-icon { font-size: 0.85rem; }

/* === Torrent Grid === */
.torrent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.torrent-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.torrent-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.card-link {
    position: absolute;
    inset: 0;
    z-index: 2;
}

.card-poster {
    height: 120px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 8px;
    position: relative;
    overflow: hidden;
}
.card-poster::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.6));
}

.quality-badge {
    position: relative;
    z-index: 3;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    color: #fff;
    pointer-events: none;
}
.q-4k { background: #9b59b6; }
.q-1080 { background: #2980b9; }
.q-720 { background: #27ae60; }
.q-br { background: #e67e22; }
.q-web { background: #2ecc71; }
.q-other { background: var(--text-muted); }

.type-badge {
    position: relative;
    z-index: 3;
    font-size: 0.8rem;
    pointer-events: none;
}

.card-body {
    padding: 0.6rem 0.75rem 0.75rem;
    position: relative;
    z-index: 3;
    pointer-events: none;
}
.card-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
}
.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}
.card-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.73rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* === Load More === */
.btn-load-more {
    display: block;
    width: 200px;
    margin: 1.5rem auto 3rem;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-load-more:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.btn-load-more:disabled {
    opacity: 0.5;
    cursor: default;
}

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

/* === Responsive === */
@media (max-width: 600px) {
    .torrent-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
        padding: 0.75rem;
    }
    .app-header {
        flex-wrap: wrap;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    .cat-nav {
        padding: 0.5rem 0.75rem;
        top: 44px;
    }
    .card-poster { height: 90px; }
}

/* === Legacy magneticow pages (search results, stats) === */
body > main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 2rem;
}
body > main > div:first-child {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2rem;
}
body > main > div:first-child b { color: var(--accent); }

body > footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

body > header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
body > header > div:first-child { font-size: 1.15rem; font-weight: 600; white-space: nowrap; }
body > header > div:first-child b { color: var(--accent); }

body > main ul {
    list-style: none;
    padding: 1rem 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}
body > main ul li {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
body > main ul li:hover { background: var(--bg-hover); }
body > main ul li h3 { font-size: 1rem; font-weight: 500; margin-bottom: 0.35rem; }
body > main ul li h3 a { color: var(--text); }
body > main ul li h3 a:hover { color: var(--accent); }

button {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 1rem auto;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
button:hover { background: var(--bg-hover); border-color: var(--accent); }

.statistics {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1.5rem;
}
.statistics table { width: 100%; border-collapse: collapse; }
.statistics td { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.statistics td:last-child { text-align: right; font-weight: 500; }
