:root {
  --bg: #f3f5f8; --panel: #fff; --line: #e3e7ee; --text: #1d2433; --muted: #6b7486;
  --primary: #1f5eff; --primary-soft: #e8efff; --wa: #1fa855; --wa-soft: #e5f7ec;
  --mine: #dbe6ff; --note: #fff4cc; --danger: #d23b3b; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; padding: 6px; border-radius: 8px; line-height: 1; }
.icon-btn:hover { background: var(--bg); }

input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select { margin-top: 4px; color: var(--text); }

/* giriş */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); padding: 28px; border-radius: 14px; box-shadow: 0 8px 30px rgba(20,30,60,.08); display: grid; gap: 14px; }
.brand { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand .logo { background: var(--primary); color: #fff; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }

/* yerleşim */
.app { height: 100%; display: grid; grid-template-columns: 64px 320px 1fr; }
.rail { background: #15203b; display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 6px; }
.rail .logo { color: #fff; font-size: 22px; margin-bottom: 10px; }
.rail-btn { position: relative; width: 44px; height: 44px; border: 0; border-radius: 12px; background: none; font-size: 20px; cursor: pointer; }
.rail-btn:hover, .rail-btn.active { background: rgba(255,255,255,.12); }
.rail-spacer { flex: 1; }
.badge { position: absolute; top: 2px; right: 0; background: var(--danger); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: none; align-items: center; justify-content: center; }
.badge.show { display: flex; }

.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.side-head h2 { margin: 0; font-size: 18px; }
.side-actions { display: flex; gap: 6px; }
.filters { display: flex; gap: 6px; padding: 0 16px 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip.active { background: var(--wa-soft); border-color: var(--wa); color: #0d6b33; }
.sidebar .search { margin: 0 16px 8px; width: calc(100% - 32px); }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px 16px; cursor: pointer; border-left: 3px solid transparent; }
.conv:hover { background: var(--bg); }
.conv.active { background: var(--primary-soft); border-left-color: var(--primary); }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff; position: relative; }
.avatar.online::after { content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid var(--panel); }
.conv-body { min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: 6px; }
.conv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--muted); flex: none; }
.conv-bottom { display: flex; justify-content: space-between; gap: 6px; }
.conv-last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread { background: var(--primary); color: #fff; border-radius: 9px; font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; flex: none; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); margin-left: 4px; }
.tag.wa { background: var(--wa-soft); color: #0d6b33; }

/* sohbet */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 16px; }
.empty-icon { font-size: 48px; }
.chat-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-head .back { display: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h3 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.chat-tools select { width: auto; padding: 5px 8px; font-size: 13px; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); padding: 2px 10px; border-radius: 999px; margin: 8px 0; }
.msg { max-width: min(70%, 560px); padding: 8px 12px; border-radius: 12px; background: var(--panel); box-shadow: 0 1px 1px rgba(0,0,0,.05); align-self: flex-start; word-wrap: break-word; }
.msg .text { white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--mine); }
.msg.customer { background: var(--wa-soft); }
.msg.note { background: var(--note); border: 1px dashed #e0c25a; }
.msg.system { align-self: center; background: none; box-shadow: none; color: var(--muted); font-size: 12px; padding: 2px; }
.msg .who { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.msg.customer .who { color: #0d6b33; }
.msg .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.msg .meta .failed { color: var(--danger); }
.msg img { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; margin: 4px 0; cursor: zoom-in; }
.msg audio, .msg video { max-width: 100%; display: block; margin: 4px 0; }
.file-link { display: flex; gap: 8px; align-items: center; padding: 8px; background: rgba(0,0,0,.04); border-radius: 8px; color: inherit; text-decoration: none; margin: 4px 0; }
.file-link:hover { background: rgba(0,0,0,.08); }
.load-more { align-self: center; }

.typing { padding: 0 16px; min-height: 18px; }
.wa-warning { margin: 0 16px 8px; padding: 8px 12px; background: #fff4e5; border: 1px solid #f5c27a; border-radius: 8px; font-size: 13px; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.composer-main { flex: 1; min-width: 0; }
.composer textarea { resize: none; max-height: 160px; }
.composer.drag { outline: 2px dashed var(--primary); }
.attach { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 8px; background: var(--bg); border-radius: 6px; margin-bottom: 6px; }
.note-toggle { display: flex; align-items: center; gap: 4px; white-space: nowrap; padding-bottom: 8px; color: #8a6d00; }
.composer.noting textarea { background: var(--note); }

/* kullanıcılar */
.users-panel { padding: 20px; overflow-y: auto; }
.users-panel table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.users-panel th, .users-panel td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.users-panel th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
.users-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.users-head h2 { margin: 0; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); }
.pill.off { background: #fde8e8; color: var(--danger); }
.pill.admin { background: var(--primary-soft); color: var(--primary); }

/* modal & bildirim */
.modal { position: fixed; inset: 0; background: rgba(15,22,40,.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-card { background: var(--panel); border-radius: 14px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; padding: 20px; display: grid; gap: 12px; }
.modal-card h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--text); font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pick-list label:last-child { border-bottom: 0; }
.pick-list label:hover { background: var(--bg); }
.pick-list .avatar { width: 30px; height: 30px; font-size: 12px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #15203b; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: calc(100% - 32px); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 30; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }

/* telefon */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr 56px; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 6px; }
  .rail .logo, .rail-spacer { display: none; }
  .sidebar, .chat { grid-row: 1; grid-column: 1; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .app.in-chat .rail { display: none; }
  .app.in-chat { grid-template-rows: 1fr; }
  .chat-head { flex-wrap: wrap; }
  .chat-tools { width: 100%; justify-content: flex-start; }
  .chat-head .back { display: block; }
  .msg { max-width: 85%; }
  .note-toggle { padding-bottom: 8px; font-size: 12px; }
}
