/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
  /* Color Palette - Emerald Theme */
  --primary: #059669; /* Emerald 600 - Main Green */
  --primary-dark: #047857; /* Emerald 700 - Hover State */
  --primary-light: #34d399; /* Emerald 400 - Accents */

  /* Surfaces */
  --bg-body: #f3f4f6; /* Light Gray Background */
  --bg-surface: #ffffff; /* White Card/Navbar */
  --bg-glass: rgba(255, 255, 255, 0.9); /* Transparan untuk Navbar */

  /* Typography */
  --text-main: #111827; /* Almost Black */
  --text-secondary: #4b5563; /* Dark Gray */
  --text-light: #9ca3af; /* Light Gray */

  /* UI Elements */
  --border: #e5e7eb;
  --radius-lg: 24px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* Shadows - Soft & Modern */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  /* Fonts */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  --font-serif: "Amiri", serif;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --primary: #10b981;
  --primary-dark: #059669;
  --bg-body: #0f172a; /* Slate 900 */
  --bg-surface: #1e293b; /* Slate 800 */
  --bg-glass: rgba(30, 41, 59, 0.9);
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-light: #64748b;
  --border: #334155;
}

/* =========================================
   2. GLOBAL RESET & BASE STYLES
   ========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Agar footer selalu di bawah */
}

/* Main Layout Helpers */
main {
  flex: 1;
} /* Mendorong footer ke bawah */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.mini-container {
  max-width: 600px;
  margin: 0 auto;
}
.hidden {
  display: none !important;
}
.text-muted {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.text-center {
  text-align: center;
}

/* =========================================
   3. COMPONENTS (Buttons & Inputs)
   ========================================= */

/* Base Button Style */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

/* Primary Button (Hijau Solid) */
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 6px rgba(5, 150, 105, 0.25);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(5, 150, 105, 0.3);
}

/* Secondary Button (Ghost Button - Cek Status) */
.btn-text {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent; /* Menjaga layout stabil */
}
.btn-text:hover {
  background: rgba(5, 150, 105, 0.1); /* Background hijau tipis saat hover */
  color: var(--primary);
  transform: translateY(-1px);
}
.btn-text i {
  color: var(--primary);
}

/* Back Button */
.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  transition: 0.2s;
}
.btn-back:hover {
  color: var(--primary);
  transform: translateX(-3px);
}

/* Inputs */
input,
select,
textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1rem;
  outline: none;
  transition: 0.2s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); /* Ring Hijau */
}

/* Pills (Kategori) */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.pill {
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: 0.2s;
}
.pill:hover {
  background: rgba(255, 255, 255, 0.25);
}
.pill.active {
  background: white;
  color: var(--primary-dark);
  font-weight: 700;
  border-color: white;
}

/* =========================================
   4. NAVBAR (Glassmorphism)
   ========================================= */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 0;
}
.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}
.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--white);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.brand-text {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand-text .highlight {
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}
.btn-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 50%;
  transition: 0.2s;
}
.btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* =========================================
   5. HERO SECTION (UPDATED LAYOUT & IMAGE)
   ========================================= */
.hero-section {
  background: linear-gradient(135deg, var(--primary) 0%, #064e3b 100%);
  padding: 4rem 0 7rem; /* Padding bawah ditambah agar tidak tertabrak kartu */
  color: white;
  border-radius: 0 0 3rem 3rem;
  margin-bottom: -4rem;
  position: relative;
  box-shadow: 0 10px 30px -10px rgba(5, 150, 105, 0.4);
  overflow: hidden;
}

/* New Layout for Side-by-Side */
.hero-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.hero-content {
  flex: 1;
  max-width: 600px;
}

.hero-text h1 {
  font-size: 2.75rem;
  margin-bottom: 1rem;
  letter-spacing: -1px;
  line-height: 1.2;
}
.hero-text p {
  opacity: 0.9;
  font-size: 1.15rem;
  margin-bottom: 2rem;
}

/* Hero Image Styling */
.hero-image {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 45%;
}

.hero-image img {
  width: 100%;
  max-width: 380px; /* Batasi ukuran maksimal gambar */
  height: auto;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2)); /* Bayangan lembut */
  animation: floatImage 3s ease-in-out infinite; /* Animasi melayang */
}

/* Animasi Floating */
@keyframes floatImage {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

/* Search Bar */
.search-wrapper {
  position: relative;
  max-width: 100%;
  margin-bottom: 1rem;
}
.search-wrapper input {
  border: none;
  padding-left: 3rem;
  padding-right: 1.5rem;
  height: 3.5rem;
  border-radius: 50px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  font-size: 1rem;
  color: var(--text-main);
}
.search-icon {
  position: absolute;
  left: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 1.2rem;
}

/* =========================================
   6. CARDS & LIST
   ========================================= */
.content-wrapper {
  padding-bottom: 4rem;
  position: relative;
  z-index: 2;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  height: 100%;
  position: relative;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(5, 150, 105, 0.3);
}

.card-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.badge-cat {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  background: #ecfdf5;
  color: var(--primary-dark);
}
[data-theme="dark"] .badge-cat {
  background: rgba(5, 150, 105, 0.2);
  color: var(--primary-light);
}

.card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}
.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-action {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-light);
}
.read-more {
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: gap 0.2s;
}
.card:hover .read-more {
  gap: 0.8rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-light);
}
.empty-state img {
  width: 80px;
  margin-bottom: 1rem;
  opacity: 0.6;
}

/* =========================================
   7. PAGINATION CONTROLS (NEW)
   ========================================= */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3rem;
}

.page-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.page-btn:hover:not(.disabled):not(.active) {
  border-color: var(--primary);
  color: var(--primary);
  background: #ecfdf5;
}

[data-theme="dark"] .page-btn:hover:not(.disabled):not(.active) {
  background: rgba(5, 150, 105, 0.1);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.page-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--border);
  color: var(--text-secondary);
}

/* =========================================
   8. FORM & TRACKING
   ========================================= */
.form-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-top: 2rem;
}
.input-group {
  margin-bottom: 1.2rem;
}
.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.check-group {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  cursor: pointer;
}
.check-group input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

/* Tracking Items */
.track-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-bottom: 1rem;
  transition: 0.2s;
}
.track-item:hover:not(.pending) {
  border-color: var(--primary);
  background: #f0fdf4;
  cursor: pointer;
}
[data-theme="dark"] .track-item:hover:not(.pending) {
  background: #064e3b;
}
.track-item.pending {
  cursor: default;
}

.status-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
}
.status-pending {
  background: #fef3c7;
  color: #b45309;
}
.status-answered {
  background: #d1fae5;
  color: #047857;
}

/* =========================================
   9. DETAIL VIEW
   ========================================= */
.detail-container {
  padding-top: 2rem;
  padding-bottom: 4rem;
}
.q-box h1 {
  font-size: 2rem;
  margin: 0.5rem 0;
  line-height: 1.3;
}
.q-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.a-box {
  background: #ecfdf5;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-top: 2.5rem;
  border: 1px solid rgba(5, 150, 105, 0.1);
  position: relative;
}
[data-theme="dark"] .a-box {
  background: rgba(5, 150, 105, 0.1);
}

.ustadz-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: white;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

/* =========================================
   10. FOOTER & TOAST
   ========================================= */
footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 3rem 1.5rem;
  margin-top: 4rem;
  text-align: center;
}
footer p {
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
footer small {
  display: block;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--text-main);
  color: var(--bg-surface);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  font-weight: 600;
  animation: slideUp 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

/* =========================================
   11. MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
  /* Ubah layout hero jadi menumpuk di tablet/mobile */
  .hero-layout {
    flex-direction: column-reverse;
    text-align: center;
    gap: 3rem;
  }
  .hero-content {
    max-width: 100%;
  }
  .hero-image {
    max-width: 80%;
  }
  .category-pills {
    justify-content: center;
  }
  .search-wrapper input {
    text-align: center;
    padding-left: 1.5rem;
  }
  .search-icon {
    display: none;
  } /* Sembunyikan ikon search di mobile agar teks tengah */
}

/* =========================================
   12. MOBILE RESPONSIVE (COMPACT & CUTE MODE)
   ========================================= */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem; /* Margin kiri-kanan lebih tipis */
  }

  /* 1. Navbar Lebih Tipis */
  .navbar {
    padding: 0.5rem 0;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    border-radius: 8px;
  }
  .brand-text {
    font-size: 1.1rem;
  }
  .btn-text {
    padding: 0.5rem;
    border-radius: 8px;
  }
  .btn-text span {
    display: none;
  } /* Sembunyikan teks di tombol nav */
  .btn-primary {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  /* 2. Hero Section (Header) Lebih Pendek */
  .hero-section {
    padding: 1.5rem 0 3.5rem; /* Atas bawah lebih rapat */
    border-radius: 0 0 1.5rem 1.5rem; /* Lengkungan lebih kecil */
    margin-bottom: -2.5rem; /* Tarik konten naik ke atas */
  }

  .hero-layout {
    gap: 1.5rem;
  }
  .hero-image img {
    max-width: 140px;
  } /* Gambar buku diperkecil */

  .hero-text h1 {
    font-size: 1.6rem; /* Judul lebih kecil */
    margin-bottom: 0.5rem;
  }
  .hero-text p {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1.2rem;
  }

  /* Search Bar Imut */
  .search-wrapper input {
    height: 2.8rem; /* Lebih pendek */
    font-size: 0.9rem;
    padding-left: 1.2rem; /* Teks di tengah (karena icon hilang) */
    text-align: center;
  }
  .search-icon {
    display: none;
  }

  /* Update di dalam @media (max-width: 768px) */

  /* 3. Kategori Pills (Scroll Samping Modern) */

  .category-pills {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
  }

  .pill {
    flex: 0 0 auto; /* Mencegah tombol mengecil/gepeng */
    white-space: nowrap; /* Teks dilarang turun baris */

    font-size: 0.85rem; /* Ukuran font pas di jempol */
    padding: 0.5rem 1.2rem; /* Area sentuh luas */
    border-radius: 50px; /* Bulat sempurna */

    /* Visual perbaikan di mobile */
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
  }

  /* Style khusus pill yang Aktif di Mobile */
  .pill.active {
    background: #ffffff;
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: none;
  }

  /* 4. Kartu (Card) Lebih Kompak */
  .grid-container {
    grid-template-columns: 1fr;
    gap: 1rem; /* Jarak antar kartu rapat */
  }

  .card {
    padding: 1rem; /* Isi kartu lebih lega tapi frame kecil */
    border-radius: 16px; /* Sudut lebih bulat (imut) */
  }

  .card-top {
    margin-bottom: 0.5rem;
  }
  .badge-cat {
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
  }

  .card h3 {
    font-size: 1.05rem; /* Judul pertanyaan pas di HP */
    margin-bottom: 0.3rem;
  }
  .card p {
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    -webkit-line-clamp: 2; /* Batasi cuma 2 baris */
  }

  .card-action {
    padding-top: 0.8rem;
    font-size: 0.75rem;
  }

  /* 5. Detail View & Form */
  .form-card,
  .a-box,
  .q-box {
    padding: 1.25rem; /* Padding dalam box diperkecil */
    border-radius: 16px;
  }

  .q-box h1 {
    font-size: 1.4rem;
  }
  .answer-content {
    font-size: 0.95rem;
  }

  /* Toast Notification (Kecil di bawah) */
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 1.5rem;
    padding: 0.8rem;
    font-size: 0.85rem;
    border-radius: 50px;
    justify-content: center;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* =========================================
   11. MODAL & LOADING STYLES (BARU)
   ========================================= */

/* Modal Overlay (Latar Gelap) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6); /* Gelap transparan */
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  transition: opacity 0.3s ease;
}

/* Modal Box */
.modal-content {
  background: var(--bg-surface);
  padding: 2.5rem 2rem;
  border-radius: 24px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  position: relative;
  border: 1px solid var(--border);
}

.modal-icon {
  width: 80px;
  height: 80px;
  background: #ffffff;
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 1.5rem;
  animation: floatImage 3s ease-in-out infinite;
}

.modal-content h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}
.modal-content p {
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.modal-info-box {
  background: var(--bg-body);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  border: 1px dashed var(--border);
}

/* Animasi Zoom In untuk Modal */
.anim-zoom-in {
  animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Button Loading State */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
  background: var(--text-secondary) !important; /* Jadi abu-abu saat loading */
  box-shadow: none;
}
.btn .fa-circle-notch {
  margin-right: 0.5rem;
}
/* Styling Khusus Konten Jawaban */
.answer-content {
  font-size: 1.05rem;
  line-height: 1.8; /* Jarak antar baris agar tidak rapat */
  color: var(--text-main);
  text-align: left;
}

.answer-content b {
  font-weight: 700;
  color: var(--primary-dark); /* Warna bold sedikit lebih gelap/hijau */
}

/* Memberi jarak ekstra jika ada paragraf panjang */
.answer-content br {
  display: block;
  margin-bottom: 0.4rem; /* Jarak antar Enter */
  content: "";
}
