/* ============================================================
   Amal Tracker — calm, mobile-first Islamic-inspired styling
   Palette: deep green, warm gold, soft cream
   ============================================================ */

:root {
  --green-900: #0b2f27;
  --green-800: #0f3d33;
  --green-700: #17564a;
  --green-500: #2c7a68;
  --green-100: #dcece7;

  --gold-600: #a9853f;
  --gold-500: #c9a227;
  --gold-100: #f6eed8;

  --cream:     #f7f4ec;
  --surface:   #ffffff;
  --ink:       #1d2b28;
  --ink-muted: #6b7c78;
  --line:      #e3e0d6;

  --danger-bg: #fdecea;
  --danger-fg: #a1352b;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(11, 47, 39, .05), 0 6px 20px rgba(11, 47, 39, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--cream);
  /* Subtle geometric motif in the page ground */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(15, 61, 51, .05) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--green-700); }

.arabic { font-family: 'Amiri', Georgia, serif; }
.muted  { color: var(--ink-muted); }
.small  { font-size: .85rem; }
.center { text-align: center; }

/* ---------- header ---------- */

.site-header {
  background: linear-gradient(160deg, var(--green-800), var(--green-900));
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  padding-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  font-family: 'Amiri', Georgia, serif;
  font-size: 1.75rem;
  color: var(--gold-500);
  line-height: 1;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { font-size: .72rem; color: var(--green-100); opacity: .75; }

.logout-form { display: flex; align-items: center; gap: 8px; }

.user-chip {
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  white-space: nowrap;
}

.user-chip.updater { color: #fff; background: rgba(201, 162, 39, .3); border-color: rgba(201, 162, 39, .5); }

.btn-logout {
  background: none;
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  font: inherit;
  font-size: .78rem;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-logout:hover { background: rgba(255, 255, 255, .1); }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 4px; }

.tabs a {
  flex: 1;
  text-align: center;
  padding: 11px 4px;
  color: var(--green-100);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  opacity: .8;
}

.tabs a.active {
  color: #fff;
  opacity: 1;
  border-bottom-color: var(--gold-500);
  font-weight: 600;
}

/* ---------- cards ---------- */

main.wrap { flex: 1; padding-top: 18px; padding-bottom: 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.center-card { text-align: center; }
.center-card h1 { font-size: 1.2rem; margin-bottom: 6px; }
.center-card .btn { margin-top: 14px; display: inline-block; }

/* ---------- date card ---------- */

.date-card { padding-bottom: 16px; }

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.date-arrow {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  text-decoration: none;
  color: var(--green-700);
  background: var(--green-100);
  border-radius: 50%;
}
.date-arrow:hover { background: #cfe3dd; }
.date-arrow.disabled { color: var(--line); background: transparent; cursor: default; }

.date-current { text-align: center; }
.date-weekday {
  margin: 0;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold-600);
  font-weight: 600;
}
.date-long { font-size: 1.25rem; margin-top: 2px; }

/* progress ring */

.progress-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ring {
  --pct: 0;
  flex: 0 0 auto;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--green-500) calc(var(--pct) * 1%),
    var(--green-100) 0
  );
}

.ring span {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .95rem;
  color: var(--green-800);
}

.progress-text { display: flex; flex-direction: column; }
.progress-text strong { font-size: 1rem; }
.progress-text .muted { font-size: .87rem; }

.streak {
  margin: 14px 0 0;
  padding: 9px 12px;
  background: var(--gold-100);
  border-radius: var(--radius-sm);
  font-size: .87rem;
  color: #6d551f;
  text-align: center;
}

.viewing-note {
  margin: -4px 0 14px;
  font-size: .85rem;
  text-align: center;
  color: var(--ink-muted);
}

/* ---------- Bilu mood cards ---------- */

.bilu-grid {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 14px;
}

.bilu-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.bilu-card.done   { border-color: var(--green-500); }
.bilu-card.undone { border-color: #e8c9c4; }

/* Bilu's photo — square, fixed width so every card lines up. */
.bilu-photo {
  flex: 0 0 122px;
  position: relative;
  background: var(--green-100);
}

.bilu-card.undone .bilu-photo { background: #f7e6e3; }

.bilu-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.bilu-body {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
}

.bilu-name {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.2;
}

.bilu-status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.bilu-status .mark {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.bilu-status.yes { color: var(--green-700); }
.bilu-status.yes .mark { background: var(--green-500); }

.bilu-status.no { color: #b0483c; }
.bilu-status.no .mark { background: #d4695c; }

.bilu-status .when {
  font-weight: 400;
  color: var(--ink-muted);
  font-size: .82rem;
}

.bilu-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: .8rem;
  color: var(--ink-muted);
}

.bilu-days strong { color: var(--ink); font-size: .95rem; }

/* the updater's toggle inside each card */
.bilu-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 38px;
}

.bilu-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.bilu-card.done .toggle-label { color: var(--green-700); }

.check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: all .15s ease;
}

.check::after {
  content: "\2713";
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  opacity: 0;
  transform: scale(.6);
  transition: all .15s ease;
}

.bilu-toggle input:checked + .check {
  background: var(--green-500);
  border-color: var(--green-500);
}

.bilu-toggle input:checked + .check::after { opacity: 1; transform: scale(1); }

.bilu-toggle input:focus-visible + .check {
  outline: 3px solid var(--gold-500);
  outline-offset: 2px;
}

.tracked-note { margin-top: 4px; }

/* ---------- buttons & alerts ---------- */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--green-700);
  color: #fff;
}
.btn-primary:hover { background: var(--green-800); }
.btn-primary:active { transform: translateY(1px); }

.btn-block { display: block; width: 100%; }

.save-bar { margin-bottom: 8px; }
.save-bar .muted { margin: 8px 0 0; }
.readonly-note { margin-top: 4px; }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin: 0 0 16px;
}
.alert-success { background: var(--green-100); color: var(--green-800); }
.alert-error   { background: var(--danger-bg);  color: var(--danger-fg); }

/* ---------- login ---------- */

.login-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}

.login-mark {
  font-family: 'Amiri', Georgia, serif;
  font-size: 2.9rem;
  color: var(--gold-500);
  line-height: 1;
  margin-bottom: 8px;
}

.login-card h1 { font-size: 1.4rem; }
.login-card > .muted { margin: 6px 0 22px; font-size: .9rem; }

.login-card form { text-align: left; }

.login-card label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  font: inherit;
  font-size: 1rem; /* 16px keeps iOS from zooming on focus */
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfcf9;
  color: var(--ink);
}

.login-card input:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(44, 122, 104, .15);
}

.login-card .btn { margin-top: 6px; }

.login-note {
  margin-top: 26px;
  font-size: 1.15rem;
  color: var(--green-700);
  opacity: .7;
}

/* ---------- date filter ---------- */

.filter-card { padding: 14px; }

.filter-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #f1efe7;
  padding: 4px;
  border-radius: 11px;
}

.filter-pill {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}

.filter-pill:hover { color: var(--green-700); }

.filter-pill.active {
  background: var(--surface);
  color: var(--green-800);
  box-shadow: 0 1px 3px rgba(11, 47, 39, .12);
}

.filter-period {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.filter-period.no-nav { justify-content: center; }

.filter-period-text {
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.filter-period-text strong { font-size: 1.05rem; }

.filter-period-text small {
  font-size: .74rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* custom range form */

.filter-custom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filter-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.filter-field label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-muted);
}

.filter-field input[type="date"] {
  font: inherit;
  font-size: .92rem;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfcf9;
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

.filter-field input[type="date"]:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(44, 122, 104, .15);
}

.filter-apply {
  grid-column: 1 / -1;
  padding: 11px 16px;
  font-size: .92rem;
}

@media (max-width: 360px) {
  .filter-presets { grid-template-columns: repeat(2, 1fr); }
  .filter-pill { font-size: .8rem; }
  .filter-custom { grid-template-columns: 1fr; }
}

/* ---------- password reveal ---------- */

.password-field { position: relative; }

/* Room for the icon so long passwords never slide under it. */
.password-field input { padding-right: 52px; }

.password-toggle {
  position: absolute;
  top: 0;
  right: 8px;
  /* The input carries a 16px bottom margin; match the input box height. */
  height: calc(100% - 16px);
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--green-700);
  cursor: pointer;
  border-radius: 7px;
}

.password-toggle svg { display: block; }

/* Author styles beat the browser default for [hidden], so restate it. */
.password-toggle svg[hidden] { display: none; }

.password-toggle:hover { background: var(--green-100); }

.password-toggle:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 1px;
}

/* ---------- per-amal update time ---------- */

.bilu-time {
  margin: -2px 0 0;
  font-size: .76rem;
  color: var(--ink-muted);
}

.bilu-time.pending {
  color: var(--gold-600);
  font-style: italic;
}

/* ---------- history ---------- */

.table-card { padding: 14px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  font-size: .74rem;
  color: var(--ink-muted);
}
.legend-item b {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--green-100);
  color: var(--green-800);
  margin-right: 3px;
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.history-table th,
.history-table td {
  padding: 10px 6px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.history-table thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  font-weight: 600;
}

.history-table tbody tr:last-child th,
.history-table tbody tr:last-child td { border-bottom: none; }

.history-table tr.is-today { background: var(--gold-100); }

.col-date { text-align: left !important; white-space: nowrap; font-weight: 500; }
.col-date a { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; line-height: 1.2; }
.col-date a:hover strong { text-decoration: underline; }
.col-date small { font-size: .72rem; color: var(--ink-muted); font-weight: 400; }

.col-activity { width: 38px; }

.tick { font-size: 1rem; font-weight: 700; }
.tick.yes { color: var(--green-500); }
.tick.no  { color: #cfcabb; }

.count-badge {
  display: inline-block;
  font-size: .74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f0eee7;
  color: var(--ink-muted);
  white-space: nowrap;
}
.count-badge.full { background: var(--green-100); color: var(--green-800); }

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-tile {
  margin: 0;
  padding: 16px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-800);
  line-height: 1.1;
}

.stat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink);
}

.stat-tile .small { font-size: .68rem; }

.bar-list { list-style: none; margin: 0; padding: 0; }
.bar-row { margin-bottom: 18px; }
.bar-row:last-child { margin-bottom: 0; }

.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}

.bar-figure { font-size: .8rem; color: var(--ink-muted); white-space: nowrap; }
.bar-figure b { color: var(--green-700); font-size: .9rem; margin-left: 4px; }

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--green-100);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-500), var(--green-700));
  transition: width .4s ease;
}

/* ---------- footer ---------- */

.site-footer {
  text-align: center;
  padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.site-footer .arabic { font-size: 1.15rem; color: var(--green-700); margin: 0 0 4px; }
.site-footer p { margin: 0; }

/* ---------- responsive ---------- */

@media (max-width: 380px) {
  .brand-text small { display: none; }
  .user-chip { display: none; }
  .stat-value { font-size: 1.35rem; }
  .date-long { font-size: 1.1rem; }
}

@media (min-width: 720px) {
  main.wrap { padding-top: 26px; }
  .card { padding: 22px; }
  .date-long { font-size: 1.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Bilu cards: responsive ---------- */

@media (max-width: 360px) {
  .bilu-photo { flex-basis: 98px; }
  .bilu-body { padding: 12px 13px; }
  .bilu-name { font-size: 1rem; }
  .bilu-status { font-size: .82rem; }
  .bilu-status .when { display: none; }
}

@media (min-width: 560px) {
  .bilu-photo { flex-basis: 150px; }
  .bilu-body { padding: 16px 20px; }
}
