/* ============================================================
   Şablonio — Tek CSS dosyası. Ultra modern, koyu tema, glass.
   ============================================================ */

/* ---- Tema değişkenleri ---- */
:root {
  --wa-green: #25D366;
  --wa-green-d: #1da851;
  --wa-teal: #128C7E;

  --bg: #0b141a;
  --bg-2: #0f1c23;
  --surface: rgba(255, 255, 255, .05);
  --surface-2: rgba(255, 255, 255, .07);
  --surface-strong: rgba(23, 34, 42, .72);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #e9edef;
  --text-dim: #8696a0;
  --text-faint: #667781;
  --danger: #ff5a6a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, .5);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --blur: 16px;
  --tap: 44px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: .2s;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Otomatik açık tema (sistem açık + manuel override yok) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2f4;
    --bg-2: #e3e9ec;
    --surface: rgba(255, 255, 255, .65);
    --surface-2: rgba(255, 255, 255, .8);
    --surface-strong: rgba(255, 255, 255, .82);
    --border: rgba(0, 0, 0, .08);
    --border-strong: rgba(0, 0, 0, .14);
    --text: #0f1c23;
    --text-dim: #52616b;
    --text-faint: #7b8a94;
    --shadow-2: 0 8px 30px rgba(0, 0, 0, .12);
    --shadow-3: 0 20px 60px rgba(0, 0, 0, .18);
  }
}

/* Manuel açık tema */
:root[data-theme="light"] {
  --bg: #eef2f4;
  --bg-2: #e3e9ec;
  --surface: rgba(255, 255, 255, .65);
  --surface-2: rgba(255, 255, 255, .8);
  --surface-strong: rgba(255, 255, 255, .82);
  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .14);
  --text: #0f1c23;
  --text-dim: #52616b;
  --text-faint: #7b8a94;
  --shadow-2: 0 8px 30px rgba(0, 0, 0, .12);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, .18);
}

/* ---- Temel ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
:focus-visible { outline: 2px solid var(--wa-green); outline-offset: 2px; }

/* ---- Arkaplan küreleri ---- */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.orb-green {
  width: 60vmax; height: 60vmax; top: -20vmax; right: -18vmax;
  background: radial-gradient(circle, var(--wa-green), transparent 70%);
  opacity: .28;
}
.orb-purple {
  width: 55vmax; height: 55vmax; bottom: -22vmax; left: -18vmax;
  background: radial-gradient(circle, #7b5cff, transparent 70%);
  opacity: .22;
}

/* ---- Glass yardımcıları ---- */
.glass {
  background: var(--surface-strong);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.glass-bar {
  background: var(--surface-strong);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--border);
}

/* ---- Header ---- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-icon { color: var(--wa-green); flex: none; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.header-actions { display: flex; gap: 4px; }

.icon-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: 50%; color: var(--text);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:active { transform: scale(.9); background: var(--surface-2); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); } }

/* ---- Arama ---- */
.search-bar {
  position: sticky; top: 0; z-index: 31;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  color: var(--text-dim);
}
.search-bar input {
  flex: 1; min-width: 0; height: 40px;
  background: none; border: none; color: var(--text); font-size: 16px;
}
.search-bar input::placeholder { color: var(--text-faint); }

/* ---- Kategori çipleri ---- */
.chips-row {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 8px;
  padding: 10px 14px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
  background: linear-gradient(var(--bg), transparent);
}
.app-header + .chips-row { top: calc(var(--safe-top) + 64px); }
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 15px;
  border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), background var(--dur), color var(--dur), border-color var(--dur);
}
.chip:active { transform: scale(.94); }
.chip.active {
  background: color-mix(in srgb, var(--chip-c, var(--wa-green)) 22%, transparent);
  border-color: color-mix(in srgb, var(--chip-c, var(--wa-green)) 55%, transparent);
  color: var(--text);
}
.chip .chip-count { font-size: 12px; color: var(--text-faint); }
.chip-add { color: var(--wa-green); font-weight: 600; }

/* ---- İçerik ---- */
.content {
  padding: 6px 14px calc(120px + var(--safe-bottom));
  max-width: 720px; margin: 0 auto;
}
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 18px 4px 10px; font-size: 13px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase; color: var(--text-faint);
}
.section-title .emoji { font-size: 15px; }

/* ---- Şablon kartı ---- */
.card-grid { display: grid; gap: 10px; }
.tpl-card {
  position: relative; text-align: left;
  width: 100%; padding: 14px 46px 14px 15px;
  border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease), background .8s var(--ease), border-color .8s var(--ease);
  -webkit-user-select: none; user-select: none;
}
.tpl-card:active { transform: scale(.97); }
.tpl-card .t-title {
  display: block; font-weight: 600; font-size: 15.5px; margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tpl-card .t-body {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--text-dim); font-size: 13.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.tpl-card .t-copy {
  position: absolute; top: 12px; right: 12px; color: var(--text-faint);
  pointer-events: none;
}
.tpl-card .t-menu {
  position: absolute; bottom: 6px; right: 6px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text-faint);
}
.tpl-card .t-menu:active { background: var(--surface-2); }
.tpl-card .t-pin { position: absolute; top: 13px; right: 40px; color: var(--wa-green); }

/* Kopyalandı durumu */
.tpl-card.copied {
  background: color-mix(in srgb, var(--wa-green) 26%, var(--surface));
  border-color: color-mix(in srgb, var(--wa-green) 55%, transparent);
}
.tpl-card .copied-badge {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius); font-weight: 700; color: #fff;
  background: color-mix(in srgb, var(--wa-green) 30%, transparent);
}
.tpl-card.copied .copied-badge { display: flex; animation: pop .2s var(--ease); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- FAB ---- */
.fab {
  position: fixed; z-index: 25;
  right: 18px; bottom: calc(18px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 20px;
  display: grid; place-items: center; color: #04150c;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-teal));
  box-shadow: 0 10px 30px rgba(37, 211, 102, .4), var(--shadow-2);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur);
}
.fab:active { transform: scale(.9); }

/* ---- Boş durum ---- */
.empty {
  text-align: center; padding: 60px 20px; color: var(--text-dim);
}
.empty svg { color: var(--text-faint); opacity: .5; margin-bottom: 14px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 17px; }
.empty .btn { margin-top: 18px; }

/* ---- Toast ---- */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + var(--safe-bottom)); z-index: 60;
  width: min(440px, calc(100vw - 28px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--surface-strong); border: 1px solid var(--border-strong);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow-3); color: var(--text);
  animation: toast-in .25s var(--ease);
}
.toast.out { animation: toast-out .2s var(--ease) forwards; }
.toast .toast-msg { flex: 1; font-size: 14px; }
.toast .toast-act {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  color: var(--wa-green); font-weight: 700; font-size: 14px; padding: 6px 8px;
}
.toast.danger { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(20px); opacity: 0; } }

/* ---- Bottom sheet ---- */
.sheet-root { position: fixed; inset: 0; z-index: 50; }
.sheet-layer { position: absolute; inset: 0; }
.sheet-overlay {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .55);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.sheet-layer.open .sheet-overlay { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface-strong);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-3);
  transform: translateY(100%); transition: transform .3s var(--ease);
  padding-bottom: var(--safe-bottom);
}
.sheet-layer.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 10px auto 4px; flex: none; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 10px; flex: none;
}
.sheet-head h2 { font-size: 18px; }
.sheet-body { padding: 4px 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Aksiyon listesi (uzun basma menüsü) */
.action-list { display: flex; flex-direction: column; padding: 4px 10px 14px; }
.action-item {
  display: flex; align-items: center; gap: 14px;
  min-height: var(--tap); padding: 12px 12px; border-radius: 14px;
  font-size: 16px; color: var(--text); text-align: left;
}
.action-item:active { background: var(--surface-2); }
.action-item svg { color: var(--text-dim); flex: none; }
.action-item.danger { color: var(--danger); }
.action-item.danger svg { color: var(--danger); }
.sheet-preview {
  margin: 2px 16px 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13.5px; white-space: pre-wrap;
  max-height: 30dvh; overflow-y: auto; word-break: break-word;
}

/* ---- Formlar ---- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.input, .textarea {
  width: 100%; padding: 12px 14px; font-size: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  transition: border-color var(--dur), background var(--dur);
}
.input:focus, .textarea:focus { outline: none; border-color: var(--wa-green); background: var(--surface-2); }
.textarea { resize: none; line-height: 1.5; min-height: 96px; overflow: hidden; }

.format-bar { display: flex; gap: 8px; margin: 8px 0 4px; }
.fmt-btn {
  width: 40px; height: 36px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-weight: 700;
}
.fmt-btn:active { transform: scale(.92); background: var(--surface-2); }
.fmt-btn .i { font-style: normal; }
.fmt-btn .b { font-weight: 800; }
.fmt-btn .s { text-decoration: line-through; }
.fmt-hint { margin-left: auto; align-self: center; font-size: 12px; color: var(--text-faint); }

/* WhatsApp önizleme balonu */
.wa-preview { margin: 10px 0 4px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border); }
.wa-bubble {
  position: relative; max-width: 85%; margin-left: auto;
  padding: 8px 12px 6px; border-radius: 12px 12px 4px 12px;
  background: #075e54; color: #e9edef; font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow-1);
}
:root[data-theme="light"] .wa-bubble { background: #d9fdd3; color: #111b21; }
.wa-bubble .wa-time { display: block; text-align: right; font-size: 10px; color: rgba(233,237,239,.6); margin-top: 2px; }
:root[data-theme="light"] .wa-bubble .wa-time { color: rgba(17,27,33,.45); }
.wa-bubble strong { font-weight: 700; }
.wa-bubble em { font-style: italic; }
.wa-bubble s { text-decoration: line-through; }
.wa-bubble code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* Kategori seçici çipleri (form içi) */
.cat-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.cat-pick {
  height: 40px; padding: 0 14px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.cat-pick.active { background: color-mix(in srgb, var(--wa-green) 20%, transparent);
  border-color: color-mix(in srgb, var(--wa-green) 55%, transparent); color: var(--text); }

/* Renk noktaları */
.color-dots { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
  transition: transform var(--dur); position: relative;
}
.color-dot.active { border-color: var(--text); transform: scale(1.1); }
.color-dot.active::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700; }

/* ---- Butonlar ---- */
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform var(--dur) var(--ease), filter var(--dur), background var(--dur);
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, var(--wa-green), var(--wa-teal));
  color: #04150c; border: none; box-shadow: 0 8px 24px rgba(37,211,102,.32);
}
.btn-primary:active { filter: brightness(.96); }
.btn-danger { background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-ghost { background: transparent; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

/* ---- Kategori yönetimi ---- */
.cat-manage { display: flex; flex-direction: column; gap: 8px; }
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  touch-action: none;
}
.cat-row.dragging { opacity: .85; box-shadow: var(--shadow-3); background: var(--surface-2); }
.cat-row .drag-handle { color: var(--text-faint); cursor: grab; touch-action: none; flex: none; }
.cat-row .cat-emoji { font-size: 20px; width: 26px; text-align: center; flex: none; }
.cat-row .cat-name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .cat-num { font-size: 12px; color: var(--text-faint); flex: none; }
.cat-row .cat-edit { color: var(--text-dim); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.cat-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* Ayarlar */
.settings-group { margin-bottom: 20px; }
.settings-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); margin-bottom: 10px; }
.seg { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; min-height: 38px; border-radius: 9px; color: var(--text-dim); font-weight: 600; font-size: 14px; }
.seg button.active { background: var(--wa-green); color: #04150c; }
.top-list { display: flex; flex-direction: column; gap: 8px; }
.top-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); text-align: left; }
.top-item .top-rank { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--wa-green); flex: none; }
.top-item .top-title { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-item .top-count { font-size: 12px; color: var(--text-faint); }

/* ---- Login ---- */
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-wrap { width: min(400px, 100%); }
.login-card { padding: 30px 24px; }
.login-logo { width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 20px;
  display: grid; place-items: center; color: #04150c;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-teal)); box-shadow: 0 10px 30px rgba(37,211,102,.35); }
.login-title { text-align: center; font-size: 24px; font-weight: 700; }
.login-sub { text-align: center; color: var(--text-dim); margin: 4px 0 22px; font-size: 14px; }
.login-error { padding: 10px 14px; margin-bottom: 16px; border-radius: 12px; font-size: 14px;
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--text); }
.pw-wrap { position: relative; display: block; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text-dim); }
.remember { display: flex; align-items: center; gap: 10px; margin: 4px 0 20px; font-size: 14px; color: var(--text-dim); cursor: pointer; }
.remember input { width: 18px; height: 18px; accent-color: var(--wa-green); }
.login-foot { text-align: center; color: var(--text-faint); font-size: 12px; margin-top: 18px; }
.shake { animation: shake .4s var(--ease); }
@keyframes shake { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(3px)} 30%,50%,70%{transform:translateX(-6px)} 40%,60%{transform:translateX(6px)} }

/* iOS kurulum adımları */
.ios-steps { counter-reset: s; display: flex; flex-direction: column; gap: 12px; }
.ios-steps li { list-style: none; display: flex; gap: 12px; align-items: center; color: var(--text-dim); }
.ios-steps li::before { counter-increment: s; content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--wa-green); color: #04150c; font-weight: 700; font-size: 13px; }

/* Kurulum banner'ı */
.install-banner {
  position: fixed; left: 14px; right: 14px; z-index: 40;
  bottom: calc(84px + var(--safe-bottom));
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 16px; animation: toast-in .3s var(--ease);
}
.install-banner .ib-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-teal)); color: #04150c; flex: none; }
.install-banner .ib-text { flex: 1; font-size: 13.5px; }
.install-banner .ib-text b { display: block; }
.install-banner .ib-text span { color: var(--text-dim); }

.hidden { display: none !important; }

/* ---- Hareket azaltma ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
