/* =========================================
   QURAN SECTION - COMPLETE MODERN REDESIGN
   ========================================= */

/* =========================================
   SURAH LIST (GRID)
   ========================================= */
.surah-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  animation: fadeIn .5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 560px) {
  .surah-grid {
    grid-template-columns: repeat(auto-fill, minmax(46%, 1fr));
    gap: .85rem;
  }
}

.surah-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 1.3rem;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: 1rem .9rem .85rem;
  text-align: left;
  box-shadow: 0 8px 24px rgba(15,23,42,.06), 0 2px 8px rgba(15,23,42,.03);
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: fadeInUp .5s ease backwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.surah-card:nth-child(1) { animation-delay: 0.02s; }
.surah-card:nth-child(2) { animation-delay: 0.04s; }
.surah-card:nth-child(3) { animation-delay: 0.06s; }
.surah-card:nth-child(4) { animation-delay: 0.08s; }
.surah-card:nth-child(5) { animation-delay: 0.1s; }
.surah-card:nth-child(6) { animation-delay: 0.12s; }
.surah-card:nth-child(n+7) { animation-delay: 0.14s; }

.surah-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), #22c55e);
  opacity: 0;
  transition: opacity .3s ease;
}

.surah-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(15,23,42,.12), 0 6px 16px rgba(15,23,42,.06);
  border-color: rgba(11,122,117,.25);
}

.surah-card:hover::before {
  opacity: 1;
}

.surah-card-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(11,122,117,.12), rgba(11,122,117,.08));
  border: 1px solid rgba(11,122,117,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  color: var(--color-primary);
  margin-bottom: .5rem;
  box-shadow: 0 4px 12px rgba(11,122,117,.15);
  transition: all .3s ease;
}

.surah-card:hover .surah-card-num {
  transform: scale(1.1) rotate(5deg);
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
  box-shadow: 0 6px 16px rgba(11,122,117,.25);
}

.surah-card-name {
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.3;
  color: var(--color-text);
  letter-spacing: -.01em;
  margin-bottom: .15rem;
}

.surah-card-ar {
  font-size: .9rem;
  direction: rtl;
  text-align: right;
  font-family: "LPMQ Isep Misbah", serif;
  color: var(--color-text);
  line-height: 1.5;
  margin-bottom: .3rem;
}

.surah-card-meta {
  font-size: .7rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Dark Mode - Surah List */
body.dark-mode .surah-card {
  background: linear-gradient(135deg, rgba(30,41,59,.6), rgba(15,23,42,.5));
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .surah-card-ar,
body.dark-mode .surah-card-name {
  color: #f1f5f9;
}

body.dark-mode .surah-card-num {
  background: linear-gradient(135deg, rgba(94,234,212,.15), rgba(94,234,212,.1));
  border-color: rgba(94,234,212,.25);
  color: #5eead4;
}

body.dark-mode .surah-card:hover .surah-card-num {
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
}

/* =========================================
   SURAH DETAILS (GLOBAL WRAPPER)
   ========================================= */
#surahDetailsSection,
.pwa-surah-details {
  max-width: 800px;
  margin: 0 auto 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Sticky Topbar */
.surah-topbar {
  position: sticky;
  top: var(--app-header-h, 64px);
  z-index: 45;
  background: linear-gradient(135deg, rgba(255,255,255,.98), rgba(248,250,252,.95));
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1.1rem;
  border-radius: 1.2rem;
  box-shadow: 0 8px 24px rgba(15,23,42,.08), 0 2px 8px rgba(15,23,42,.04);
  margin-bottom: .5rem;
}

.surah-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid rgba(148,163,184,.15);
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border-radius: 999px;
  padding: .45rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: all .3s ease;
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
}

.surah-topbar-btn:hover {
  transform: translateX(-3px);
  box-shadow: 0 4px 12px rgba(15,23,42,.12);
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
  border-color: var(--color-primary);
}

.surah-topbar-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
  letter-spacing: -.01em;
}

.surah-topbar-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid rgba(148,163,184,.12);
  display: grid;
  place-items: center;
  color: var(--color-primary);
  font-size: .8rem;
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
  cursor: pointer;
  transition: all .3s ease;
}

.surah-topbar-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(15,23,42,.12);
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
}

/* Header Kartu Surah */
.surah-header-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 1.3rem;
  padding: 1.2rem 1.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  box-shadow: 0 12px 32px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.04);
  position: relative;
  overflow: hidden;
}

.surah-header-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(11,122,117,.06), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.surah-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: .35rem;
  color: var(--color-text);
  letter-spacing: -.02em;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}

.surah-title small {
  font-weight: 500;
  font-size: .85rem;
  opacity: .7;
}

.surah-meta {
  font-size: .75rem;
  color: var(--color-text-muted);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* Bismillah */
.bismillah-img {
  max-width: 220px;
  height: auto;
  opacity: .85;
  transition: all .3s ease;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.08));
}

.bismillah-img:hover {
  opacity: 1;
  transform: scale(1.02);
}

/* Dark Mode - Surah Details Header */
body.dark-mode .surah-topbar {
  background: linear-gradient(135deg, rgba(15,23,42,.98), rgba(30,41,59,.95));
}

body.dark-mode .surah-topbar-btn {
  background: linear-gradient(135deg, rgba(30,41,59,.8), rgba(15,23,42,.7));
  color: #e2e8f0;
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .surah-topbar-btn:hover {
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
}

body.dark-mode .surah-topbar-title {
  color: #f1f5f9;
}

body.dark-mode .surah-topbar-icon {
  background: linear-gradient(135deg, rgba(30,41,59,.8), rgba(15,23,42,.7));
  color: #5eead4;
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .surah-topbar-icon:hover {
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
}

body.dark-mode .surah-header-card {
  background: linear-gradient(135deg, rgba(30,41,59,.6), rgba(15,23,42,.5));
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .surah-title {
  color: #f1f5f9;
}

/* =========================================
   KARTU AYAT
   ========================================= */
.surah-ayat-list,
.quran-ayah-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.ayah-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 1.3rem;
  padding: 1.3rem 1.2rem 1.1rem;
  box-shadow: 0 8px 24px rgba(15,23,42,.06), 0 2px 8px rgba(15,23,42,.03);
  transition: all .3s ease;
  position: relative;
  overflow: hidden;
}

.ayah-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--color-primary), #22c55e);
  opacity: 0;
  transition: opacity .3s ease;
}

.ayah-card:hover {
  box-shadow: 0 16px 40px rgba(15,23,42,.12), 0 6px 16px rgba(15,23,42,.06);
  border-color: rgba(11,122,117,.2);
}

.ayah-card:hover::before {
  opacity: 1;
}

.ayah-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6rem;
  gap: .6rem;
}

.ayah-num,
.ayah-number {
  min-width: 34px;
  height: 34px;
  border-radius: .9rem;
  background: linear-gradient(135deg, rgba(11,122,117,.12), rgba(11,122,117,.08));
  border: 1px solid rgba(11,122,117,.2);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .75rem;
  box-shadow: 0 4px 12px rgba(11,122,117,.12);
  transition: all .3s ease;
}

.ayah-card:hover .ayah-num,
.ayah-card:hover .ayah-number {
  transform: scale(1.05);
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
  box-shadow: 0 6px 16px rgba(11,122,117,.25);
}

/* Actions di Ayat */
.ayah-actions {
  display: flex;
  gap: .5rem;
  margin-top: .85rem;
  flex-wrap: wrap;
}

.ayah-btn {
  min-width: 36px;
  height: 36px;
  border-radius: .9rem;
  border: 0;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 1px solid rgba(148,163,184,.12);
  display: grid;
  place-items: center;
  font-size: .85rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all .3s ease;
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
  padding: 0 .7rem;
}

.ayah-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15,23,42,.12);
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
  border-color: var(--color-primary);
}

.ayah-btn:active {
  transform: translateY(0);
}

.ayah-btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(11,122,117,.25);
}

.ayah-btn-primary:hover {
  box-shadow: 0 6px 16px rgba(11,122,117,.35);
  transform: translateY(-2px) scale(1.05);
}

/* Latin & Terjemah */
.ayah-latin {
  direction: ltr;
  text-align: left;
  font-size: .8rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: .65rem;
  font-style: italic;
  padding-left: .5rem;
  border-left: 2px solid rgba(11,122,117,.15);
}

.ayah-indo,
.ayah-translation {
  font-size: .85rem;
  line-height: 1.65;
  color: var(--color-text);
  margin-top: .5rem;
}

.ayah-indo p {
  margin: 0;
}

/* Dark Mode - Ayah Cards */
body.dark-mode .ayah-card {
  background: linear-gradient(135deg, rgba(30,41,59,.6), rgba(15,23,42,.5));
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .ayah-num,
body.dark-mode .ayah-number {
  background: linear-gradient(135deg, rgba(94,234,212,.15), rgba(94,234,212,.1));
  border-color: rgba(94,234,212,.25);
  color: #5eead4;
}

body.dark-mode .ayah-card:hover .ayah-num,
body.dark-mode .ayah-card:hover .ayah-number {
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
}

body.dark-mode .ayah-btn {
  background: linear-gradient(135deg, rgba(30,41,59,.8), rgba(15,23,42,.7));
  color: #cbd5e1;
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .ayah-btn:hover {
  background: linear-gradient(135deg, var(--color-primary), #0d9488);
  color: white;
}

body.dark-mode .ayah-indo,
body.dark-mode .ayah-translation {
  color: #e2e8f0;
}

body.dark-mode .ayah-latin {
  color: #94a3b8;
  border-left-color: rgba(94,234,212,.2);
}

/* =========================================
   ARABIC TEXT - RESPONSIVE & BEAUTIFUL
   ========================================= */
.surah-detail-page .ayah-card .ayah-arab,
.ayat-list .ayah-arab,
.quran-arabic,
.ayah-arab,
.surah-ayah-item .arabic {
  font-family: "LPMQ Isep Misbah", serif;
  direction: rtl;
  text-align: justify;
  white-space: normal;
  margin-bottom: .75rem;
  color: var(--color-text);
  
  /* Responsive font size */
  font-size: clamp(1.5rem, 1.4rem + 0.5vw, 1.9rem);
  
  /* Responsive line height */
  line-height: clamp(2.9rem, 3.1rem + 1vw, 3.3rem);
  
  /* Better text rendering */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* PENTING: Beri ruang untuk tooltip */
  padding-top: 2.5rem;
  position: relative;
  overflow: visible;
}

.surah-detail-page .ayah-card .ayah-arab.is-centered {
  text-align: center !important;
  direction: rtl;
}

body.dark-mode .ayah-arab {
  color: #f1f5f9;
}

/* =========================================
   KLIK KATA ARAB → PENJELASAN AI
   ========================================= */
.ayah-card .word,
.quran-arabic .word,
.ayah-arab .word {
  display: inline-block;
  padding: .15rem .25rem;
  border-radius: .5rem;
  transition: all .2s ease;
  position: relative;
}

/* Hanya tampilkan cursor pointer jika AI enabled */
body:not(.ai-word-disabled) .ayah-card .word,
body:not(.ai-word-disabled) .quran-arabic .word,
body:not(.ai-word-disabled) .ayah-arab .word {
  cursor: pointer;
}

.ayah-card .word::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--color-primary);
  transition: width .3s ease;
}

body:not(.ai-word-disabled) .ayah-card .word:hover {
  background: linear-gradient(135deg, rgba(11,122,117,.12), rgba(11,122,117,.08));
  color: var(--color-primary);
  transform: translateY(-1px);
}

body:not(.ai-word-disabled) .ayah-card .word:hover::after {
  width: 80%;
}

body.dark-mode:not(.ai-word-disabled) .ayah-card .word:hover {
  background: linear-gradient(135deg, rgba(94,234,212,.15), rgba(94,234,212,.1));
  color: #5eead4;
}

body.dark-mode .ayah-card .word::after {
  background: #5eead4;
}

/* Disabled state - no hover effects */
body.ai-word-disabled .ayah-card .word {
  cursor: default;
}

body.ai-word-disabled .ayah-card .word:hover {
  background: none;
  color: inherit;
  transform: none;
}

/* =========================================
   HIDE LATIN & TERJEMAH (SETTINGS)
   ========================================= */
body.hide-latin .ayah-latin {
  display: none !important;
}

body.hide-translation .ayah-indo,
body.hide-translation .ayah-translation {
  display: none !important;
}

body.hide-translation .random-ayat-trans {
  display: none !important;
}

/* =========================================
   SEARCH INPUT ENHANCEMENT
   ========================================= */
#searchSurah {
  border-radius: .9rem;
  border: 1.5px solid rgba(148,163,184,.2);
  padding: .7rem 1rem;
  font-size: .8rem;
  transition: all .3s ease;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 4px 12px rgba(15,23,42,.04);
}

#searchSurah:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(11,122,117,.1), 0 4px 12px rgba(11,122,117,.15);
  outline: none;
  background: #ffffff;
}

#searchSurah::placeholder {
  color: var(--color-text-muted);
}

body.dark-mode #searchSurah {
  background: linear-gradient(135deg, rgba(30,41,59,.6), rgba(15,23,42,.5));
  border-color: rgba(148,163,184,.15);
  color: #f1f5f9;
}

body.dark-mode #searchSurah:focus {
  border-color: #5eead4;
  box-shadow: 0 0 0 4px rgba(94,234,212,.15), 0 4px 12px rgba(94,234,212,.2);
  background: rgba(30,41,59,.7);
}

/* =========================================
   TOOLS/SELECT ENHANCEMENT
   ========================================= */
.surah-tools {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 1.2rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
}

.surah-tools .form-select {
  border-radius: .85rem;
  border: 1.5px solid rgba(148,163,184,.2);
  padding: .6rem .9rem;
  font-size: .75rem;
  transition: all .3s ease;
  background: #ffffff;
}

.surah-tools .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(11,122,117,.1);
  outline: none;
}

.surah-tools .form-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: .03em;
}

body.dark-mode .surah-tools {
  background: linear-gradient(135deg, rgba(30,41,59,.6), rgba(15,23,42,.5));
  border-color: rgba(148,163,184,.15);
}

body.dark-mode .surah-tools .form-select {
  background: rgba(30,41,59,.8);
  border-color: rgba(148,163,184,.15);
  color: #f1f5f9;
}

body.dark-mode .surah-tools .form-select:focus {
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(94,234,212,.15);
}

body.dark-mode .surah-tools .form-label {
  color: #cbd5e1;
}

/* =========================================
   RESPONSIVE ADJUSTMENTS
   ========================================= */
@media (max-width: 640px) {
  .surah-topbar {
    padding: .7rem .85rem;
  }

  .surah-header-card {
    padding: 1rem 1.1rem;
  }

  .surah-title {
    font-size: 1.05rem;
  }

  .ayah-card {
    padding: 1.1rem 1rem .95rem;
  }

  .surah-tools {
    padding: .85rem .95rem;
  }
}

/* =========================================
   ACCESSIBILITY
   ========================================= */
.surah-card:focus-visible,
.ayah-btn:focus-visible,
.surah-topbar-btn:focus-visible,
.surah-topbar-icon:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

body.dark-mode .surah-card:focus-visible,
body.dark-mode .ayah-btn:focus-visible,
body.dark-mode .surah-topbar-btn:focus-visible,
body.dark-mode .surah-topbar-icon:focus-visible {
  outline-color: #5eead4;
}

/* =========================================
   SMOOTH TRANSITIONS
   ========================================= */
* {
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}