/* =================================================================
   Quick AI Chat — Mobile PWA
   Desktop tasariminin mobil uyarlamasi (ayni koyu tema, yesil accent,
   Inter font, glassmorphism, orb arka plan)
   ================================================================= */

/* ---------- RESET ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html { -webkit-text-size-adjust: 100%; }
body, button, input, textarea { font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
button { background: none; border: none; cursor: pointer; color: inherit; }
input, textarea { color: inherit; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

/* ---------- TOKENS (desktop ile uyumlu — LIGHT TEMA) ---------- */
:root {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: rgba(255, 255, 255, 0.9);
  --bg-elevated: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(37, 211, 102, 0.5);

  --accent: #25d366;
  --accent-hover: #20bd5a;
  --accent-dark: #128c7e;
  --accent-glow: rgba(37, 211, 102, 0.18);
  --accent-soft: rgba(37, 211, 102, 0.08);

  --text-primary: #1a202c;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --success: #25d366;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  --orb-1-color: rgba(37, 211, 102, 0.20);
  --orb-2-color: rgba(59, 130, 246, 0.15);
  --orb-3-color: rgba(245, 158, 11, 0.12);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.10);
  --shadow-glow: 0 0 30px rgba(37, 211, 102, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --nav-h: 64px;
  --topbar-h: 96px;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  position: relative;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; min-height: 100dvh; position: relative; z-index: 1; }

/* ================================================================
   BACKGROUND ORBS (desktop ile birebir, floating animasyon)
   ================================================================ */
.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: orbFloat 20s infinite ease-in-out;
}
.bg-orb-1 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, var(--orb-1-color), transparent 70%);
  top: -80px; right: -80px;
}
.bg-orb-2 {
  width: 260px; height: 260px;
  background: radial-gradient(circle, var(--orb-2-color), transparent 70%);
  bottom: -40px; left: -40px;
  animation-delay: -7s;
}
.bg-orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--orb-3-color), transparent 70%);
  top: 40%; left: 60%;
  animation-delay: -14s;
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(20px, -20px) scale(1.05); }
  50% { transform: translate(-14px, 14px) scale(0.95); }
  75% { transform: translate(10px, 10px) scale(1.02); }
}

/* ================================================================
   SPLASH
   ================================================================ */
.splash {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashFade 0.4s ease-out 1.3s forwards;
}
@keyframes splashFade {
  to { opacity: 0; pointer-events: none; }
}
.splash.hidden { display: none !important; }

.splash-content {
  text-align: center;
  animation: splashRise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes splashRise {
  from { opacity: 0; transform: translateY(10px); }
}
.splash-logo {
  width: 84px; height: 84px;
  background: linear-gradient(135deg, var(--accent), #128c7e);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 0 40px var(--accent-glow), 0 12px 30px rgba(0,0,0,0.4);
}
.splash-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.splash-tag {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
.splash-spinner {
  margin: 28px auto 0;
  width: 28px; height: 28px;
  border: 2.5px solid rgba(0,0,0,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   LOGIN — desktop login.html class isimleri ile birebir
   ================================================================ */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}
.login-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}
.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 36px 28px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

.login-header {
  text-align: center;
  margin-bottom: 26px;
}
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.login-header p {
  font-size: 13.5px;
  color: var(--text-secondary);
}

#loginForm { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.form-group input {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input::placeholder {
  color: var(--text-muted);
  font-size: 14.5px;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
  padding: 11px 13px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #dc2626;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 2px;
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
  margin-top: 8px;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: none;
}
.btn-login:hover { box-shadow: 0 6px 20px var(--accent-glow); }
.btn-login:active { transform: scale(0.985); }
.btn-login:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-login svg { stroke: currentColor; flex-shrink: 0; }

.login-footer {
  text-align: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}
.link-secondary {
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  display: inline-block;
  padding: 8px 12px;
  transition: color 0.15s;
}
.link-secondary:hover { color: var(--accent); }

/* dummy spacer */
.login-foot {
  display: none;
  margin-top: 24px;
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ================================================================
   MAIN APP SHELL
   ================================================================ */
#main-app {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  padding-top: var(--safe-top);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
  transition: border-color 0.3s;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 4px;
}
.topbar h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.topbar-search {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.topbar-search:active { background: var(--bg-card); }
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.meta-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* ---------- SEARCH BAR ---------- */
.search-bar {
  margin: 8px 16px 4px;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ================================================================
   CHATS LIST
   ================================================================ */
/* Sohbet filtre pill'leri — Tumu / Okunmamis */
.chat-filters {
  display: flex;
  gap: 8px;
  padding: 10px 14px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chat-filters::-webkit-scrollbar { display: none; }
.chat-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s;
}
.chat-filter:active { transform: scale(0.97); }
.chat-filter.active {
  background: rgba(37, 211, 102, 0.16);
  color: var(--accent-dark);
  font-weight: 600;
}
.chat-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}
.chat-filter.active .chat-filter-count { background: var(--accent-dark); }

.chats-list { padding: 4px 0 0; }

/* ---------- TEMPLATES (mobile) ---------- */
.mtpl-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid var(--border-color);
}
.mtpl-picker label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.mtpl-picker select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  outline: none;
}
.mtpl-list {
  padding: 8px 12px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mtpl-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: transform 0.12s, box-shadow 0.12s;
}
.mtpl-card:active { transform: scale(0.985); }
.mtpl-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.mtpl-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.012em;
  word-break: break-word;
  line-height: 1.3;
}
.mtpl-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.mtpl-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  background: rgba(0,0,0,0.05);
  color: var(--text-secondary);
}
.mtpl-chip.status-APPROVED { background: rgba(37,211,102,0.16); color: var(--accent-dark); }
.mtpl-chip.status-PENDING { background: rgba(245,158,11,0.16); color: #b45309; }
.mtpl-chip.status-REJECTED, .mtpl-chip.status-PAUSED { background: rgba(239,68,68,0.14); color: #b91c1c; }
.mtpl-chip.cat { background: rgba(99,102,241,0.12); color: #4f46e5; }
.mtpl-chip.lang { background: rgba(59,130,246,0.12); color: #2563eb; }
.mtpl-card-body {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.025);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 5em;
  overflow: hidden;
  position: relative;
}
.mtpl-card-body.expanded { max-height: none; }
.mtpl-card-footer-text {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}
.mtpl-card-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.mtpl-card-button-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  background: rgba(37,211,102,0.10);
  color: var(--accent-dark);
  border: 1px solid rgba(37,211,102,0.22);
}
.mtpl-card-reject {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(239,68,68,0.08);
  border-left: 3px solid rgba(239,68,68,0.5);
  border-radius: 4px;
  font-size: 12px;
  color: #b91c1c;
}
.chat-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 12px 18px;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.chat-item::after {
  content: '';
  position: absolute;
  left: 78px; right: 18px; bottom: 0;
  height: 1px;
  background: var(--border-color);
}
.chat-item:last-child::after { display: none; }
.chat-item:active { background: var(--bg-card); }
.chat-item.unread .chat-name { color: var(--text-primary); font-weight: 600; }
.chat-item.unread .chat-preview { color: var(--text-secondary); }

.chat-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.chat-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.012em;
}
.chat-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  gap: 4px;
}
.chat-preview .preview-self {
  color: var(--text-secondary);
  flex-shrink: 0;
}
.chat-preview .preview-media {
  color: var(--text-secondary);
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.chat-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.chat-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ================================================================
   CONNECTIONS
   ================================================================ */
.conn-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 14px;
}
.summary-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.summary-num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.summary-card.success .summary-num { color: var(--success); }
.summary-card.error .summary-num { color: var(--error); }
.summary-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.conn-list {
  padding: 6px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conn-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.conn-card:active { transform: scale(0.99); background: var(--bg-card-hover); }

.conn-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}
.conn-icon.type-web { background: rgba(37, 211, 102, 0.12); color: var(--accent); }
.conn-icon.type-cloud { background: rgba(59, 130, 246, 0.12); color: var(--info); }
.conn-icon.type-business { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

.conn-info { min-width: 0; }
.conn-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.conn-phone {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.conn-pill {
  padding: 4px 9px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.conn-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.conn-pill.status-connected {
  color: var(--success);
  background: rgba(37, 211, 102, 0.12);
}
.conn-pill.status-connected::before { animation: pulse 2s infinite; }
.conn-pill.status-disconnected {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}
.conn-pill.status-connecting, .conn-pill.status-qr_pending {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

/* ================================================================
   PROFILE
   ================================================================ */
.profile-card {
  margin: 16px 14px 14px;
  padding: 22px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  gap: 14px;
  align-items: center;
}
.profile-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 0 24px rgba(37,211,102,0.15);
  flex-shrink: 0;
}
.profile-info { min-width: 0; }
.profile-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.012em;
  margin-bottom: 3px;
}
.profile-email {
  font-size: 13px;
  color: var(--text-muted);
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 14px 18px;
}
.ps-item {
  padding: 11px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.ps-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.ps-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.menu {
  margin: 0 14px;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.menu-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 14px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-primary);
}
.menu-item + .menu-item { border-top: 1px solid var(--border-color); }
.menu-item:active { background: var(--bg-card-hover); }

.menu-ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.menu-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-body strong {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.menu-body em {
  font-style: normal;
  font-size: 12px;
  color: var(--text-muted);
}
.menu-arrow {
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
}
.menu-item.logout .menu-ico { color: var(--error); background: rgba(239,68,68,0.1); }
.menu-item.logout .menu-body strong { color: var(--error); }

.profile-foot {
  text-align: center;
  margin: 28px 14px 0;
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ================================================================
   BOTTOM NAV
   ================================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  z-index: 80;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  letter-spacing: 0.005em;
  min-height: 44px;
}
.nav-item svg { transition: transform 0.2s; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { transform: scale(1.08); }
.nav-item:active svg { transform: scale(0.92); }

/* ================================================================
   CHAT DETAIL
   ================================================================ */
.chat-detail {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.chat-detail.visible { transform: translateX(0); }

.cd-head {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: calc(10px + var(--safe-top)) 8px 10px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}
/* Şablon butonu gizli iken grid'i 4 sutuna dusur ki dar ekranlarda da bosluk olmasin */
.cd-head:has(.cd-template.hidden) { grid-template-columns: auto auto 1fr auto; }
.cd-back, .cd-more, .cd-template {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}
.cd-back:active, .cd-more:active, .cd-template:active { background: var(--bg-card); }
.cd-template { color: var(--accent-dark); }
.cd-template:active { background: rgba(37, 211, 102, 0.14); }

.cd-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.cd-user { min-width: 0; }
.cd-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.cd-phone {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ---------- MESSAGES ---------- */
.cd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(37,211,102,0.04), transparent),
    var(--bg-primary);
}
.msg-day {
  text-align: center;
  margin: 10px 0 6px;
}
.msg-day span {
  display: inline-block;
  padding: 4px 11px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.msg-row {
  display: flex;
  margin: 1px 0;
  animation: msgIn 0.2s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
}
.msg-row.in { justify-content: flex-start; }
.msg-row.out { justify-content: flex-end; }

.msg-bubble {
  max-width: 80%;
  padding: 8px 12px 6px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  word-wrap: break-word;
  letter-spacing: -0.005em;
}
.msg-row.in .msg-bubble {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
}
.msg-row.out .msg-bubble {
  background: linear-gradient(135deg, var(--accent), #128c7e);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37,211,102,0.15);
}

.msg-time {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  text-align: right;
  opacity: 0.7;
  font-weight: 500;
}
.msg-row.out .msg-time { color: rgba(255,255,255,0.85); }
.msg-row.in .msg-time { color: var(--text-muted); }

.msg-row.same-sender + .msg-row.same-sender { margin-top: -2px; }

/* ---------- MEDYA BALONCUKLARI ---------- */
.msg-bubble .msg-audio {
  display: block;
  width: 240px;
  max-width: 100%;
  height: 38px;
  outline: none;
}
.msg-row.out .msg-bubble .msg-audio { filter: invert(1) hue-rotate(180deg) brightness(1.1); }

.msg-bubble .msg-image-link {
  display: block;
  margin: -10px -12px 4px -12px;
  overflow: hidden;
  border-radius: 14px 14px 4px 4px;
}
.msg-row.out .msg-bubble .msg-image-link { border-radius: 14px 14px 4px 4px; }
.msg-bubble .msg-image {
  display: block;
  max-width: 260px;
  max-height: 320px;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.msg-bubble .msg-video {
  display: block;
  max-width: 260px;
  max-height: 320px;
  width: 100%;
  border-radius: 8px;
  outline: none;
}

.msg-bubble .msg-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 200px;
}
.msg-row.out .msg-bubble .msg-doc { background: rgba(255,255,255,0.15); }
.msg-bubble .msg-doc-icon { font-size: 22px; }
.msg-bubble .msg-doc-name {
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
}

.msg-bubble .msg-text {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-media-missing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.msg-row.out .msg-media-missing {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
}

/* Bitrix24 dosya karti — disk URL'leri OAuth gerektirdiginden onizleme yerine kart */
.msg-bubble .msg-bitrix-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.2);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 220px;
  max-width: 100%;
  transition: background 0.15s;
}
.msg-bubble .msg-bitrix-card:active {
  background: rgba(0, 122, 255, 0.14);
}
.msg-row.out .msg-bubble .msg-bitrix-card {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
}
.msg-bitrix-ico {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}
.msg-bitrix-info {
  flex: 1;
  min-width: 0;
}
.msg-bitrix-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #0066cc;
  line-height: 1.3;
}
.msg-row.out .msg-bitrix-title { color: #ffffff; }
.msg-bitrix-name {
  font-size: 11.5px;
  margin-top: 2px;
  color: var(--text-muted);
  word-break: break-word;
}
.msg-row.out .msg-bitrix-name { color: rgba(255,255,255,0.85); }
.msg-bitrix-arrow {
  flex-shrink: 0;
  color: #0066cc;
  opacity: 0.7;
}
.msg-row.out .msg-bitrix-arrow { color: rgba(255,255,255,0.9); }

/* ---------- COMPOSER ---------- */
.cd-composer {
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  color: var(--text-primary);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  transition: border-color 0.15s;
}
#chat-input::placeholder { color: var(--text-muted); }
#chat-input:focus { border-color: var(--border-focus); }

/* ATTACH (paperclip) */
.cd-attach {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, transform 0.12s;
}
.cd-attach:hover, .cd-attach:active {
  color: var(--accent);
  background: var(--accent-soft);
}
.cd-attach:active { transform: scale(0.92); }
.cd-attach svg { transition: transform 0.2s; }
.cd-attach.open svg { transform: rotate(45deg); color: var(--accent); }

/* MIC */
.cd-mic {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.2s;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.cd-mic:active { transform: scale(0.92); }
.cd-mic.recording {
  background: linear-gradient(135deg, var(--error), #b91c1c);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.cd-send {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.2s;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.cd-send:not(:disabled):active { transform: scale(0.92); }
.cd-send:disabled {
  background: var(--bg-card);
  color: var(--text-muted);
  box-shadow: none;
}

/* ================================================================
   SKELETON LOADERS
   ================================================================ */
.skel-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px 18px;
  align-items: center;
}
.skel-row.conn { grid-template-columns: auto 1fr auto; padding: 12px 14px; margin: 0 14px; }
.skel-circle, .skel-square {
  background: linear-gradient(90deg, var(--border-color) 0%, rgba(255,255,255,0.08) 50%, var(--border-color) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skel-circle { width: 48px; height: 48px; border-radius: 50%; }
.skel-square { width: 42px; height: 42px; border-radius: 10px; }
.skel-stack { display: flex; flex-direction: column; gap: 7px; }
.skel-stack span {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border-color) 0%, rgba(255,255,255,0.08) 50%, var(--border-color) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skel-stack span:first-child { width: 50%; }
.skel-stack span:last-child { width: 85%; height: 9px; }
.skel-pill {
  width: 60px; height: 22px;
  border-radius: 11px;
  background: linear-gradient(90deg, var(--border-color) 0%, rgba(255,255,255,0.08) 50%, var(--border-color) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty {
  text-align: center;
  padding: 60px 28px;
}
.empty-icon {
  font-size: 56px;
  margin-bottom: 14px;
  opacity: 0.6;
}
.empty h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.empty p {
  margin: 0 auto;
  max-width: 240px;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ================================================================
   INSTALL PROMPT
   ================================================================ */
.install-prompt {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px);
  left: 12px; right: 12px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  animation: installSlide 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes installSlide {
  from { opacity: 0; transform: translateY(16px); }
}
.install-icon {
  width: 36px; height: 36px;
  background: var(--accent-soft);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.install-text { flex: 1; min-width: 0; }
.install-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.install-text span {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}
.install-cta {
  background: var(--accent);
  color: #fff;
  padding: 7px 13px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.install-cta:active { transform: scale(0.95); }
.install-x {
  color: var(--text-muted);
  font-size: 22px;
  width: 26px; height: 26px;
  border-radius: 50%;
}

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 1000;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================================================================
   STANDALONE (PWA installed)
   ================================================================ */
@media (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
}

/* ================================================================
   RECORDING OVERLAY (ses kaydı sırasında composer üzerinde belirir)
   ================================================================ */
.rec-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 6;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: recIn 0.25s ease-out;
}
@keyframes recIn {
  from { opacity: 0; transform: translateY(10px); }
}
.rec-cancel, .rec-stop {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s, background 0.15s;
}
.rec-cancel {
  background: rgba(239, 68, 68, 0.10);
  color: var(--error);
}
.rec-cancel:active { transform: scale(0.92); background: rgba(239, 68, 68, 0.18); }
.rec-stop {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.rec-stop:active { transform: scale(0.92); }
.rec-pulse {
  width: 10px; height: 10px;
  background: var(--error);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  animation: recDot 1.2s ease-in-out infinite;
}
@keyframes recDot {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    opacity: 0.7;
  }
}
.rec-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rec-time {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--error);
  letter-spacing: -0.01em;
}
.rec-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.005em;
}

/* ================================================================
   ATTACH MENU (paperclip'e basinca acilan kart)
   ================================================================ */
.attach-menu {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(70px + var(--safe-bottom));
  z-index: 6;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  animation: attachIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes attachIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}
.attach-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s, transform 0.12s;
}
.attach-item:active {
  background: var(--bg-input);
  transform: scale(0.97);
}
.attach-ico {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ================================================================
   UC NOKTA MENUSU (kisi bilgileri vb.)
   ================================================================ */
.cd-menu {
  position: absolute;
  top: calc(var(--safe-top) + 56px);
  right: 12px;
  z-index: 8;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 6px;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  animation: menuIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
}
.cd-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.12s;
}
.cd-menu-item:active { background: var(--bg-input); }
.cd-menu-item svg { color: var(--text-secondary); flex-shrink: 0; }

/* ================================================================
   KISI PROFIL PANELI (WhatsApp benzeri)
   ================================================================ */
.contact-profile {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.contact-profile.hidden { display: none; }
.contact-profile.visible { transform: translateX(0); }

.cp-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(var(--safe-top) + 10px) 16px 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.cp-back {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  transition: background 0.12s;
}
.cp-back:active { background: var(--bg-input); }
.cp-head-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.cp-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(20px + var(--safe-bottom));
}

.cp-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px 24px;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid var(--border-color);
}
.cp-photo {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  font-size: 48px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), inset 0 0 0 1px rgba(255,255,255,0.4);
}
.cp-photo img { width: 100%; height: 100%; object-fit: cover; }
.cp-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.015em;
  margin-top: 4px;
}
.cp-phone {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}
.cp-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.cp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cp-badge.verified { background: rgba(37,211,102,0.14); color: #128c7e; }
.cp-badge.business { background: rgba(99,102,241,0.12); color: #4f46e5; }
.cp-badge.not-wa { background: rgba(239,68,68,0.12); color: #dc2626; }

.cp-section {
  background: rgba(255, 255, 255, 0.65);
  margin-top: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}
.cp-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.cp-section-value {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
}
.cp-section-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.cp-section a { color: var(--accent-dark); text-decoration: underline; }

.cp-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid var(--border-color);
}
.cp-row-ico {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.cp-row-content { min-width: 0; flex: 1; }
.cp-row-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.cp-row-value {
  font-size: 14.5px;
  color: var(--text-primary);
  margin-top: 2px;
  word-break: break-word;
}

/* ---------- MEDYA GALERISI ---------- */
.media-gallery .mg-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.media-gallery .mg-tab {
  padding: 7px 14px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.media-gallery .mg-tab.active {
  background: var(--accent);
  color: #fff;
}
.media-gallery .mg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
}
.media-gallery .mg-cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-input);
  overflow: hidden;
  cursor: pointer;
}
.media-gallery .mg-cell img,
.media-gallery .mg-cell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-gallery .mg-cell .mg-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.18);
  color: #fff;
  pointer-events: none;
}
.media-gallery .mg-cell .mg-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 28px;
  color: var(--text-muted);
}
.media-gallery .mg-list {
  display: flex;
  flex-direction: column;
}
.media-gallery .mg-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
}
.media-gallery .mg-item:active { background: var(--bg-input); }
.media-gallery .mg-item-ico {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.media-gallery .mg-item-info { flex: 1; min-width: 0; }
.media-gallery .mg-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-gallery .mg-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.media-gallery .mg-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.media-gallery .mg-empty-ico { font-size: 38px; margin-bottom: 10px; }

/* Lightbox viewer (resim tam ekran) */
.mg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightboxIn 0.18s ease;
}
.mg-lightbox.hidden { display: none; }
@keyframes lightboxIn { from { opacity: 0; } }
.mg-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.mg-lightbox-close {
  position: absolute;
  top: calc(var(--safe-top) + 14px);
  right: 14px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

/* Bitrix24 CRM linki — Lead/Deal/Contact/Company */
.cp-crm-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 14px 4px;
  padding: 14px 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-color);
  border-left: 4px solid;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.12s, box-shadow 0.12s;
}
.cp-crm-card:active { transform: scale(0.985); }
.cp-crm-ico {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.cp-crm-info { flex: 1; min-width: 0; }
.cp-crm-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.cp-crm-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-crm-arrow { color: var(--text-secondary); flex-shrink: 0; }

.cp-loading, .cp-error {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 14px;
}
.cp-error { color: #dc2626; }
.cp-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: cpSpin 0.8s linear infinite;
}
@keyframes cpSpin { to { transform: rotate(360deg); } }

/* ================================================================
   SABLON GONDER BOTTOM SHEET
   ================================================================ */
.tpl-send-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.tpl-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  animation: tplSheetFade 0.2s ease;
}
@keyframes tplSheetFade { from { opacity: 0; } }
.tpl-sheet-panel {
  position: relative;
  width: 100%;
  max-height: 88vh;
  background: #fff;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.18);
  animation: tplSheetUp 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes tplSheetUp { from { transform: translateY(100%); } }
.tpl-sheet-handle {
  width: 38px; height: 4px;
  background: rgba(0,0,0,0.16);
  border-radius: 2px;
  margin: 8px auto 0;
}
.tpl-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 6px;
}
.tpl-sheet-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.012em;
}
.tpl-sheet-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
}
.tpl-sheet-close:active { background: var(--bg-input); }
.tpl-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px calc(20px + var(--safe-bottom));
}
.tpl-sheet-item {
  padding: 14px 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.tpl-sheet-item:active { background: var(--bg-input); }
.tpl-sheet-item-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}
.tpl-sheet-item-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.tpl-sheet-item-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 3.5em;
  overflow: hidden;
}
.tpl-sheet-loading, .tpl-sheet-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-secondary);
  font-size: 14px;
}
.tpl-sheet-param-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 4px 14px;
}
.tpl-sheet-param-form label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}
.tpl-sheet-param-form input {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.tpl-sheet-param-form input:focus { border-color: var(--accent); }
.tpl-sheet-send-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.tpl-sheet-send-btn {
  flex: 1;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
}
.tpl-sheet-send-btn:disabled { opacity: 0.55; }
.tpl-sheet-cancel-btn {
  flex: 0 0 90px;
  padding: 11px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 14.5px;
}

/* ================================================================
   STANDALONE (PWA installed)
   ================================================================ */
@media (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
}

/* ================================================================
   REDUCED MOTION
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===================================================================
   CRM (Bitrix24 Lead / Deal / Contact / Company)
   =================================================================== */
#view-crm { display: flex; flex-direction: column; min-height: 0; height: 100%; overflow: hidden; }

.crm-portalbar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 0.82rem; color: var(--text-secondary); background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.crm-portalbar label { font-weight: 600; }
.crm-portalbar select { flex: 1; padding: 6px 8px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-input); color: var(--text-primary); font-size: 0.85rem; }
.crm-portal-name { font-weight: 600; color: var(--accent-dark); }

.crm-tabs { display: flex; gap: 4px; padding: 8px 10px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.crm-tab { flex: 1; padding: 9px 4px; border: none; background: transparent; color: var(--text-secondary); font-size: 0.86rem; font-weight: 600; border-radius: 9px; cursor: pointer; transition: background .15s, color .15s; }
.crm-tab.active { background: var(--accent-soft); color: var(--accent-dark); }

.crm-searchbar { display: flex; align-items: center; gap: 8px; margin: 10px 12px 6px; padding: 9px 12px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 12px; color: var(--text-muted); flex-shrink: 0; }
.crm-searchbar input { flex: 1; border: none; background: transparent; outline: none; font-size: 0.92rem; color: var(--text-primary); }

.crm-list { flex: 1; overflow-y: auto; padding: 4px 12px 96px; -webkit-overflow-scrolling: touch; }
.crm-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px; margin-bottom: 8px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 14px; cursor: pointer; box-shadow: var(--shadow-sm); }
.crm-card:active { background: var(--bg-card-hover); }
.crm-card-av { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }
.crm-card-main { flex: 1; min-width: 0; }
.crm-card-title { font-weight: 600; color: var(--text-primary); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-card-sub { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.crm-card-meta { flex-shrink: 0; font-weight: 700; font-size: 0.82rem; color: var(--accent-dark); }

.crm-loading { text-align: center; padding: 18px; color: var(--text-muted); font-size: 0.86rem; }
.crm-empty { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.crm-empty-ic { font-size: 2.4rem; margin-bottom: 10px; }
.crm-empty h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--text-primary); }
.crm-empty p { margin: 0; font-size: 0.88rem; }

.crm-detail { position: fixed; inset: 0; z-index: 300; background: var(--bg-primary); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.7,.3,1); }
.crm-detail.visible { transform: none; }
.crm-detail.hidden { display: none; }
.crm-detail-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.crm-drow { display: flex; justify-content: space-between; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--border-color); }
.crm-drow span { color: var(--text-secondary); font-size: 0.86rem; }
.crm-drow b { color: var(--text-primary); font-size: 0.9rem; font-weight: 600; text-align: right; word-break: break-word; }
.crm-detail-actions { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-color); background: var(--bg-secondary); }
.crm-wa-btn, .crm-call-btn { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; min-width: 0; padding: 14px; border: none; border-radius: 14px; color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer; }
.crm-wa-btn { background: var(--accent); }
.crm-call-btn { background: #4f46e5; }
.crm-wa-btn:disabled, .crm-call-btn:disabled { opacity: .45; cursor: not-allowed; }
.crm-wa-btn:active:not(:disabled) { background: var(--accent-hover); }
.crm-call-btn:active:not(:disabled) { background: #4338ca; }
