/* ==================== CENTRAL STYLE ==================== */
/* ==================== THEME VARIABLES ==================== */
:root {
  --bg: #f5f5f5;
  --text: #222222;
  --card: #ffffff;
  --border: #ddd;
  --accent: #4CAF50;
  --accent-hover: #45a049;
  --secondary-text: #666666;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --text: #e0e0e0;
  --card: #1e1e1e;
  --border: #333333;
  --accent: #6bdc8b;
  --accent-hover: #57c47d;
  --secondary-text: #bbbbbb;
}

/* ==================== BODY ==================== */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 20px;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

html {
  transition: background-color 0.3s, color 0.3s;
}

@font-face {
  font-family: "Noto Sans Arabic";
  src: url("fonts/NotoSansArabic-SemiBold.ttf") format("truetype");
}

/* ==================== CONTAINER ==================== */
.container {
  max-width: 600px;
  width: 100%;
  background: var(--card);
  color: var(--text);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  flex:1;
  display: flex;
  flex-direction: column;
  gap: 30px;
  transition: background-color 0.3s, color 0.3s;
}

/* ==================== HEADINGS ==================== */
h1 {
  text-align: center;
  margin: 0;
  font-size: 2em;
}

/* ==================== BIG BUTTONS ==================== */
.big-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.big-button {
  flex: 1 1 45%;
  aspect-ratio: 1 / 1;
  font-size: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s ease;
}

.big-button:hover {
  background: var(--accent-hover);
}

.big-button .emoji {
  font-size: 3.5rem;
}

.big-button .label {
  font-weight: bold;
}

/* ==================== SMALL BUTTONS ==================== */
.small-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  justify-content: start;
}

.small-button {
  background: var(--card);
  color: var(--text);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  padding: 12px 0;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: background-color 0.3s ease, color 0.3s ease;
  position: relative;
  border: 2px solid var(--border);
}

.small-button:hover {
  background: var(--border);
}

.small-button .emoji {
  font-size: 2rem;
}

.small-button .label {
  font-weight: normal;
  color: var(--secondary-text);
}

.top-icons {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  gap: 2px;
}

.os-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: transform 0.2s;
}

.small-button:hover .os-icon {
  transform: scale(1.1);
}

.locked {
  background: repeating-linear-gradient(
    45deg,
    #ccc,
    #ccc 10px,
    #bbb 10px,
    #bbb 20px
  );
  color: #777;
  position: relative;
}

.locked::after {
  content: "🔒";
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.2rem;
  opacity: 0.8;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
  .big-buttons {
    flex-direction: column;
    gap: 20px;
  }
  .big-button {
    flex: none;
    width: 100%;
  }
  .small-buttons {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  .os-icon {
    width: 16px;
    height: 16px;
  }
}

/* ==================== ALERTS ==================== */
.alert-popup {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  max-width: 80%;
  padding: 15px 25px;
  color: white;
  font-weight: bold;
  border-radius: 12px;
  text-align: center;
  font-size: 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 9999;
  box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.alert-popup.show {
  opacity: 1;
  pointer-events: auto;
}

.alert-popup.success {
  background-color: #4CAF50;
}

.alert-popup.error {
  background-color: #f44336;
}

/* ==================== QURAN AND SURAHS ==================== */
.surah-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .surah-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.surah-card {
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 15px 20px;
  box-shadow: 0 0 8px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: box-shadow 0.3s, transform 0.2s, background-color 0.3s, color 0.3s;
  user-select: none;
  border: 2px solid var(--border);
}

.surah-card:hover {
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  transform: scale(1.02);
}

.surah-card.incomplete {
  opacity: 0.6;
  filter: grayscale(50%);
  position: relative;
  cursor: pointer;
}

.surah-card.incomplete::after {
  content: "НЕ ЗАВЕРШАНА";
  position: absolute;
  bottom: -8px;
  right: -8px;
  background: #f44336;
  color: white;
  padding: 3px 8px;
  font-size: 0.75em;
  border-radius: 8px;
  font-weight: bold;
  user-select: none;
  z-index: 5;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.top-row {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 10px;
}

.divider {
  border-top: 1px solid var(--border);
  margin-bottom: 10px;
}

.bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-style: italic;
  color: var(--secondary-text);
  font-size: 0.9em;
}

.read-badge {
  background-color: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.85em;
  white-space: nowrap;
}

/* ==================== HOME BUTTON ==================== */
.home-button {
  margin-bottom: 20px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 1.1em;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  align-self: flex-start;
  transition: background-color 0.3s ease;
}

.home-button:hover {
  background: var(--accent-hover);
}

.home-button:active {
  background: var(--accent-hover);
}

/* ==================== THEME BUTTON ==================== */
#themeToggle {
  margin-bottom: 20px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 1.1em;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  align-self: flex-end;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  transition: background-color 0.3s ease;
}

#themeToggle:hover {
  background: var(--accent-hover);
}

#themeToggle:active {
  background: var(--accent-hover);
}

/* ==================== SCROLL TOP ==================== */
.scroll-top {
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, background-color 0.3s;
  z-index: 2000;
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
  .big-buttons {
    flex-direction: column;
    gap: 20px;
  }
  .big-button {
    flex: none;
    width: 100%;
  }
  .small-buttons {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

/* ==================== PRINT ==================== */
@media print {
  :root {
    --bg: #fff;
    --text: #000;
    --card: #fff;
    --border: #000;
    --accent: #4CAF50;
    --accent-hover: #45a049;
    --secondary-text: #000;
  }

  body, .container, .surah-card, table {
    background-color: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
  }

  button, .home-button, .big-button, .small-button, .scroll-top {
    display: none !important;
  }
}

/* ==================== PAGE WRAPPER ==================== */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==================== FOOTER ==================== */
.footer {
  background: var(--accent);
  color: white;
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 12px 0;
  box-shadow: 0 -3px 8px rgba(0,0,0,0.2);
  flex-shrink: 0; /* don't shrink */
  flex-wrap: wrap;
}

.footer-button {
  background: white;
  color: var(--accent);
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s, color 0.3s;
}

.footer-button:hover {
  background: var(--accent-hover);
  color: white;
}

@media (max-width: 480px) {
  .footer {
    flex-direction: column;
    gap: 10px;
  }
}