/* ==========================================
   MOTJOBOOK — Theme Spotify Dark + Gold Accent
   ========================================== */

/* ─── CSS Variables ─── */
:root {
  --bg-primary: #121212;
  --bg-surface: #1a1a1e;
  --bg-surface-hover: #242428;
  --bg-elevated: #2a2a2e;
  --bg-input: #1f1f23;

  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #6a6a6a;

  --gold: #c9a94e;
  --gold-hover: #d4b35a;
  --gold-muted: rgba(201, 169, 78, 0.3);
  --gold-glow: rgba(201, 169, 78, 0.15);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-gold: rgba(201, 169, 78, 0.4);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-pill: 500px;
  --radius-full: 50%;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.2s ease;

  --header-h: 56px;
  --bottom-nav-h: 64px;
  --max-width: 1200px;
  --reader-font-size: 18px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-hover); }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
input, textarea { font-family: var(--font); border: none; outline: none; background: none; color: var(--text-primary); font-size: 16px; }
ul { list-style: none; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }

/* ─── Layout ─── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; padding-top: var(--header-h); padding-bottom: calc(var(--bottom-nav-h) + 16px); }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

/* ─── Header ─── */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
}
.header-inner {
  max-width: var(--max-width); margin: 0 auto;
  width: 100%; display: flex; align-items: center; gap: 12px;
}
.header-logo {
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.header-logo-img { height: 32px; width: auto; object-fit: contain; }
.header-logo .gold { color: var(--gold); }
.header-search {
  flex: 1; max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  display: flex; align-items: center; gap: 8px;
  transition: var(--transition);
}
.header-search:focus-within { border-color: var(--gold-muted); }
.header-search input { flex: 1; background: none; color: var(--text-primary); font-size: 14px; }
.header-search .icon { color: var(--text-muted); font-size: 16px; }
.icon-search { color: var(--text-muted); flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ─── Bottom Navigation (Mobile) ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottom-nav-h);
  background: rgba(18, 18, 18, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 8px;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; color: var(--text-muted); font-size: 10px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  transition: var(--transition); position: relative;
}
.bottom-nav a.active { color: var(--gold); }
.bottom-nav a .nav-icon { font-size: 22px; line-height: 1; }
.bottom-nav a .nav-label { font-size: 10px; font-weight: 500; }

/* ─── Page Container (SPA) ─── */
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Home: Hero Section ─── */
.home-hero {
  padding: 32px 0 24px; text-align: center;
  background: linear-gradient(180deg, rgba(201,169,78,0.08) 0%, transparent 100%);
  margin-bottom: 24px;
}
.hero-logo { margin-bottom: 16px; }
.hero-logo-img { max-width: 180px; margin: 0 auto; }
.hero-logo-text { font-size: 40px; font-weight: 700; display: none; }
.hero-tagline { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.hero-tagline .gold { color: var(--gold); }
.hero-sub { color: var(--text-secondary); font-size: 14px; max-width: 400px; margin: 0 auto; }

/* ─── Category Chips ─── */
.category-scroll {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 0 16px 16px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; max-width: var(--max-width); margin: 0 auto;
}
.category-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
}
.chip.active { background: var(--gold); color: #121212; border-color: var(--gold); font-weight: 600; }
.chip:hover:not(.active) { border-color: var(--text-muted); color: var(--text-primary); }

/* ─── Book Grid ─── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; margin-bottom: 12px; max-width: var(--max-width); margin-left: auto; margin-right: auto;
}
.section-header h2 { font-size: 18px; font-weight: 600; }
.section-header .see-all { font-size: 13px; color: var(--text-muted); }

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}
@media (min-width: 600px) { .book-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .book-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .book-grid { grid-template-columns: repeat(5, 1fr); } }

.book-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.book-card:hover { transform: translateY(-2px); border-color: var(--gold-muted); box-shadow: 0 4px 16px rgba(201,169,78,0.1); }
.book-cover {
  position: relative;
  aspect-ratio: 2/3;
  background: var(--bg-elevated);
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.cover-letter {
  font-size: 48px; font-weight: 700;
  color: rgba(201, 169, 78, 0.3);
  font-family: 'Playfair Display', serif;
}
.book-cover .badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--gold); color: #121212;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-pill);
}
.book-info { padding: 10px 12px 12px; }
.book-title { font-size: 14px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.book-author { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.book-stats { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ─── Buttons ─── */
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-full);
  color: var(--text-muted); transition: var(--transition);
}
.icon-btn:hover { color: var(--text-primary); background: var(--bg-surface); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 600;
  transition: var(--transition); border: none; cursor: pointer;
}
.btn-gold { background: var(--gold); color: #121212; }
.btn-gold:hover { background: var(--gold-hover); }
.btn-outline {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
}
.btn-outline:hover { border-color: var(--gold-muted); color: var(--gold); }
.btn-danger { background: transparent; border: 1px solid rgba(255,70,70,0.4); color: #ff6b6b; border-radius: var(--radius-pill); width: 100%; margin-top: 12px; }
.btn-danger:hover { background: rgba(255,70,70,0.1); }

/* ─── Auth Page ─── */
.auth-page {
  min-height: calc(100vh - var(--header-h) - var(--bottom-nav-h));
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-box {
  width: 100%; max-width: 400px; text-align: center;
}
.auth-box .auth-logo { font-size: 28px; font-weight: 700; margin-bottom: 24px; }
.auth-box h2 { font-size: 20px; margin-bottom: 8px; }
.auth-desc { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.auth-form { text-align: left; }
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.phone-input {
  display: flex; align-items: center; gap: 0;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; transition: var(--transition);
}
.phone-input:focus-within { border-color: var(--gold-muted); }
.phone-prefix {
  padding: 10px 4px 10px 12px; color: var(--text-muted);
  font-size: 14px; font-weight: 500; background: var(--bg-elevated);
}
.phone-input input { flex: 1; padding: 10px 12px; background: none; border: none; color: var(--text-primary); font-size: 16px; }
.input-group input[type="password"],
.input-group input[type="text"],
.input-group input[type="number"] {
  width: 100%; padding: 12px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 16px; transition: var(--transition);
}
.input-group input:focus { border-color: var(--gold-muted); }
.auth-note { font-size: 13px; color: var(--text-muted); margin-top: 12px; text-align: center; }
.auth-loader { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Book Detail ─── */
.book-detail-header {
  background: linear-gradient(180deg, #1a1a2e, var(--bg-primary));
  padding: 24px 16px; text-align: center;
}
.detail-cover-placeholder {
  width: 120px; height: 120px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius-md);
}
.detail-cover-letter {
  font-size: 60px; font-weight: 700;
  color: rgba(201, 169, 78, 0.3);
  font-family: 'Playfair Display', serif;
}
.book-detail-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.detail-section-title { font-size: 14px; color: var(--gold); margin-bottom: 8px; margin-top: 16px; }
.chapter-list { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.chapter-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: var(--transition); cursor: pointer;
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: var(--bg-surface-hover); }
.chapter-item.locked { opacity: 0.6; }
.chapter-item.locked:hover { opacity: 0.8; }
.ch-left { display: flex; align-items: center; gap: 12px; }
.ch-number { font-size: 14px; font-weight: 600; color: var(--gold); width: 28px; }
.ch-title { font-size: 14px; }
.ch-status { font-size: 14px; }

/* ─── Reader ─── */
.reader {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200; background: #0d0d0f;
  display: flex; flex-direction: column;
}
.reader-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(13,13,15,0.95);
  border-bottom: 1px solid var(--border); z-index: 10;
}
.reader-header button { font-size: 14px; color: var(--gold); padding: 4px 8px; }
.reader-title { font-size: 13px; color: var(--text-secondary); text-align: center; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; }
.reader-content {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  -webkit-overflow-scrolling: touch;
}
.reader-text { max-width: 680px; margin: 0 auto; }
.reader-text p {
  font-size: var(--reader-font-size); line-height: 1.8;
  color: #e8e8e8; margin-bottom: 1.2em;
  text-align: justify;
  font-family: 'Georgia', 'Literata', serif;
}
.reader-footer {
  background: rgba(13,13,15,0.95); border-top: 1px solid var(--border);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}
.reader-progress { height: 3px; background: var(--bg-elevated); border-radius: 2px; margin-bottom: 8px; }
.reader-progress-bar { height: 100%; background: var(--gold); border-radius: 2px; width: 0%; transition: width 0.3s ease; }
.reader-chapter-nav { display: flex; align-items: center; justify-content: space-between; }
.reader-chapter-nav button { font-size: 13px; color: var(--gold); padding: 6px 12px; border: 1px solid var(--gold-muted); border-radius: var(--radius-pill); }
.reader-chapter-nav button:disabled { opacity: 0.3; }
.reader-tap-zones {
  position: absolute; top: 56px; left: 0; right: 0; bottom: 90px;
  display: flex; z-index: 5;
}
.tap-zone { flex: 1; }
.tap-zone[data-action="prev"] { cursor: w-resize; }
.tap-zone[data-action="next"] { cursor: e-resize; }

/* ─── Profile Page ─── */
.profile-page { padding: 16px; }
.profile-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
}
.profile-card h2 { font-size: 16px; margin-bottom: 16px; }
.profile-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.profile-row:last-child { border-bottom: none; }
.profile-row .label { font-size: 14px; color: var(--text-muted); }
.profile-row .value { font-size: 14px; font-weight: 600; }
.coin-balance { text-align: center; padding: 16px 0; }
.coin-amount { font-size: 48px; font-weight: 700; color: var(--gold); display: block; line-height: 1; }
.coin-label { font-size: 13px; color: var(--text-muted); }
.btn-group { display: flex; gap: 8px; margin-top: 12px; }
.btn-group .btn { flex: 1; font-size: 13px; padding: 8px 12px; }
.referral-box { display: flex; gap: 8px; margin: 12px 0; }
.referral-box input {
  flex: 1; padding: 10px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 13px;
}
.referral-tiers { margin: 12px 0; }
.tier { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.tier span:last-child { color: var(--text-muted); }
.total-commission { display: flex; justify-content: space-between; padding: 12px 0 0; font-size: 14px; font-weight: 600; border-top: 1px solid var(--border); margin-top: 8px; }
.transaction-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tx-info .tx-desc { font-size: 14px; display: block; }
.tx-info .tx-date { font-size: 12px; color: var(--text-muted); }
.tx-amount { font-size: 14px; font-weight: 600; }
.tx-amount.positive { color: var(--gold); }

/* ─── Buy Coins ─── */
.buy-page { padding: 16px; }
.payment-option { margin: 16px 0; text-align: center; }
.qris-container { max-width: 220px; margin: 12px auto; }
.qris-img { width: 100%; border-radius: var(--radius-md); }
.qris-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.coin-packages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.package-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 20px 16px; text-align: center; cursor: pointer;
  transition: var(--transition);
}
.package-card:hover, .package-card.active { border-color: var(--gold); background: rgba(201,169,78,0.08); }
.package-name { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.package-price { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.package-coin { font-size: 13px; color: var(--text-secondary); }
.bonus { color: var(--gold); font-weight: 600; }
.payment-form { margin-top: 20px; }
.payment-form .btn { width: 100%; }

/* ─── Admin ─── */
.admin-page { padding: 16px; }
.admin-login { max-width: 360px; margin: 0 auto; text-align: center; }
.admin-login h2 { margin-bottom: 20px; }
.admin-dashboard h2 { margin-bottom: 16px; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; text-align: center; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gold); display: block; }
.user-table-container { overflow-x: auto; margin-bottom: 20px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.user-table th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
.user-table td { color: var(--text-secondary); }
.user-table .btn-outline { padding: 4px 10px; font-size: 11px; }

/* ─── Submit Page ─── */
.submit-page { padding: 24px 16px; text-align: center; }
.submit-page h2 { margin-bottom: 12px; }
.submit-howto { text-align: left; margin: 20px 0; }
.step { padding: 12px 16px; margin-bottom: 8px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px; }

/* ─── SPA Reader keyboard handler ─── */
@media (min-width: 768px) {
  .reader-tap-zones { display: none; }
}
@media (max-width: 767px) {
  .reader-tap-zones { display: flex; }
}

/* ─── Text utility ─── */
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.gold { color: var(--gold); }
