:root {
  /* Colors */
  --primary: #047857; /* Emerald 700 */
  --primary-light: #10b981; /* Emerald 500 */
  --primary-dark: #064e3b; /* Emerald 900 */
  --accent: #d4af37; /* Gold */
  --accent-light: #fcd34d;

  --bg-light: #f8fafc;
  --bg-dark: #0f172a;
  --surface-light: #ffffff;
  --surface-dark: #1e293b;

  --text-primary-light: #1e293b;
  --text-secondary-light: #64748b;
  --text-primary-dark: #f1f5f9;
  --text-secondary-dark: #94a3b8;

  /* Variables that change with theme */
  --bg-app: var(--bg-light);
  --bg-surface: var(--surface-light);
  --bg-glass: rgba(255, 255, 255, 0.8);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --border-color: rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 2px 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);

  /* Typography */
  --font-main: "Plus Jakarta Sans", sans-serif;
  --font-arabic: "Amiri", serif;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-app: var(--bg-dark);
  --bg-surface: var(--surface-dark);
  --bg-glass: rgba(30, 41, 59, 0.8);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --border-color: rgba(255, 255, 255, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Background Elements */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23047857' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index: -2;
  pointer-events: none;
}

.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 30vh;
  background: linear-gradient(
    180deg,
    rgba(4, 120, 87, 0.1) 0%,
    transparent 100%
  );
  z-index: -1;
  pointer-events: none;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-icon {
  font-size: 2rem;
  color: var(--primary);
  animation: pulse 2s infinite;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-text {
  margin-top: var(--spacing-md);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* Header */
.glass-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-md);
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.icon-btn.hidden {
  display: none;
}

/* Main Content */
#main-content {
  padding-top: 70px;
  padding-bottom: 100px; /* Space for audio dock */
  min-height: 100vh;
}

.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

/* Hero Section */
.hero-section {
  padding: var(--spacing-md);
}

.greeting {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.hero-content h2 {
  font-size: 1.5rem;
  margin: var(--spacing-sm) 0;
}

/* Last Read Card */
.last-read-card {
  background: linear-gradient(
    135deg,
    var(--primary-dark) 0%,
    var(--primary) 100%
  );
  color: white;
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  z-index: 1;
  pointer-events: auto;
}

.last-read-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 20.5V18H0v-2h20v-2H0v-2h20v-2H0V8h20V6H0V4h20V2H0V0h22v20h2V0h2v20h2V0h2v20h2V0h2v20h2v2H20v-1.5zM0 20h2v20H0V20zm4 0h2v20H4V20zm4 0h2v20H8V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
  opacity: 0.3;
  z-index: -1;
}

.last-read-card.hidden {
  display: none;
}

.last-read-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.last-read-info {
  flex: 1;
}

.last-read-info .label {
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.last-read-info h3 {
  font-size: 1.1rem;
  margin: 4px 0;
}

.last-read-info .ayah-number {
  font-size: 0.85rem;
  opacity: 0.9;
}

.continue-btn {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.continue-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Search Section */
.search-section {
  padding: var(--spacing-md);
}

.search-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  box-shadow: var(--shadow-sm);
}

.search-bar i {
  color: var(--text-secondary);
  font-size: 1.2rem;
}

.search-bar input {
  border: none;
  background: transparent;
  flex: 1;
  font-family: var(--font-main);
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
}

/* Surah List */
.surah-list {
  padding: 0 var(--spacing-md);
  display: grid;
  gap: var(--spacing-sm);
}

.surah-item {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.surah-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.surah-number {
  width: 36px;
  height: 36px;
  background: rgba(4, 120, 87, 0.1);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  transform: rotate(45deg);
}

.surah-number span {
  transform: rotate(-45deg);
}

.surah-details {
  flex: 1;
}

.surah-title {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.surah-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.surah-arabic {
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  color: var(--primary);
}

/* Detail View */
.surah-header-card {
  margin: var(--spacing-md);
  background: linear-gradient(
    135deg,
    var(--primary-dark) 0%,
    var(--primary) 100%
  );
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  color: white;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.surah-header-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 20.5V18H0v-2h20v-2H0v-2h20v-2H0V8h20V6H0V4h20V2H0V0h22v20h2V0h2v20h2V0h2v20h2V0h2v20h2v2H20v-1.5zM0 20h2v20H0V20zm4 0h2v20H4V20zm4 0h2v20H8V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20zm4 0h2v20h-2V20z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
  opacity: 0.3;
}

.header-arabic {
  font-family: var(--font-arabic);
  font-size: 2.5rem;
  margin-bottom: var(--spacing-sm);
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.header-meta {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: var(--spacing-xs);
}

.bismillah {
  text-align: center;
  font-family: var(--font-arabic);
  font-size: 1.8rem;
  color: var(--text-primary);
  margin: var(--spacing-xl) 0;
}

.info-card {
  background: var(--bg-surface);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.ayah-container {
  padding: 0 var(--spacing-md);
}

.ayah-item {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.ayah-item.active {
  background: rgba(4, 120, 87, 0.05);
  border: 1px solid var(--primary-light);
}

.ayah-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  background: rgba(0, 0, 0, 0.03);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
}

.ayah-badge {
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.action-icons {
  display: flex;
  gap: var(--spacing-sm);
}

.action-icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color 0.2s;
}

.action-icon-btn:hover,
.action-icon-btn.active {
  color: var(--primary);
}

.ayah-text {
  text-align: right;
  font-family: var(--font-arabic);
  font-size: 1.8rem; /* Dynamic */
  line-height: 2.2;
  color: var(--text-primary);
  margin-bottom: var(--spacing-lg);
}

.ayah-translation {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Audio Dock */
.audio-dock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 400px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: var(--spacing-sm) var(--spacing-md);
  color: white;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.audio-dock.hidden {
  transform: translate(-50%, 100px);
  opacity: 0;
}

.audio-dock-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audio-info {
  flex: 1;
  overflow: hidden;
}

.audio-info h4 {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-info span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.control-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn.sm {
  font-size: 1.2rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.control-btn.sm:hover {
  opacity: 1;
}

.control-btn.play {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
  border-radius: 50%;
  font-size: 1.2rem;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.control-btn.play:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-btn.close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  font-size: 1rem;
  margin-left: var(--spacing-xs);
  transition: all 0.2s;
}

.control-btn.close:hover {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  transform: scale(1.05);
}

.progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  margin-top: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
}

/* Settings Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  width: 90%;
  max-width: 350px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal-body {
  padding: var(--spacing-md);
}

.setting-group {
  margin-bottom: var(--spacing-lg);
}

.setting-group label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.setting-group select {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-main);
}

.setting-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.setting-group.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-group.toggle label {
  margin-bottom: 0;
}

/* Tafsir Styles */
.tafsir-card {
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
}

.tafsir-body {
  overflow-y: auto;
  padding: var(--spacing-lg);
  max-height: calc(85vh - 60px);
}

.tafsir-ayah {
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.tafsir-ayah:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.tafsir-number {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: var(--spacing-sm);
}

.tafsir-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  text-align: justify;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast i {
  font-size: 1.2rem;
}

/* Navigation Buttons */
.nav-btn {
  background: var(--bg-surface);
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.nav-btn:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Search Input Placeholder */
#ayah-search::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 45px;
  height: 45px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 900;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}
