/* MC CRM — mobil öncelikli arayüz */
:root {
  --bg: #0e1116;
  --panel: #171b23;
  --panel-2: #1e242f;
  --border: #2a3140;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --green: #34c98e;
  --red: #ff5d6c;
  --amber: #ffb648;
  --radius: 14px;
  --tabbar-h: 62px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 5px; }
a { color: var(--accent); text-decoration: none; }

/* ---------- Giriş ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2436 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.auth-logo { font-size: 40px; text-align: center; margin-bottom: 6px; }
.auth-card h1 { text-align: center; font-size: 22px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 20px; }
.hint { color: var(--muted); font-weight: normal; }
.alert {
  background: rgba(255,93,108,.12);
  border: 1px solid rgba(255,93,108,.4);
  color: #ffb3ba;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- Butonlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 10px 16px; font-weight: 600; font-size: 14px;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--panel-2); border: 1px solid var(--border); }
.btn-danger { background: rgba(255,93,108,.15); color: var(--red); border: 1px solid rgba(255,93,108,.35); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Kabuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: rgba(14,17,22,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { color: var(--muted); font-size: 13px; }

.view {
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 900px; margin: 0 auto;
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex;
  background: rgba(14,17,22,.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted); padding-top: 6px;
}
.tab.active { color: var(--accent); }
.tab-ic { font-size: 20px; }

/* ---------- Kartlar ---------- */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 10px; font-size: 15px; font-weight: 700;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.card-tap { cursor: pointer; transition: border-color .15s; }
.card-tap:hover { border-color: var(--accent); }
.card-title { font-weight: 600; font-size: 15px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px;
}
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }

/* ---------- Rozetler ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge.lead      { background: rgba(139,148,167,.15); color: var(--muted); }
.badge.contacted { background: rgba(79,140,255,.15);  color: var(--accent); }
.badge.meeting   { background: rgba(255,182,72,.15);  color: var(--amber); }
.badge.collab    { background: rgba(124,92,255,.18);  color: #b3a1ff; }
.badge.won       { background: rgba(52,201,142,.15);  color: var(--green); }
.badge.lost      { background: rgba(255,93,108,.15);  color: var(--red); }
.badge.type-not      { background: rgba(139,148,167,.15); color: var(--muted); }
.badge.type-arama    { background: rgba(79,140,255,.15);  color: var(--accent); }
.badge.type-toplanti { background: rgba(255,182,72,.15);  color: var(--amber); }
.badge.type-script   { background: rgba(124,92,255,.18);  color: #b3a1ff; }
.badge.overdue { background: rgba(255,93,108,.18); color: var(--red); }
.badge.soon    { background: rgba(255,182,72,.15); color: var(--amber); }

/* ---------- Görev panosu ---------- */
.board { display: grid; gap: 12px; }
@media (min-width: 800px) { .board { grid-template-columns: repeat(4, 1fr); align-items: start; } }
.board-col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.board-col.drag-over { border-color: var(--accent); background: var(--panel-2); }
.board-col h3 {
  font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; margin: 4px 4px 10px;
  display: flex; justify-content: space-between;
}
.task-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
}
.task-card .t { font-weight: 600; font-size: 14px; }
.task-card .m { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.task-move { display: flex; gap: 6px; margin-top: 8px; }
.task-move button {
  font-size: 11px; padding: 3px 8px; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
@media (min-width: 800px) { .task-move { display: none; } }

/* ---------- Zaman çizelgesi ---------- */
.note {
  border-left: 2px solid var(--border);
  padding: 0 0 16px 14px;
  margin-left: 6px;
  position: relative;
}
.note::before {
  content: ''; position: absolute; left: -5px; top: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
.note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.note-meta { color: var(--muted); font-size: 12px; }
.note-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.note-body.script {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 13px;
  max-height: 240px; overflow-y: auto;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%; max-width: 520px;
  max-height: 88dvh; overflow-y: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slide-up .2s ease;
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }
@keyframes slide-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }

/* ---------- Araçlar ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
}
.chip.active { background: rgba(79,140,255,.15); border-color: var(--accent); color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
.fab-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }

/* ---------- Masaüstü düzeni: alt sekme çubuğu sol kenar çubuğuna dönüşür ---------- */
@media (min-width: 900px) {
  .tabbar {
    top: 0; bottom: auto; left: 0; right: auto;
    width: 230px; height: 100dvh;
    flex-direction: column; justify-content: flex-start;
    gap: 4px;
    border-top: none; border-right: 1px solid var(--border);
    padding: 22px 12px 12px;
  }
  .tabbar::before {
    content: '📇 MC CRM';
    display: block;
    font-weight: 700; font-size: 17px; color: var(--text);
    padding: 0 14px 20px;
  }
  .tab {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 12px; width: 100%;
    font-size: 14px; font-weight: 600;
    padding: 12px 14px; border-radius: 10px;
  }
  .tab:hover { background: var(--panel-2); }
  .tab.active { background: rgba(79,140,255,.12); }
  .tab-ic { font-size: 18px; }

  .topbar { margin-left: 230px; padding-left: 36px; }
  .topbar-title { display: none; }
  .view {
    margin-left: 230px;
    max-width: 1160px;
    padding: 28px 36px 48px;
  }
  .dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
  #cust-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  #cust-list .card { margin-bottom: 0; }
  .searchbar input { max-width: 420px; }
  .detail-cols { display: grid; grid-template-columns: 5fr 4fr; gap: 0 24px; align-items: start; }
}

/* WhatsApp butonu */
.btn-wa {
  background: rgba(37,211,102,.14);
  color: #4ce08a;
  border: 1px solid rgba(37,211,102,.35);
}
.badge.type-whatsapp { background: rgba(37,211,102,.15); color: #4ce08a; }
.wa-quick { font-size: 18px; padding: 8px; border-radius: 10px; background: rgba(37,211,102,.12); line-height: 1; }

.keybox {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; word-break: break-all; user-select: all; margin: 6px 0 10px;
}

/* ---------- Panel: dağılım barı + ilerleme ---------- */
.dist-bar {
  display: flex; height: 18px; border-radius: 9px; overflow: hidden;
  background: var(--panel-2); margin-bottom: 12px;
}
.dist-seg { min-width: 3px; transition: width .4s; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; }
.dist-item { display: inline-flex; align-items: center; gap: 6px; }
.dist-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.progress {
  height: 10px; border-radius: 6px; background: var(--panel-2);
  overflow: hidden; margin: 10px 0 8px;
}
.progress-fill {
  height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .6s ease;
}
.pulse {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); margin-left: 6px;
  animation: pulse-anim 1.6s ease-in-out infinite;
}
@keyframes pulse-anim {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,201,142,.5); }
  50% { opacity: .6; box-shadow: 0 0 0 6px rgba(52,201,142,0); }
}

/* ---------- WhatsApp sohbet balonları ---------- */
.wa-meta { color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.wa-chat {
  display: flex; flex-direction: column; gap: 6px;
  background: #0b141a; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
  max-height: 320px; overflow-y: auto;
}
.wa-msg { max-width: 82%; padding: 7px 11px; border-radius: 10px; font-size: 13px; }
.wa-msg.them { align-self: flex-start; background: #202c33; border-top-left-radius: 3px; }
.wa-msg.me   { align-self: flex-end; background: #005c4b; border-top-right-radius: 3px; }
.wa-text { white-space: pre-wrap; word-break: break-word; }
.wa-time { font-size: 10px; color: rgba(255,255,255,.45); margin-top: 3px; text-align: right; }

/* ---------- Sparky (AI yan panel) ---------- */
#sparky-fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 45;
  width: 54px; height: 54px; border-radius: 50%;
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(79,140,255,.4);
  transition: transform .15s;
}
#sparky-fab:hover { transform: scale(1.08); }
@media (min-width: 900px) { #sparky-fab { bottom: 24px; right: 24px; } }

#sparky-panel {
  position: fixed; inset: 0; z-index: 60;
  background: var(--panel);
  display: flex; flex-direction: column;
}
#sparky-panel[hidden] { display: none !important; }
@media (min-width: 900px) {
  #sparky-panel {
    inset: auto 24px 90px auto;
    width: 400px; height: min(620px, calc(100dvh - 120px));
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0,0,0,.55);
  }
}
.sparky-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
@media (min-width: 900px) { .sparky-head { padding-top: 12px; } }
.sparky-msgs {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.sparky-bubble {
  max-width: 88%; padding: 10px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.sparky-bubble.ai   { background: var(--panel-2); border: 1px solid var(--border); align-self: flex-start; }
.sparky-bubble.user { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; align-self: flex-end; }
.sparky-bubble.ctx  { align-self: center; color: var(--muted); font-size: 11px; background: none; padding: 0; }
.sparky-bubble.action {
  align-self: stretch; max-width: 100%;
  background: rgba(52,201,142,.1);
  border: 1px solid rgba(52,201,142,.35);
  color: #7de8b8; font-size: 13px;
}
.sparky-conv {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.sparky-conv:hover { border-color: var(--accent); }
.sparky-conv-t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sparky-input {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.sparky-input textarea { resize: none; max-height: 180px; overflow-y: auto; }
.sparky-input .btn { padding: 10px 14px; align-self: flex-end; }

#sparky-resize { display: none; }
@media (min-width: 900px) {
  #sparky-resize {
    display: block;
    position: absolute; left: 0; top: 0;
    width: 22px; height: 22px;
    cursor: nwse-resize; z-index: 2;
    border-left: 3px solid var(--border);
    border-top: 3px solid var(--border);
    border-top-left-radius: 18px;
  }
  #sparky-resize:hover { border-color: var(--accent); }
  #sparky-panel { position: fixed; }
}

#toast-root { position: fixed; top: 70px; left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: slide-up .2s ease;
}
.toast.err { border-color: rgba(255,93,108,.5); color: #ffb3ba; }
