/* ── AAMAL NAMAH — CSS ────────────────────────────────── */
/* Mobile-first dark theme */

:root {
  --bg:         #0f1117;
  --bg2:        #161b27;
  --bg3:        #1e2535;
  --border:     #2a3045;
  --gold:       #c9a84c;
  --gold-dim:   #8a6e2f;
  --gold-light: #e8c96a;
  --text:       #e8eaf0;
  --text2:      #9aa3b8;
  --text3:      #5a6380;
  --green:      #3d9970;
  --green-bg:   #1a2e22;
  --red:        #c0392b;
  --red-bg:     #2e1a1a;
  --amber:      #e67e22;
  --amber-bg:   #2e2010;
  --blue:       #2980b9;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --header-h:   56px;
  --nav-h:      60px;
  --font:       'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; overflow:auto; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── LOGIN ────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(201,168,76,0.08) 0%, transparent 60%),
    var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 380px;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 28px 32px;
}

.login-brand { text-align: center; margin-bottom: 32px; }

.login-logo {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 14px;
  color: var(--gold);
  letter-spacing: -1px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.login-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.login-error {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: #e8a0a0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

/* ── APP SHELL ────────────────────────────────────────── */

.app-body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

/* ── HEADER ─────────────────────────────────────────── */

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 100;
}

.header-brand {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.header-center { text-align: center; flex: 1; line-height: 1.2; }

.header-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.header-hijri {
  font-size: 11px;
  color: var(--gold);
}

.header-right { display: flex; gap: 4px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.icon-btn:hover { color: var(--gold); }

/* ── MAIN CONTENT ────────────────────────────────────── */

.app-main {
  flex: 1;
  overflow-y: auto;
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  padding: 14px 14px 20px;
  -webkit-overflow-scrolling: touch;
}

/* ── VIEWS ──────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

/* ── CARDS ──────────────────────────────────────────── */

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-badge {
  background: var(--bg3);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.card-badge.alert { background: var(--red-bg); color: #e8a0a0; border-color: var(--red); }

/* ── PRAYERS ─────────────────────────────────────────── */

.prayer-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.prayer-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.prayer-row:last-child { border-bottom: none; }

.prayer-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  color: var(--text);
}

.prayer-time {
  font-size: 11px;
  color: var(--text3);
  margin-right: 8px;
}

.prayer-actions { display: flex; gap: 8px; }

.prayer-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.prayer-btn.prayed {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

.prayer-btn.missed {
  background: var(--red-bg);
  border-color: var(--red);
  color: #e8a0a0;
}

.prayer-btn.pending {
  background: var(--bg3);
  border-color: var(--border);
  color: var(--text2);
}

.prayer-btn.prayed.active,
.prayer-btn.missed.active {
  opacity: 1;
}

.prayer-btn:not(.active) {
  opacity: 0.45;
}

.prayer-btn.active {
  opacity: 1;
}

/* ── RAMADAN ──────────────────────────────────────────── */

.ramadan-day {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}

.fast-status-row {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
}

.fast-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  transition: all 0.15s;
  text-align: center;
}

.fast-btn.fasted.active {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

.fast-btn.missed.active {
  background: var(--red-bg);
  border-color: var(--red);
  color: #e8a0a0;
}

/* ── REMINDERS ───────────────────────────────────────── */

.reminder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.reminder-item:last-child { border-bottom: none; }

.reminder-icon-wrap {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border-radius: 50%;
  flex-shrink: 0;
}

.reminder-info { flex: 1; }

.reminder-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.reminder-desc {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.reminder-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}

.reminder-check.done {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}

/* ── TIMELINE ─────────────────────────────────────────── */

.timeline-list { padding: 8px 0; }

.timeline-entry {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.timeline-entry:last-child { border-bottom: none; }
.timeline-entry:hover { background: var(--bg3); }

.entry-time-col {
  width: 54px;
  flex-shrink: 0;
  text-align: right;
  padding-top: 2px;
}

.entry-time {
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

.entry-time-end {
  font-size: 10px;
  color: var(--text3);
  display: block;
  margin-top: 2px;
}

.entry-dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding-top: 5px;
}

.entry-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-dim);
  flex-shrink: 0;
}

.entry-dot-line {
  width: 1px;
  flex: 1;
  background: var(--border);
  min-height: 20px;
}

.entry-content { flex: 1; min-width: 0; }

.entry-type-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.entry-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-details {
  font-size: 12px;
  color: var(--text2);
  margin-top: 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.timeline-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* Entry type colors */
.type-worship   { color: #9b59b6; } .dot-worship   { background: #9b59b6; }
.type-food      { color: #e67e22; } .dot-food      { background: #e67e22; }
.type-sleep     { color: #2980b9; } .dot-sleep     { background: #2980b9; }
.type-work      { color: #1abc9c; } .dot-work      { background: #1abc9c; }
.type-study     { color: #3498db; } .dot-study     { background: #3498db; }
.type-travel    { color: #f39c12; } .dot-travel    { background: #f39c12; }
.type-good_deed { color: var(--green); } .dot-good_deed { background: var(--green); }
.type-bad_action{ color: var(--red); }  .dot-bad_action{ background: var(--red); }
.type-household { color: #95a5a6; } .dot-household { background: #95a5a6; }
.type-other     { color: var(--text3); } .dot-other { background: var(--text3); }

/* ── QAZA ─────────────────────────────────────────────── */

.qaza-list { padding: 0; }

.qaza-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.qaza-item:last-child { border-bottom: none; }

.qaza-info { flex: 1; }

.qaza-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.qaza-date {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.qaza-notes {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
  font-style: italic;
}

.qaza-done-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--green-bg);
  border: 1px solid var(--green);
  color: var(--green);
  cursor: pointer;
  white-space: nowrap;
}

.qaza-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* ── ZAKAT ─────────────────────────────────────────────── */

.zakat-status-block {
  padding: 16px;
}

.zakat-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.zakat-label {
  font-size: 13px;
  color: var(--text2);
}

.zakat-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
}

.zakat-due { color: var(--amber); }
.zakat-paid { color: var(--green); }

/* ── HISTORY ─────────────────────────────────────────── */

.history-list { padding: 0; }

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--bg3); }

.history-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.history-hijri {
  font-size: 11px;
  color: var(--gold);
}

.history-export-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.history-export-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ── BOTTOM NAV ──────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  transition: color 0.15s;
  padding: 8px 0;
}

.nav-btn.active { color: var(--gold); }
.nav-btn:hover { color: var(--text2); }

.nav-icon { font-size: 18px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; }

/* ── FORMS ───────────────────────────────────────────── */

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-group.half { flex: 1; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold-dim);
}

textarea { resize: vertical; min-height: 80px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239aa3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── BUTTONS ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-full { width: 100%; }

.btn-primary {
  background: var(--gold);
  color: #0f1117;
  border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-light); }

.btn-gold {
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border-color: var(--gold-dim);
}
.btn-gold:hover { background: rgba(201,168,76,0.25); }

.btn-ghost {
  background: none;
  color: var(--text2);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--text3); color: var(--text); }

.btn-danger {
  background: var(--red-bg);
  color: #e8a0a0;
  border-color: var(--red);
}

.btn-danger-ghost {
  background: none;
  color: #e8a0a0;
  border-color: transparent;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ── TOGGLE ROW ──────────────────────────────────────── */

.toggle-row {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn.active {
  background: var(--bg3);
  color: var(--gold);
}

/* ── MODALS ──────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
}

.modal-sm {
  border-radius: 16px;
  margin: 20px;
  width: auto;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px 20px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-footer .btn { flex: 1; }

/* ── REMINDER POPUP ──────────────────────────────────── */

.reminder-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
}

.reminder-popup.hidden { display: none; }

.reminder-popup-inner {
  background: var(--bg2);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  animation: popIn 0.25s ease;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.reminder-icon { font-size: 40px; margin-bottom: 12px; }

.reminder-popup-inner h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 10px;
}

.reminder-popup-inner p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 20px;
}

.reminder-popup-inner .btn { width: 100%; margin-bottom: 8px; }
.reminder-popup-inner .btn:last-child { margin-bottom: 0; }

/* ── TOAST ───────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 90%;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 30px;
  animation: toastIn 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: #e8a0a0; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SETTINGS ────────────────────────────────────────── */

.settings-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.settings-section-title {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.settings-row:last-child { border-bottom: none; }

.settings-row-label {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.settings-row-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.settings-row input,
.settings-row select {
  width: auto;
  max-width: 140px;
  font-size: 13px;
  padding: 7px 10px;
}

.month-override-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }

.month-override-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.month-override-row select,
.month-override-row input {
  flex: 1;
  font-size: 13px;
  padding: 8px 10px;
}

/* ── SPINNER ─────────────────────────────────────────── */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #0f1117;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* ── UTILS ───────────────────────────────────────────── */

.hidden { display: none !important; }

.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text3); }
.text-center { text-align: center; }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

/* ── LOADING STATE ────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-text {
  font-size: 13px;
  color: var(--text3);
}

/* ── SAFE AREA (iPhone notch) ────────────────────────── */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .app-main {
    margin-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
}
