/* Asistan paneli — mobil öncelikli, açık/koyu tema */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1d1f21;
  --muted: #6b6e72;
  --line: #e2dfd7;
  --accent: #2c6e5a;
  --accent-ink: #ffffff;
  --accent-soft: #e1eee9;
  --danger: #b4332b;
  --danger-soft: #f8e6e4;
  --warn: #9a6400;
  --radius: 12px;
  --tap: 44px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1f2224;
    --surface-2: #272a2d;
    --text: #e8e6e1;
    --muted: #9a9da1;
    --line: #2f3336;
    --accent: #5fb89b;
    --accent-ink: #0f1a16;
    --accent-soft: #1d332b;
    --danger: #ef7b72;
    --danger-soft: #3a2220;
    --warn: #e0a83c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2 { margin: 0; line-height: 1.2; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- yerleşim ---------- */
.main {
  padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}
.page-head { margin: 8px 0 16px; }
.page-head h1 { font-size: 28px; letter-spacing: -0.01em; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- gezinme: mobilde altta ---------- */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav-logout { display: contents; }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap);
  color: var(--muted); text-decoration: none; font: inherit; font-size: 12px;
  background: none; border: 0; cursor: pointer;
}
.nav-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.is-active { color: var(--accent); font-weight: 600; }

/* ---------- butonlar ve formlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-block { width: 100%; }
.btn-danger-quiet { color: var(--danger); background: transparent; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .check:focus-visible, .nav-item:focus-visible, .task-body:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

input, select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* iOS yakınlaştırmasını önler */
}
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }

.form { display: grid; gap: 14px; }
.form-task { grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }
.danger-zone { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

.quick-add { display: flex; gap: 8px; margin-bottom: 20px; }
.quick-add input { flex: 1; min-width: 0; }
.main { overflow-x: clip; }
.filters > label, .form-task > label { min-width: 0; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }

/* ---------- bildirim kutuları ---------- */
.flashes { display: grid; gap: 8px; margin-bottom: 12px; }
.flash {
  padding: 10px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text); font-size: 14px;
}
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- bölümler ve görev listesi ---------- */
.section { margin-bottom: 26px; }
.section h2 {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.section-overdue h2 { color: var(--danger); }
.count { font-variant-numeric: tabular-nums; font-weight: 500; }
.empty { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
.list-foot { color: var(--muted); font-size: 13px; margin-top: 10px; }

.tasks {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.task { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task form { display: flex; }
.check {
  width: 52px; min-height: 52px;
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer; color: var(--muted);
}
.check::before {
  content: ""; grid-area: 1 / 1;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.8px solid currentColor;
}
.check svg {
  grid-area: 1 / 1; width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0;
}
.check:hover svg { opacity: 0.45; }
.check.is-checked { color: var(--accent); }
.check.is-checked::before { background: var(--accent); border-color: var(--accent); }
.check.is-checked svg { opacity: 1; stroke: var(--accent-ink); }
.prio-high .check { color: var(--danger); }

.task-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 10px 14px 10px 0;
  color: inherit; text-decoration: none;
}
.task-title { overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.task-meta:empty { display: none; }
.meta-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.is-overdue .meta-date { color: var(--danger); font-weight: 600; }
.tag { color: var(--accent); }
.badge {
  padding: 0 7px; border-radius: 6px; font-size: 12px; line-height: 20px;
  background: var(--surface-2); color: var(--muted);
}
.badge-high { background: var(--danger-soft); color: var(--danger); }
.is-done .task-title, .is-cancelled .task-title { text-decoration: line-through; color: var(--muted); }

/* ---------- giriş ---------- */
.login { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; }
.login-title { font-size: 32px; letter-spacing: -0.01em; }
.login-sub { color: var(--muted); margin: 6px 0 24px; }
.login .flash { margin-bottom: 14px; }

/* ---------- masaüstü: kenar çubuğu + iki sütun ---------- */
@media (min-width: 900px) {
  body:not(.page-login) { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
  .nav {
    position: sticky; top: 0; inset: auto; height: 100vh;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 24px 12px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-brand { display: block; font-weight: 700; font-size: 20px; padding: 0 12px 18px; }
  .nav-item {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 0 12px; border-radius: 10px; font-size: 15px; width: 100%;
  }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.is-active { background: var(--accent-soft); }
  .nav-logout .nav-item { margin-top: auto; }
  .nav-logout { display: flex; margin-top: auto; }
  .main { padding: 32px 40px 48px; width: 100%; }
  .today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .form-task { max-width: 720px; }
  .quick-add { max-width: 720px; }
}

/* ---------- Faz 2: gezinme parçaları ---------- */
.nav-desktop { display: none; }
@media (min-width: 900px) {
  .nav-desktop { display: flex; }
  .nav-mobile { display: none; }
  .nav-logout.nav-desktop { display: flex; margin-top: auto; }
}

.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.menu { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a { display: flex; align-items: center; min-height: 52px; padding: 0 16px; color: inherit; text-decoration: none; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.warn-text { color: var(--warn); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent); }
.check-row { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.check-row input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- kartlar ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card-link { color: inherit; text-decoration: none; }
.card-title { display: block; font-weight: 600; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.meta-rule { color: var(--text); }
.is-inactive { opacity: 0.6; }

/* ---------- tekrar seçici ---------- */
.rule-picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
.rule-picker legend { padding: 0 6px; font-size: 14px; color: var(--muted); }
.rp-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.rp-interval { display: flex; align-items: center; gap: 8px; color: var(--text); }
.rp-interval input { width: 80px; flex: none; }
.rp-days { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; color: var(--text); }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; cursor: pointer; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-rule-picker].js [hidden] { display: none !important; }

/* ---------- ajanlar ---------- */
.agent-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.agent-desc { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.agent-last { margin: 8px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.agent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.agent-status { width: 52px; display: grid; place-items: center; font-size: 18px; flex: none; }
.strip { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }
.strip-cell { aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); font-size: 13px; line-height: 1; }
.strip-success { background: var(--accent-soft); }
.strip-failed { background: var(--danger-soft); }
.strip-missed { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.strip-empty { background: transparent; border: 1px dashed var(--line); }

.runs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.run + .run { border-top: 1px solid var(--line); }
.run summary { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; cursor: pointer; list-style: none; }
.run summary::-webkit-details-marker { display: none; }
.run-icon { font-size: 18px; flex: none; }
.run-main { display: grid; gap: 2px; min-width: 0; }
.run-when { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.run-summary { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.run-failed .run-summary { color: var(--danger); }
.run-missed .run-summary { color: var(--warn); }
.run-body { padding: 0 14px 14px; }
.run-times { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.log { margin: 0; padding: 10px 12px; max-height: 320px; overflow: auto; background: var(--surface-2); border-radius: 8px; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .agent-cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: start; }
  .detail-grid .form-task { max-width: none; }
}

/* ---------- düzeltmeler ---------- */
.card.form { display: grid; }
.btn { white-space: nowrap; flex: none; }
label small { font-size: 12px; }
.rp-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.chip span { min-width: 0; width: 100%; padding: 0 2px; }
.page-head-row { flex-wrap: wrap; }
.page-head-row > div { flex: 1 1 220px; min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.status-list p { margin: 0 0 8px; }
.status-list form { margin-top: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
