/* ============================================
   boooks.ai — Stylesheet
   Dark literary aesthetic, warm accents
   ============================================ */

:root {
    --bg: #0c0b0f;
    --bg-card: #16151b;
    --bg-card-hover: #1d1c24;
    --bg-input: #1a1920;
    --bg-header: rgba(12,11,15,0.92);
    --border: #2a2833;
    --border-light: #353340;
    --text: #e8e4f0;
    --text-muted: #8a8694;
    --text-dim: #5c586a;
    --accent: #e8a847;
    --accent-hover: #f0bc60;
    --accent-glow: rgba(232,168,71,0.15);
    --upvote: #5ec269;
    --downvote: #d65c5c;
    --danger: #d65c5c;
    --success: #5ec269;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow: 0 2px 20px rgba(0,0,0,0.3);
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    --container: 1200px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

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

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }

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

img { max-width: 100%; display: block; }

/* ---- Header ---- */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 0;
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px; gap: 32px;
}
.logo { display: flex; align-items: baseline; gap: 0; text-decoration: none; }
.logo-text {
    font-family: var(--font-display); font-size: 1.7rem;
    color: var(--text); letter-spacing: -0.02em;
}
.logo-dot { font-family: var(--font-display); font-size: 1.7rem; color: var(--accent); }

.main-nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
    color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
    padding: 6px 14px; border-radius: var(--radius-sm); transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--bg-card); }
.nav-upload {
    color: var(--accent) !important; border: 1px solid var(--accent);
    background: var(--accent-glow);
}
.nav-upload:hover { background: var(--accent); color: var(--bg) !important; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.mobile-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 4px; }

/* User Menu Dropdown */
.user-menu { position: relative; }
.user-menu-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 5px 12px 5px 5px; cursor: pointer; color: var(--text); font-size: 0.85rem;
    transition: border-color 0.2s;
}
.user-menu-btn:hover { border-color: var(--border-light); }
.user-avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-name-sm { font-weight: 500; }
.user-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); min-width: 180px; padding: 6px;
    box-shadow: var(--shadow); z-index: 50;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown a {
    display: block; padding: 8px 14px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 0.85rem; transition: all 0.15s;
}
.user-dropdown a:hover { background: var(--bg-card-hover); color: var(--text); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 22px; border-radius: var(--radius-sm); font-size: 0.9rem;
    font-weight: 600; border: none; cursor: pointer; transition: all 0.2s;
    font-family: var(--font-body); text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--accent); color: #0c0b0f; }
.btn-primary:hover { background: var(--accent-hover); color: #0c0b0f; transform: translateY(-1px); }
.btn-ghost {
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* ---- Forms ---- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; margin-bottom: 6px; font-size: 0.85rem;
    font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 16px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-size: 0.95rem; font-family: var(--font-body);
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { min-height: 120px; resize: vertical; }
.form-select { -webkit-appearance: none; -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%238a8694' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 16px; padding: 10px 14px; background: rgba(214,92,92,0.1); border-radius: var(--radius-sm); }
.form-file-drop {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 32px; text-align: center; cursor: pointer;
    transition: border-color 0.2s; color: var(--text-muted);
}
.form-file-drop:hover { border-color: var(--accent); }

/* ---- Flash Messages ---- */
.flash {
    max-width: var(--container); margin: 16px auto; padding: 12px 20px;
    border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500;
}
.flash-success { background: rgba(94,194,105,0.1); color: var(--success); border: 1px solid rgba(94,194,105,0.2); }
.flash-error { background: rgba(214,92,92,0.1); color: var(--danger); border: 1px solid rgba(214,92,92,0.2); }

/* ---- Hero Section ---- */
.hero {
    text-align: center; padding: 80px 20px 60px;
    background: radial-gradient(ellipse at 50% 0%, rgba(232,168,71,0.08) 0%, transparent 70%);
}
.hero h1 {
    font-family: var(--font-display); font-size: clamp(2.8rem, 6vw, 4.5rem);
    font-weight: 400; line-height: 1.1; margin-bottom: 16px;
    letter-spacing: -0.02em;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 540px; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- Section Headers ---- */
.section { padding: 48px 0; }
.section-header {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 28px; gap: 16px;
}
.section-title {
    font-family: var(--font-display); font-size: 1.8rem; font-weight: 400;
}
.section-link { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

/* ---- Book Grid ---- */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

/* ---- Book Card ---- */
.book-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.book-card:hover {
    transform: translateY(-4px); border-color: var(--border-light);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.book-card-cover {
    aspect-ratio: 2/3; overflow: hidden; position: relative;
    background: var(--bg-input);
}
.book-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card-type {
    position: absolute; top: 10px; right: 10px;
    background: rgba(12,11,15,0.75); backdrop-filter: blur(8px);
    padding: 4px 10px; border-radius: 20px; font-size: 0.7rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.book-card-body { padding: 14px 16px 16px; }
.book-card-title {
    font-family: var(--font-display); font-size: 1.1rem;
    line-height: 1.3; margin-bottom: 4px;
}
.book-card-title a { color: var(--text); }
.book-card-title a:hover { color: var(--accent); }
.book-card-author { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }
.book-card-author a { color: var(--text-muted); }
.book-card-author a:hover { color: var(--accent); }
.book-card-meta {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.78rem; color: var(--text-dim);
}
.book-card-votes {
    display: flex; align-items: center; gap: 4px;
    font-weight: 600; color: var(--accent);
}
.book-card-cat {
    background: var(--bg-input); padding: 2px 8px;
    border-radius: 4px; font-size: 0.72rem;
}

/* ---- Book Detail Page ---- */
.book-detail { padding: 40px 0 60px; }
.book-detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 48px; align-items: start; }
.book-detail-cover {
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4); position: sticky; top: 80px;
}
.book-detail-cover img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.book-detail-info h1 {
    font-family: var(--font-display); font-size: 2.4rem;
    font-weight: 400; line-height: 1.2; margin-bottom: 12px;
}
.book-detail-byline { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.book-detail-byline img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.book-detail-byline span { color: var(--text-muted); font-size: 0.9rem; }
.book-detail-byline a { font-weight: 600; }
.book-detail-stats {
    display: flex; gap: 24px; margin-bottom: 28px;
    padding-bottom: 28px; border-bottom: 1px solid var(--border);
}
.stat { text-align: center; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.book-detail-desc { font-size: 1rem; line-height: 1.8; color: var(--text-muted); margin-bottom: 32px; }
.book-detail-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 32px; }
.book-detail-meta { font-size: 0.85rem; color: var(--text-dim); }
.book-detail-meta dt { font-weight: 600; color: var(--text-muted); display: inline; }
.book-detail-meta dd { display: inline; margin: 0 20px 8px 4px; }

/* ---- Vote Buttons ---- */
.vote-box { display: flex; align-items: center; gap: 4px; }
.vote-btn {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; color: var(--text-muted);
}
.vote-btn:hover { border-color: var(--border-light); color: var(--text); }
.vote-btn.active-up { background: rgba(94,194,105,0.12); border-color: var(--upvote); color: var(--upvote); }
.vote-btn.active-down { background: rgba(214,92,92,0.12); border-color: var(--downvote); color: var(--downvote); }
.vote-score { font-weight: 700; font-size: 1.1rem; min-width: 40px; text-align: center; }

/* ---- Categories Grid ---- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.cat-card {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-weight: 500;
    transition: all 0.2s; font-size: 0.9rem;
}
.cat-card:hover { border-color: var(--accent); background: var(--bg-card-hover); color: var(--text); }
.cat-icon { font-size: 1.3rem; }
.cat-count { margin-left: auto; font-size: 0.75rem; color: var(--text-dim); }

/* ---- Filter/Sort Bar ---- */
.filter-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 28px;
}
.filter-bar .form-select { width: auto; padding: 8px 36px 8px 14px; font-size: 0.85rem; }
.filter-bar .form-input { width: auto; min-width: 220px; padding: 8px 14px; font-size: 0.85rem; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
    padding: 6px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
    transition: all 0.2s; text-decoration: none;
}
.pill:hover, .pill.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* ---- Profile Page ---- */
.profile-header {
    display: flex; align-items: center; gap: 28px;
    padding: 40px 0 32px; border-bottom: 1px solid var(--border); margin-bottom: 32px;
}
.profile-avatar { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); }
.profile-info h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 400; }
.profile-info .username { color: var(--text-muted); font-size: 0.9rem; }
.profile-bio { color: var(--text-muted); font-size: 0.9rem; margin-top: 6px; max-width: 500px; }
.profile-stats { display: flex; gap: 24px; margin-top: 12px; }
.profile-stats .stat-value { font-size: 1.1rem; }

/* ---- Leaderboard ---- */
.leaderboard-table {
    width: 100%; border-collapse: collapse;
}
.leaderboard-table th {
    text-align: left; padding: 12px 16px; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-dim); border-bottom: 1px solid var(--border);
}
.leaderboard-table td {
    padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.leaderboard-table tr:hover td { background: var(--bg-card); }
.lb-rank { font-weight: 700; color: var(--accent); font-size: 1.1rem; width: 60px; }
.lb-user { display: flex; align-items: center; gap: 12px; }
.lb-user img { width: 36px; height: 36px; border-radius: 50%; }
.lb-medal { font-size: 1.3rem; }

/* ---- Auth Pages ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 64px); padding: 40px 20px; }
.auth-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 440px;
}
.auth-card h1 {
    font-family: var(--font-display); font-size: 2rem; font-weight: 400;
    text-align: center; margin-bottom: 8px;
}
.auth-card .auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 0.9rem; }
.auth-card .auth-footer { text-align: center; margin-top: 20px; font-size: 0.85rem; color: var(--text-dim); }

/* ---- Comments ---- */
.comments { margin-top: 40px; }
.comment {
    display: flex; gap: 14px; padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.comment-body { flex: 1; }
.comment-meta { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 4px; }
.comment-meta a { font-weight: 600; color: var(--text-muted); }
.comment-text { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; justify-content: center; padding: 40px 0 20px; }
.pg-btn {
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 0.85rem; font-weight: 500;
    transition: all 0.2s; text-decoration: none;
}
.pg-btn:hover { border-color: var(--border-light); color: var(--text); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-dim);
}
.empty-state h3 { font-family: var(--font-display); font-size: 1.5rem; color: var(--text-muted); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* ---- Upload Page ---- */
.upload-page { max-width: 700px; margin: 0 auto; padding: 40px 0 60px; }
.upload-page h1 { font-family: var(--font-display); font-size: 2.2rem; margin-bottom: 8px; }
.upload-page .subtitle { color: var(--text-muted); margin-bottom: 32px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .main-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-direction: column; padding: 12px; }
    .main-nav.open { display: flex; }
    .mobile-toggle { display: block; }
    .user-name-sm { display: none; }
    .hero h1 { font-size: 2.2rem; }
    .book-detail-grid { grid-template-columns: 1fr; }
    .book-detail-cover { position: static; max-width: 300px; }
    .profile-header { flex-direction: column; text-align: center; }
    .profile-stats { justify-content: center; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
    .cat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .btn-primary, .btn-ghost { font-size: 0.82rem; padding: 8px 16px; }
}
