/* --- Theme Variables --- */
:root {
  --bg-color: #f4f4f4;
  --text-color: #333;
  --header-bg: rgba(255, 255, 255, 0.95);
  --panel-bg: #ffffff;
  --border-color: #ccc;
  --input-bg: #ffffff;
  --hover-bg: #f8f9fa;
  --shadow: rgba(0, 0, 0, 0.1);
}

body.dark-theme {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --header-bg: rgba(30, 30, 30, 0.95);
  --panel-bg: #1e1e1e;
  --border-color: #444;
  --input-bg: #2c2c2c;
  --hover-bg: #2a2a2a;
  --shadow: rgba(0, 0, 0, 0.5);
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  transition:
    background-color 0.3s,
    color 0.3s;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Prevent horizontal scrollbar */
}
/* --- Sticky Header Styles --- */
.sticky-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: var(
    --header-bg,
    rgba(255, 255, 255, 0.98)
  ); /* Fully opaque! */
  backdrop-filter: blur(8px); /* Beautiful frosted glass effect */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
  transform: translateY(0);
  opacity: 1;
  box-sizing: border-box;
}

.sticky-header.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.header-spacer {
  height: 200px; /* Keep your current height */
  width: 100%;
  transition: height 0.3s ease; /* ADD THIS LINE: smooth slide */
}

.controls-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 15px;
  width: 100%;
  max-width: 1100px; /* Increased from 900px */
}

.control-group {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-color, #555);
  min-width: 0; /* Prevents flex item overflow */
  flex-shrink: 0; /* Prevents controls from collapsing */
}

.control-group select,
.control-group input {
  background-color: var(--input-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-top: 3px;
}

audio {
  height: 40px;
}

#selection-label {
  background-color: var(--hover-bg);
  color: var(--text-color);
  border-left: 5px solid #007bff;
  font-size: 1.1rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
  padding: 5px 15px;
  background-color: #e9ecef;
  border-radius: 4px;
  border-left: 5px solid #007bff;
}

#quran-wrapper {
  position: relative;
  width: 100%; /* Full width */
  max-width: 100%; /* Remove any size restriction */
  box-shadow: none; /* Remove shadow since it touches edges now */
  background-color: var(
    --panel-bg
  ); /* Changed from 'white' to use the theme variable */
  transition: background-color 0.3s; /* Smooth transition when switching themes */
}

#quran-page {
  display: block;
  width: 100%;
  height: auto;
}

/* Update page-controls to fit neatly in the header */
.page-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 8px 15px;
  background: var(--hover-bg, #f8f9fa);
  border-radius: 6px;
  border: 1px solid var(--border-color, #ddd);
  width: fit-content;
}

.page-controls button {
  padding: 5px 12px; /* Slightly smaller buttons */
  font-size: 0.9rem;
}

#page-display {
  color: var(--text-color);
  /* font-size: 1rem; */
}

.page-controls button:hover {
  background-color: #0056b3;
}

#overlay-container {
  position: absolute; /* Crucial: allows it to sit on top of the image */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.ayah-box {
  position: absolute;
  border: 2px solid transparent; /* Hide border by default */
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.2s ease;
  border-radius: 6px; /* Slightly rounded corners look nice */
}

/* The hover effect you already like */
.ayah-box:hover {
  background-color: rgba(0, 255, 166, 0.119);
  border-color: rgba(0, 123, 255, 0.5);
}

/* The new calm highlight for the currently playing Ayah */
.ayah-box.highlight {
  background-color: rgba(0, 123, 255, 0.25); /* Soft, transparent blue */
  border-color: rgba(
    0,
    123,
    255,
    0.477
  ); /* Slightly stronger blue border to stand out */
  box-shadow: 0 0 6px rgba(0, 123, 255, 0.4); /* Gentle blue glow */
}

/* --- Floating Action Button (FAB) --- */
#fab-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* The Main FAB (always visible) */
.fab-main {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #007bff;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.5);
  transition:
    transform 0.3s ease,
    background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-size: 1.5rem; /* Slightly bigger icon */
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab-main:hover {
  background-color: #0056b3;
}

.fab-main.open {
  /* transform: rotate(90deg);
    background-color: #dc3545; */

  transform: rotate(90deg) scale(1.1);
  background-color: #dc3545;
}

/* The menu containing hidden buttons */
.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
  /* Hide by default */
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
  transform-origin: bottom right;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.fab-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* Individual FAB items */
.fab-item {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #ffffff;
  color: #333;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
  padding: 0;
  line-height: 1;
}

.fab-item:hover {
  transform: scale(1.1);
  background-color: #f0f0f0;
}

/* Dark theme adjustments */
body.dark-theme .fab-item {
  background-color: #2c2c2c;
  color: #e0e0e0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

body.dark-theme .fab-item:hover {
  background-color: #3a3a3a;
}

/* --- Dark Mode Image Inversion --- */
body.dark-theme #quran-page {
  /* Invert white to black, black to white, and fix the colors */
  /* filter: invert(1) hue-rotate(180deg); */

  /* Invert, fix hues, then boost saturation and contrast to revive the colors */
  /* filter: invert(1) hue-rotate(180deg) saturate(1.8) contrast(1.2); */

  /* Converts the image to a warm, dark sepia tone */
  filter: invert(0.9) sepia(0.5) hue-rotate(180deg) brightness(0.85)
    contrast(1.2);
}

/* Adjust highlights for dark mode so they aren't too bright */
body.dark-theme .ayah-box.highlight {
  background-color: rgba(0, 123, 255, 0.3);
  border-color: rgba(0, 123, 255, 0.8);
}

body.dark-theme .ayah-box:hover {
  background-color: rgba(0, 123, 255, 0.2);
}

#surah-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background-color: rgba(0, 123, 255, 0.95);
  color: white;
  padding: 20px 40px;
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  z-index: 2000; /* Above everything */
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 2px solid white;
}

#surah-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* --- Tajweed Legend Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 2000; /* Above everything */
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background-color: var(--panel-bg);
  color: var(--text-color);
  width: 90%;
  max-width: 500px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  padding: 20px;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-content {
  transform: translateY(20px);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

#close-legend-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-color);
  line-height: 1;
}

#close-legend-btn:hover {
  color: #dc3545;
}

.legend-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 8px;
  border-radius: 6px;
  background-color: var(--hover-bg);
}

.legend-item strong {
  display: block;
  font-size: 0.95rem;
}

.legend-item p {
  margin: 2px 0 0 0;
  font-size: 0.8rem;
  color: #888;
}

/* The color indicators */
.color-box {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

.color-box.red {
  background-color: #dc3545;
}
.color-box.green {
  background-color: #28a745;
}
.color-box.blue {
  background-color: #007bff;
}
.color-box.grey {
  background-color: #6c757d;
}
.color-box.orange {
  background-color: #fd7e14;
}

.modal-footer {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.8rem;
  color: #888;
}

/* --- Translation Subtitle Bar --- */
#subtitle-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.85);

  /* NEW: Movie Subtitle Style */
  color: #ffeb3b; /* Bright yellow */
  font-family:
    "Segoe UI", Arial, Helvetica, sans-serif; /* Clean, modern font */
  font-weight: 500;
  text-shadow:
    1px 1px 2px rgba(0, 0, 0, 0.9),
    0 0 5px rgba(0, 0, 0, 0.8); /* Subtle shadow for pop */
  font-size: var(--subtitle-font-size, 1.1rem); /* Dynamic size */

  /* padding: 15px 25px; */
  /* padding: 15px 40px; Was 15px 25px — slightly wider for balance */
  padding: 15px 90px 15px 40px; /* RIGHT padding = 90px to clear the FAB */
  text-align: center;
  z-index: 900;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.3);
  line-height: 1.4;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease,
    font-size 0.2s ease;
  box-sizing: border-box;
  max-height: 30vh;
  overflow-y: auto;
}

@media (max-width: 600px) {
  #subtitle-bar {
    padding: 15px 75px 15px 20px;
    font-size: 0.95rem;
  }
}

#subtitle-bar.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#subtitle-text {
  width: 100%;
  max-width: 100%; /* Was 900px — now full width */
  margin: 0 auto;
  padding: 0 15px; /* Small side padding so text doesn't touch the edge */
  box-sizing: border-box;
}
