:root {
  /* Default Blue Theme */
  --gradient-start: #667eea;
  --gradient-end: #764ba2;
  --modal-bg: linear-gradient(135deg, rgba(102, 126, 234, 0.5) 0%, rgba(118, 75, 162, 0.5) 100%);
  --modal-border: rgba(255, 255, 255, 0.3);
  --glass-bg: rgba(0, 0, 0, 0.3);
  --button-gradient-start: #667eea;
  --button-gradient-end: #764ba2;
  --red-active: #f44336;
  --green-playing: #4caf50;
  --yellow-manual: rgba(255, 193, 7, 0.15);
  --white: white;
  --black: rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  height: 100vh;
  overflow: hidden;
  color: var(--white);
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header Section - 15% */
.header {
  height: 15vh;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
  flex-shrink: 0;
}

.settings-toggle-btn {
  position: absolute;
  top: 10px;
  right: 80px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 2.2rem;
  cursor: pointer;
  border-radius: 50%;
  width: 55px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--white);
  backdrop-filter: blur(5px);
}

.library-toggle-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 2.2rem;
  cursor: pointer;
  border-radius: 50%;
  width: 55px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--white);
  backdrop-filter: blur(5px);
}

.settings-toggle-btn:active,
.library-toggle-btn:active {
  transform: scale(0.95);
}

.jalali-date {
  font-size: 3.5rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px var(--black);
  letter-spacing: 2px;
  text-align: center;
  margin: 0 auto;
}

.time {
  font-size: 1.8rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px var(--black);
  position: absolute;
  top: 10px;
  left: 15px;
}

.hijri-date {
  font-size: 1.3rem;
  margin-top: 5px;
  opacity: 0.9;
  font-family: "Traditional Arabic", "Amiri", serif;
  text-align: center;
}

/* Main View */
.main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Library View */
.library-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(0, 0, 0, 0.2);
}

/* Prayers Section */
.prayers {
  flex: 6;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  overflow-y: auto;
  overflow-x: hidden; /* Safety: hide any horizontal overflow */
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-sizing: border-box;
}

/* Play Section */
/* Status Bar */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.status-message {
  font-size: 0.9rem;
  color: #ffffff;
  text-align: center;
  padding: 0 15px;
  font-family: monospace;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.status-message.error {
  color: #ff6b6b;
  font-weight: bold;
}

.status-message.success {
  color: #81c784;
  font-weight: bold;
}

.status-message.info {
  color: #64b5f6;
  font-weight: bold;
}

/* Adjust play section to account for status bar */
.play {
  flex: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  margin-bottom: 35px; /* Space for status bar */
}

@media (max-width: 768px) {
  .status-bar {
    height: 38px;
  }
  .status-message {
    font-size: 0.8rem;
  }
  .play {
    margin-bottom: 30px;
  }
}

/* Library Prayers */
.library-prayers {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  overflow-y: auto;
  padding: 10px;
}

/* Prayer items */
.prayer-item {
  background: rgba(255, 255, 255, 0.15);
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  box-sizing: border-box;
}

/* Active/Paused state - RED */
.prayer-item.active {
  background: var(--red-active) !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transform: scale(1.01);
}

/* Playing state - GREEN */
.prayer-item.playing {
  background: var(--green-playing) !important;
  border-color: rgba(255, 255, 255, 0.8) !important;
  animation: pulse 1.5s infinite;
}

/* When both classes exist, GREEN wins */
.prayer-item.active.playing {
  background: var(--green-playing) !important;
}

/* Manual items */
.prayer-item.manual {
  background: var(--yellow-manual);
}

.prayer-item.manual::before,
.prayer-item.manual::after {
  display: none;
}

@keyframes pulse {
  0% {
    transform: scale(0.99);
  }
  50% {
    transform: scale(1.005);
  }
  100% {
    transform: scale(0.99);
  }
}

.play-pause-btn {
  width: 100%;
  max-width: 320px;
  height: auto;
  aspect-ratio: 1 / 1;
  background: linear-gradient(
    135deg,
    var(--button-gradient-start, #f093fb) 0%,
    var(--button-gradient-end, #f5576c) 100%
  );
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  margin: 0 auto;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.play-pause-btn:focus {
  outline: none;
  border: none;
}

.play-pause-btn:active {
  transform: scale(0.95);
}

.play-icon {
  font-size: 6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--white);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.prayers-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Scrollbar styling */
.prayers::-webkit-scrollbar,
.library-prayers::-webkit-scrollbar {
  width: 6px;
}

.prayers::-webkit-scrollbar-track,
.library-prayers::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.prayers::-webkit-scrollbar-thumb,
.library-prayers::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 10px;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--modal-bg);
  backdrop-filter: blur(20px);
  border-radius: 25px;
  max-width: 90%;
  width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  color: var(--white);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--modal-border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  flex-direction: row-reverse;
}

.modal-header h2 {
  font-size: 1.8rem;
  margin: 0;
}

.modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--white);
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-close:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.25);
}

.modal-body {
  padding: 20px 25px;
}

.app-info {
  text-align: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.app-info h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.app-info p {
  font-size: 0.9rem;
  opacity: 0.8;
}

.theme-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.theme-section h3 {
  font-size: 1.3rem;
  margin-bottom: 15px;
}

.theme-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-btn {
  flex: 1;
  min-width: 80px;
  padding: 12px 15px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--white);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-btn:active {
  transform: scale(0.95);
}

.download-section {
  margin-bottom: 15px;
}

.download-section h3 {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.download-section p {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-bottom: 15px;
  line-height: 1.4;
}

.download-modal-btn,
.delete-download-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 10px;
}

.download-modal-btn {
  background: #4caf50;
  color: var(--white);
}

.delete-download-btn {
  background: #f44336;
  color: var(--white);
}

.download-modal-btn:active,
.delete-download-btn:active {
  transform: scale(0.98);
}

.download-status {
  font-size: 0.85rem;
  text-align: center;
  margin-top: 10px;
  opacity: 0.8;
}

.nav-prev-btn,
.nav-next-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--white);
  backdrop-filter: blur(5px);
  top: 75px;
}

.nav-prev-btn {
  left: 15px;
}

.nav-next-btn {
  right: 15px;
}

.nav-prev-btn:active,
.nav-next-btn:active {
  transform: scale(0.95);
}

/* Responsive */
@media (max-width: 768px) {
  .nav-prev-btn,
  .nav-next-btn {
    font-size: 1.3rem;
    width: 38px;
    height: 38px;
    top: 60px;
  }
  .nav-prev-btn {
    left: 8px;
  }
  .nav-next-btn {
    right: 8px;
  }
}

.date-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 5px 10px;
  border-radius: 15px;
}

.date-container:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.98);
}

/* Responsive */
@media (max-width: 768px) {
  .jalali-date {
    font-size: 2.2rem;
  }
  .time {
    font-size: 1.3rem;
    top: 5px;
    left: 10px;
  }
  .hijri-date {
    font-size: 1rem;
  }
  .prayer-item {
    padding: 10px;
    font-size: 1rem;
  }
  .prayers {
    flex: 4;
    padding: 8px;
  }
  .play-pause-btn {
    max-width: 220px;
  }
  .play-icon {
    font-size: 4rem;
  }
  .settings-toggle-btn {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    top: 8px;
    right: 58px;
  }
  .library-toggle-btn {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    top: 8px;
    right: 8px;
  }
  .nav-prev-btn,
  .nav-next-btn {
    font-size: 1.3rem;
    width: 38px;
    height: 38px;
    top: 60px;
  }
  .modal-content {
    width: 95%;
    max-width: 95%;
  }
  .modal-header {
    padding: 15px 20px;
  }
  .modal-header h2 {
    font-size: 1.4rem;
  }
  .theme-options {
    gap: 8px;
  }
  .theme-btn {
    min-width: 70px;
    padding: 10px;
    font-size: 0.9rem;
  }
}

@media (min-width: 1200px) {
  .modal-content {
    width: 1000px;
    max-width: 90%;
  }
}

/* Prayer item with duration on left */
.prayer-item {
  background: rgba(255, 255, 255, 0.15);
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.item-duration {
  font-size: 1.2rem;
  font-family: monospace;
  opacity: 0.8;
  min-width: 55px;
  text-align: left;
  direction: ltr;
  font-weight: bold;
}

.item-title {
  flex: 1;
  text-align: center;
}

@media (max-width: 768px) {
  .item-duration {
    font-size: 1.1rem;
    min-width: 50px;
  }
  .prayer-item {
    padding: 10px;
    font-size: 1rem;
  }
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0 20px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 20px;
  font-size: 1rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.3s ease;
  position: relative;
  font-weight: 500;
}

.tab-btn.active {
  color: white;
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #4caf50;
}

.tab-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Log Container */
.log-container {
  display: flex;
  flex-direction: column;
  height: 400px;
  max-height: 60vh;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

.clear-log-btn {
  background: rgba(244, 67, 54, 0.8);
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s ease;
}

.clear-log-btn:active {
  transform: scale(0.95);
}

.log-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 15px;
  font-family: monospace;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.15);
}

.log-entry {
  padding: 5px 15px;
  margin-bottom: 3px;
  border-radius: 4px;
  word-wrap: break-word;
  direction: ltr;
  text-align: left;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.7rem;
  line-height: 2.5;
}

.log-entry.info {
  background: rgba(33, 150, 243, 0.2);
  border-left: 3px solid #2196f3;
  color: #90caf9;
}

.log-entry.error {
  background: rgba(244, 67, 54, 0.2);
  border-left: 3px solid #f44336;
  color: #ffcdd2;
}

.log-entry.success {
  background: rgba(76, 175, 80, 0.2);
  border-left: 3px solid #4caf50;
  color: #a5d6a7;
}

.log-entry.debug {
  background: rgba(255, 152, 0, 0.15);
  border-left: 3px solid #ff9800;
  color: #ffe0b2;
  font-size: 0.65rem;
}

.log-entry.system {
  background: rgba(158, 158, 158, 0.15);
  border-left: 3px solid #9e9e9e;
  color: #e0e0e0;
  font-style: italic;
}

@media (max-width: 768px) {
  .log-container {
    height: 350px;
  }
  .log-entry {
    padding: 3px 8px;
    font-size: 0.65rem;
    line-height: 1.2;
  }
  .log-entry.debug {
    font-size: 0.6rem;
  }
}

/* Speed Control Buttons */
.speed-down-btn,
.speed-up-btn,
.speed-reset-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: white;
  margin: 0 10px;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
}

.speed-reset-btn {
  font-size: 1.5rem;
  background: rgba(76, 175, 80, 0.3);
  border-color: rgba(76, 175, 80, 0.5);
}

.play-pause-btn {
  width: 100%;
  max-width: 320px;
  height: auto;
  aspect-ratio: 1 / 1;
  background: linear-gradient(
    135deg,
    var(--button-gradient-start, #f093fb) 0%,
    var(--button-gradient-end, #f5576c) 100%
  );
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  margin: 0 auto;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  flex-shrink: 0;
}

.play {
  flex: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  position: relative;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .speed-down-btn,
  .speed-up-btn,
  .speed-reset-btn {
    width: 55px;
    height: 55px;
    font-size: 1.4rem;
    margin: 0 4px;
  }
  .speed-reset-btn {
    font-size: 1.2rem;
  }
  .play-pause-btn {
    max-width: 200px;
  }
  .play {
    gap: 8px;
    padding: 10px;
  }
  .play-icon {
    font-size: 4rem;
  }
}

@media (max-width: 480px) {
  .speed-down-btn,
  .speed-up-btn,
  .speed-reset-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    margin: 0 3px;
  }
  .speed-reset-btn {
    font-size: 1rem;
  }
  /* No max-width constraint for play-pause-btn on small phones */
  .play {
    gap: 6px;
    padding: 8px;
  }
  .play-icon {
    font-size: 3.5rem;
  }
}
