/* Nixcon WhatsApp gelen kutusu — light/dark, WCAG AA (tüm metin/zemin çiftleri >= 4.5:1).
   Bilgi/uyarı kutuları SOLID zemin (transparan yok). */
:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --card-2: #eef1f5;
  --text: #111827;        /* beyaz üzerinde 17.7:1 */
  --text-dim: #4b5563;    /* beyaz 7.6:1, --bg 6.9:1 */
  --border: #c9d0d9;
  --primary: #0b5cad;     /* beyaz yazı 6.9:1 */
  --primary-hover: #094a8c;
  --secondary-bg: #e3e8ef;
  --secondary-text: #111827;
  --focus: #b45309;
  --bubble-in: #ffffff;
  --bubble-out: #d9f2e1;  /* --text 15:1 */
  --bubble-bot: #dde9fb;  /* --text 14:1 */
  --bubble-sys: #ece7d9;
  --tick-read: #0b5cad;
  --b-bot: #1d4ed8;       /* beyaz 6.7:1 */
  --b-wait: #a3420b;      /* beyaz 6.2:1 */
  --b-human: #046c4e;     /* beyaz 6.6:1 */
  --b-closed: #4b5563;    /* beyaz 7.6:1 */
  --danger: #b91c1c;      /* beyaz 6.5:1 */
  --warn-bg: #7c3a0a;     /* beyaz 8.9:1 */
  --warn-text: #ffffff;
  --danger-bg: #991b1b;   /* beyaz 8.3:1 */
  --info-bg: #0b4a8a;     /* beyaz 8.9:1 */
  --selected: #dbe6f4;
  --shadow: 0 1px 2px rgba(0,0,0,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a; --card: #17202b; --card-2: #1e2935; --text: #e8edf3; --text-dim: #aab5c3;
    --border: #334253; --primary: #2563eb; --primary-hover: #1d4ed8; --secondary-bg: #2a3747; --secondary-text: #e8edf3;
    --focus: #fbbf24; --bubble-in: #1f2b38; --bubble-out: #16452c; --bubble-bot: #1c3557; --bubble-sys: #3a3324;
    --tick-read: #7cc0ff; --selected: #22344a; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131a; --card: #17202b; --card-2: #1e2935; --text: #e8edf3; --text-dim: #aab5c3;
  --border: #334253; --primary: #2563eb; --primary-hover: #1d4ed8; --secondary-bg: #2a3747; --secondary-text: #e8edf3;
  --focus: #fbbf24; --bubble-in: #1f2b38; --bubble-out: #16452c; --bubble-bot: #1c3557; --bubble-sys: #3a3324;
  --tick-read: #7cc0ff; --selected: #22344a; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.boot { padding: 40px; text-align: center; color: var(--text-dim); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary-bg); color: var(--secondary-text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-link { background: none; border: 0; color: var(--text); text-decoration: underline; cursor: pointer; font: inherit; }
.alert { margin: 8px 0; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.alert-danger { background: var(--danger-bg); color: #fff; }

/* giriş */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.login-card h1 { font-size: 20px; margin: 0 0 8px; }
.login-card input { min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; }
.login-card .btn-primary { margin-top: 8px; }
.login-foot { text-align: center; margin-top: 8px; }

/* uygulama */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.mode-banner { background: var(--warn-bg); color: var(--warn-text); padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.me { color: var(--text-dim); font-size: 14px; padding: 0 4px; }
.layout { flex: 1; display: grid; grid-template-columns: 340px 1fr 300px; min-height: 0; }

.list-pane { border-right: 1px solid var(--border); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.list-tools { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.list-tools input, .list-tools select { min-height: 36px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; }
.list-tools input { flex: 1; min-width: 0; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.conv-item:hover { background: var(--card-2); }
.conv-item[aria-current="true"] { background: var(--selected); }
.ci-row { display: flex; align-items: center; gap: 6px; }
.ci-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { color: var(--text-dim); font-size: 12px; }
.ci-prev { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.ci-meta { margin-top: 4px; gap: 6px; flex-wrap: wrap; }
.unread { background: var(--b-human); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; min-width: 20px; text-align: center; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.badge-bot { background: var(--b-bot); }
.badge-waiting_human { background: var(--b-wait); }
.badge-human { background: var(--b-human); }
.badge-closed { background: var(--b-closed); }
.win { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.win-low { background: var(--warn-bg); color: #fff; border-color: transparent; }
.win-closed { background: var(--danger-bg); color: #fff; border-color: transparent; }
.empty { padding: 20px; color: var(--text-dim); }
.center { margin: auto; text-align: center; }

.detail-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.detail { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.detail-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 700; }
.who-sub { color: var(--text-dim); font-size: 13px; }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#d-handoff { margin: 8px 12px 0; }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(560px, 85%); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-in { align-self: flex-start; background: var(--bubble-in); }
.msg-out { align-self: flex-end; background: var(--bubble-out); }
.msg-bot { background: var(--bubble-bot); }
.msg-note { align-self: center; background: var(--bubble-sys); font-size: 13px; max-width: 90%; }
.msg-meta { display: flex; gap: 8px; justify-content: flex-end; font-size: 12px; color: var(--text-dim); margin-top: 4px; white-space: normal; }
.msg-who { font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 2px; }
.tick-read { color: var(--tick-read); font-weight: 700; }
.tick-failed { color: var(--danger); font-weight: 700; }
:root[data-theme="dark"] .tick-failed { color: #fca5a5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tick-failed { color: #fca5a5; } }
.msg img.media { max-width: 100%; max-height: 320px; border-radius: 6px; display: block; }
.msg audio, .msg video { max-width: 100%; display: block; }
.msg a { color: inherit; }
.day-sep { align-self: center; font-size: 12px; color: var(--text-dim); padding: 2px 8px; }

.composer { border-top: 1px solid var(--border); background: var(--card); padding: 8px 12px; }
.send-form { display: flex; gap: 6px; align-items: flex-end; }
.send-form textarea { flex: 1; resize: vertical; min-height: 42px; max-height: 200px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; }
.attach { font-size: 20px; width: 40px; }
.window-closed .btn { margin-top: 4px; }

.customer-pane { border-left: 1px solid var(--border); background: var(--card); padding: 12px; overflow-y: auto; }
.customer-pane h2 { font-size: 16px; margin: 0 0 10px; }
.customer-pane h3 { font-size: 14px; margin: 14px 0 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 14px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; }
.plist { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.plist li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.plist a { color: var(--text); }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--info-bg); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: calc(100% - 32px); }
.toast.err { background: var(--danger-bg); }
.only-mobile { display: none; }
@media (min-width: 1101px) { #btn-customer { display: none; } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 300px 1fr; }
  .customer-pane { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 100%); z-index: 20; box-shadow: -2px 0 8px rgba(0,0,0,.25); transform: translateX(100%); transition: transform .15s; }
  .customer-pane.open { transform: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .app.show-detail .list-pane { display: none; }
  .app:not(.show-detail) .detail-pane { display: none; }
  .only-mobile { display: inline-flex; }
  .topbar .brand span, .me { display: none; }
  .topbar { gap: 6px; padding: 6px 8px; }
  .top-actions .btn { min-height: 32px; padding: 4px 8px; font-size: 13px; }
  .msg { max-width: 92%; }
}
