/* =========================================================
   Birinchi Qadam — styles
   ========================================================= */

:root {
  /* Telegram theme colors with fallbacks */
  --bg:              var(--tg-theme-bg-color, #ffffff);
  --text:            var(--tg-theme-text-color, #1a1a1a);
  --hint:            var(--tg-theme-hint-color, #8a8a8a);
  --link:            var(--tg-theme-link-color, #2481cc);
  --button:          var(--tg-theme-button-color, #2481cc);
  --button-text:     var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg:    var(--tg-theme-secondary-bg-color, #f4f4f5);

  /* Brand */
  --accent:       #0a7d4d;
  --accent-soft:  #e6f4ec;
  --danger:       #d33a2c;
  --separator:    rgba(0,0,0,0.08);

  --radius:     16px;
  --radius-sm:  10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --separator: rgba(255,255,255,0.10);
    --accent-soft: rgba(10, 125, 77, 0.18);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 88px;
  position: relative;
}

/* ---------- Header ---------- */
.header {
  padding: 18px 16px 10px;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
  flex: 1;
}
.subtitle {
  color: var(--hint);
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.45;
}
.date {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--hint);
  font-weight: 500;
  text-transform: capitalize;
}

.progress-summary {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: none;
}
.progress-summary.visible { display: block; }

/* ---------- Icon button ---------- */
.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary-bg);
  border: none;
  border-radius: 50%;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- Content area ---------- */
.content { padding: 4px 16px 16px; }

/* ---------- Sections ---------- */
.section { margin-bottom: 22px; }
.section-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--hint);
  margin: 14px 4px 6px;
}
.section-hint {
  font-size: 12px;
  color: var(--hint);
  margin: 0 4px 10px;
  font-style: italic;
  line-height: 1.4;
}

.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- Item (dashboard) ---------- */
.item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--separator);
  transition: background .2s ease;
}
.item:last-child { border-bottom: none; }
.item.done { background: var(--accent-soft); }

.item-body { flex: 1; min-width: 0; }
.item-title {
  font-weight: 600;
  font-size: 15px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.item-arabic {
  font-size: 19px;
  color: var(--text);
  margin-top: 4px;
  direction: rtl;
  font-family: "Amiri", "Traditional Arabic", "Scheherazade", serif;
  line-height: 1.6;
}
.item-hint {
  font-size: 12px;
  color: var(--hint);
  margin-top: 3px;
  line-height: 1.35;
}

.progress-bar {
  height: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width .25s ease;
  width: 0%;
}

/* ---------- Counter ---------- */
.counter {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.count-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .08s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.count-btn:active { transform: scale(0.90); }
.count-btn.minus {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--separator);
}
.count-btn:disabled { opacity: 0.35; cursor: default; }

.count-value {
  min-width: 62px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
}
.count-value .done-mark {
  color: var(--accent);
  margin-left: 4px;
}

/* ---------- Empty state ---------- */
.empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--hint);
  font-size: 14px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  border: 1px dashed var(--separator);
  line-height: 1.5;
}
.empty a { color: var(--link); font-weight: 500; }
.empty.inline {
  background: transparent; border: none; padding: 16px;
}

/* ---------- Bottom nav ---------- */
.bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--bg);
  border-top: 1px solid var(--separator);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  z-index: 5;
}
.nav-btn {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  color: var(--hint);
  font-size: 18px;
  font-weight: 500;
  border-radius: 8px;
  line-height: 1;
}
.nav-btn span {
  display: block;
  font-size: 11px;
  margin-top: 2px;
  font-weight: 500;
}
.nav-btn.active {
  color: var(--button);
}
.hidden { display: none !important; }

/* ---------- Toggle (settings) ---------- */
.toggle-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--separator);
}
.toggle-item:last-child { border-bottom: none; }
.toggle-item .item-body { flex: 1; }

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #bbb;
  border-radius: 999px;
  transition: background .2s ease;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  top: 3px; left: 3px;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--button); color: var(--button-text); }
.btn.ghost   { background: var(--secondary-bg); color: var(--text); }
.btn.danger  { background: transparent; color: var(--danger); }
.btn.small   { padding: 6px 10px; font-size: 12.5px; }
.btn.full    { width: 100%; }

/* ---------- Admin item ---------- */
.admin-item {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--separator);
  align-items: flex-start;
}
.admin-item:last-child { border-bottom: none; }
.admin-item .item-body { flex: 1; min-width: 0; }
.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.badge.off { background: rgba(0,0,0,0.06); color: var(--hint); }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  border: none;
  font-size: 28px;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  z-index: 10;
  cursor: pointer;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}
.modal-content {
  position: relative;
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .22s ease;
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--separator);
  border-radius: 999px;
  margin: 0 auto 10px;
}
.modal-content h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.modal-content label {
  display: block;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--hint);
  font-weight: 500;
}
.modal-content label.row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content select,
.modal-content textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 11px 12px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  border-color: var(--button);
}
.modal-content .actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.modal-content .actions .btn { flex: 1; }

/* ---------- Loader / Toast ---------- */
.loader {
  text-align: center;
  padding: 40px 16px;
  color: var(--hint);
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slideDown .25s ease;
  max-width: 90%;
}

@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translate(-50%,-20px); opacity: 0; } to { transform: translate(-50%,0); opacity: 1; } }
@keyframes slideUp   { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
