/* ==================================================================
   Regl Takip — tasarim dili
   Krem zemin, beyaz kartlar, mat kirmizi/bordo vurgular, yumusak golge.
   ================================================================== */

:root {
  --bg: #FBF6F2;
  --surface: #FFFFFF;
  --surface-sunken: #F5EBE5;

  --menstrual: #A13D3D;
  --follicular: #D98C8C;
  --ovulation: #C97B5A;
  --luteal: #8C4B5C;

  --accent: #A13D3D;
  --accent-soft: #F3E3E0;
  --accent-ink: #7E2E2E;

  --ink: #332326;
  --ink-soft: #6B565A;
  --ink-muted: #927C80;
  --line: #EEE2DC;

  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lifted: 0 6px 20px rgba(120, 60, 60, 0.12);

  --radius: 20px;
  --radius-sm: 14px;
  --gap: 18px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.view[hidden] { display: none; }

.muted { color: var(--ink-soft); margin: 0; }

.boot-note {
  max-width: 480px;
  margin: 40px auto;
  padding: 18px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font);
  color: var(--ink-soft);
  line-height: 1.6;
}
.boot-note code {
  background: var(--surface-sunken);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.9em;
}

/* ---------------- kart ---------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: var(--gap);
  border: none;
}

.card-title {
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--ink);
}

/* ---------------- butonlar ---------------- */

button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.primary-button {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.primary-button:hover { background: var(--accent-ink); }
.primary-button:active { transform: translateY(1px); }

.secondary-button {
  display: inline-block;
  padding: 12px 18px;
  margin: 0 8px 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
}
.secondary-button:hover { background: var(--surface-sunken); }

.danger-button {
  display: inline-block;
  padding: 12px 18px;
  border: 1px solid #E4C4C4;
  border-radius: var(--radius-sm);
  background: #FCF2F2;
  color: #8E3030;
  font-weight: 500;
}
.danger-button:hover { background: #F8E6E6; }

.text-button {
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 500;
  padding: 10px 4px;
}
.text-button:hover { text-decoration: underline; }

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.6rem;
  line-height: 1;
}
.icon-button:hover { background: var(--accent-soft); color: var(--accent-ink); }
.icon-button:disabled { opacity: 0.3; cursor: default; }
.icon-button:disabled:hover { background: transparent; color: var(--ink-soft); }
.icon-button-placeholder { width: 40px; height: 40px; display: inline-block; }

.row-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  text-align: left;
}
.row-button:last-of-type { border-bottom: none; }
.row-button:hover { color: var(--accent-ink); }
.row-chevron { color: var(--ink-muted); font-size: 1.3rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- üst çubuk ---------------- */

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0 18px;
}
.app-title {
  font-size: 1.15rem;
  flex: 1;
  text-align: center;
}
.app-bar .app-title:first-child { text-align: left; }

/* ---------------- ilk kurulum ---------------- */

.onboarding { padding-top: 24px; }
.onboarding-head { margin-bottom: 24px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.onboarding-title { font-size: 1.9rem; margin-bottom: 6px; }

.stepper-dots {
  display: flex;
  gap: 7px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.stepper-dots li {
  width: 26px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.2s ease;
}
.stepper-dots li.is-active { background: var(--accent); }

.step { border: none; margin: 0 0 var(--gap); }
.step-question {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.35;
  padding: 0;
  margin-bottom: 6px;
}
.step-help { margin: 0 0 20px; color: var(--ink-soft); font-size: 0.92rem; }
.step-range { margin: 14px 0 0; color: var(--ink-muted); font-size: 0.85rem; text-align: center; }

.onboarding-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.onboarding-actions .primary-button { flex: 1; }

/* ---------------- sayı seçici ---------------- */

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 4px;
}
.stepper-button {
  width: 44px;
  height: 44px;
  flex: none;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: var(--shadow);
}
.stepper-button:hover { background: #fff; color: var(--accent-ink); }
.stepper-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  flex: 1;
}
.stepper-value input {
  width: 3ch;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
  padding: 0;
  -moz-appearance: textfield;
}
.stepper-value input::-webkit-outer-spin-button,
.stepper-value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-unit { color: var(--ink-soft); font-size: 1rem; }

.field-label {
  display: block;
  margin: 18px 0 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.field-label:first-of-type { margin-top: 0; }

.field-help { margin: 8px 0 0; font-size: 0.86rem; color: var(--ink-muted); line-height: 1.55; }
.limitation { margin-top: 12px; }

.date-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
}

.form-error {
  margin: 12px 0 0;
  color: #A02C2C;
  font-size: 0.88rem;
  min-height: 1.2em;
}
.form-error:empty { display: none; }

#settings-form .primary-button { margin-top: 18px; }

/* ---------------- banner ---------------- */

.banners { display: grid; gap: 10px; margin-bottom: var(--gap); }
.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
}
.banner--warn { background: #FBEDE4; border-left-color: var(--ovulation); }
.banner--soft { background: #F7EAEA; border-left-color: var(--follicular); }
.banner-body { flex: 1; }
.banner-title { margin: 0 0 2px; font-weight: 600; font-size: 0.95rem; }
.banner-text { margin: 0; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.5; }
.banner-close {
  border: none;
  background: none;
  color: var(--ink-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 2px 4px;
}

/* ---------------- halka ---------------- */

.ring-card { padding: 26px 22px 20px; }

.ring-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  aspect-ratio: 1;
}
.ring-host { width: 100%; height: 100%; }
.ring { width: 100%; height: 100%; display: block; }
.ring-segment { transition: stroke-width 0.25s ease; }

.ring-center {
  position: absolute;
  inset: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  pointer-events: none;
}
.ring-phase {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.ring-day {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.ring-countdown {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.35;
}

.phase-note {
  margin: 22px 0 0;
  padding: 14px 16px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------------- "regl başladı mı?" ---------------- */

.period-button {
  background: var(--surface);
  color: var(--accent-ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
.period-button:hover { background: var(--surface-sunken); color: var(--accent-ink); }

/* tahmini tarihe 3 gün kala belirginleşir */
.period-button.is-due {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-lifted);
  animation: pulse 2.6s ease-in-out infinite;
}
.period-button.is-due:hover { background: var(--accent-ink); color: #fff; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(161, 61, 61, 0.22); }
  50% { box-shadow: 0 6px 26px rgba(161, 61, 61, 0.36); }
}
@media (prefers-reduced-motion: reduce) {
  .period-button.is-due { animation: none; }
  * { scroll-behavior: auto !important; }
}

.period-button-hint {
  margin: 10px 0 28px;
  text-align: center;
  font-size: 0.84rem;
  color: var(--ink-muted);
}

/* ---------------- takvim ---------------- */

.calendar-host { display: block; }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
/* Dar ekranda kartlar tek satir: etiket solda, tarih sagda. */
.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  margin: 0;
}
.summary-label {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  line-height: 1.35;
}
.summary-text { text-align: right; }
.summary-value { margin: 0; font-size: 0.98rem; font-weight: 600; line-height: 1.3; }
.summary-hint { margin: 2px 0 0; font-size: 0.8rem; color: var(--ink-soft); }

/* Genis ekranda yan yana üç kart. */
@media (min-width: 560px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .summary-card {
    display: block;
    padding: 16px;
  }
  .summary-label { margin-bottom: 6px; }
  .summary-text { text-align: left; }
}

.observed-note {
  margin: 0 0 var(--gap);
  padding: 0 6px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.calendar-card { padding: 18px 16px 16px; }

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.calendar-title { font-size: 1rem; font-weight: 600; }

.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.weekday-row {
  margin-bottom: 8px;
  font-size: 0.7rem;
  color: var(--ink-muted);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.month-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.month-track::-webkit-scrollbar { display: none; }

.month {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  position: relative;
}
.day--empty { background: none; }

/* tahmini günler: soluk/transparan */
.day--predicted {
  background: var(--phase-tint);
  color: var(--ink-soft);
}
/* gerçekleşmiş günler: dolu renk */
.day--actual {
  background: var(--phase-color);
  font-weight: 600;
}
/* döngü başlangıcı olarak kaydedilen gün */
.day--start::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}
.day--today {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  font-weight: 700;
}

.calendar-hint {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

.calendar-card .text-button { display: block; margin: 6px auto 0; }

/* ---------------- geçmiş / log ---------------- */

.log-actions { display: flex; flex-wrap: wrap; margin-bottom: 14px; }

.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.history-list li:last-child { border-bottom: none; }
.history-time {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}
.history-text { font-size: 0.93rem; line-height: 1.5; }

.tech-log {
  margin: 0;
  padding: 14px;
  max-height: 60vh;
  overflow: auto;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-note {
  padding: 28px 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.app-footer {
  margin-top: 26px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--ink-muted);
  line-height: 1.6;
}
.app-footer p { margin: 0; }

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

/* ---------------- toast & dialog ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  max-width: min(400px, calc(100vw - 36px));
  padding: 13px 20px;
  border-radius: 999px;
  background: #3B2A2D;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lifted);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.confirm-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  max-width: min(360px, calc(100vw - 40px));
  box-shadow: var(--shadow-lifted);
  color: var(--ink);
  font-family: var(--font);
}
.confirm-dialog::backdrop { background: rgba(51, 35, 38, 0.4); }
.confirm-dialog h2 { font-size: 1.1rem; margin-bottom: 8px; }
.confirm-dialog p { margin: 0 0 20px; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.55; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions button { margin: 0; }
