@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner,
.disconnect-spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.disconnect-spinner {
  border-top-color: var(--text-muted);
}

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #25d366;
  --primary-hover: #20bd5a;
  --danger: #f85149;
  --danger-hover: #da3633;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header: başlık ile menü aynı satırda, üst üste binmez */
.header {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.logo-icon {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.header-user-email {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #111;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #21262d;
}

.btn-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.15);
}

/* Account list */
.account-list {
  display: grid;
  gap: 1rem;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.account-card:hover {
  border-color: #484f58;
}

.account-card.ready {
  border-left: 4px solid var(--primary);
}

.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.account-info {
  flex: 1;
  min-width: 0;
}

.account-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.account-meta {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.account-error {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--danger);
  max-width: 100%;
  word-break: break-word;
}

.account-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-ready {
  color: var(--primary);
  background: rgba(37, 211, 102, 0.15);
}

.status-qr, .status-connecting {
  color: #d29922;
  background: rgba(210, 153, 34, 0.15);
}

.status-disconnected, .status-error, .status-auth_failure {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.15);
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-actions .btn-qr {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: rgba(37, 211, 102, 0.2);
  color: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.account-actions .btn-qr:hover {
  background: rgba(37, 211, 102, 0.3);
}

.account-actions .btn-retry {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: rgba(210, 153, 34, 0.2);
  color: #d29922;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.account-actions .btn-retry:hover {
  background: rgba(210, 153, 34, 0.3);
}

.account-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-name-row .account-name {
  margin: 0;
  cursor: pointer;
}

.account-card.ready .account-name-row .account-name:hover,
.account-card.ready .account-avatar:hover {
  text-decoration: underline;
}

.btn-edit-name {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.9rem;
  opacity: 0.8;
}

.btn-edit-name:hover {
  color: var(--text);
}

.account-actions .btn-open-chat {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: var(--primary);
  color: #111;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.account-actions .btn-open-chat:hover {
  background: var(--primary-hover);
}

.account-actions .btn-analyze-account {
  padding: 0.4rem 0.65rem;
  font-size: 1.1rem;
  min-width: 2.25rem;
  background: rgba(37, 211, 102, 0.25);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  cursor: pointer;
}

.account-actions .btn-analyze-account:hover {
  background: rgba(37, 211, 102, 0.35);
}

.account-card.disconnect-loading {
  opacity: 0.85;
  pointer-events: none;
}

.account-card.disconnect-loading .account-disconnect {
  cursor: wait;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state.hidden {
  display: none !important;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.empty-state h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.empty-state p {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}

/* Header link (Ayarlar) */
.header-link {
  color: var(--text-muted);
  text-decoration: none;
  margin-right: 0.75rem;
  font-size: 0.9rem;
}
.header-link:hover {
  color: var(--primary);
}

/* Ayarlar görünümü */
.settings-view {
  padding: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
}
.settings-view.hidden {
  display: none !important;
}
.settings-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.settings-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.settings-desc {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.settings-form .settings-label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-weight: 500;
  font-size: 0.9rem;
}
.settings-form .settings-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
}
.settings-form #settingsSaveBtn {
  margin-top: 1.25rem;
}
.settings-message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
.settings-message.success { color: var(--success, #0a0); }
.settings-message.error { color: var(--danger, #c00); }

.settings-hr {
  margin: 1.5rem 0 1rem;
  border: none;
  border-top: 1px solid var(--border);
}
.settings-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.settings-checkbox {
  width: 1.1rem;
  height: 1.1rem;
}

/* Analiz Dashboard */
.dashboard-view {
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}
.dashboard-view.hidden {
  display: none !important;
}
.dashboard-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.dashboard-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.dashboard-desc {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.dashboard-card {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: border-color 0.15s;
}
.dashboard-card:hover {
  border-color: var(--primary);
}
.dashboard-card-main {
  flex: 1;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: inherit;
}
.dashboard-card-main:hover {
  background: var(--surface);
}
.dashboard-card-delete {
  flex-shrink: 0;
  align-self: center;
  margin-right: 1rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.dashboard-card-delete:hover {
  color: var(--danger, #c53030);
  border-color: var(--danger, #c53030);
  background: rgba(197, 48, 48, 0.08);
}
.dashboard-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.dashboard-card-account {
  font-weight: 600;
  color: var(--text);
}
.dashboard-card-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.dashboard-card-phone {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.dashboard-card-preview {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.dashboard-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.dashboard-empty.hidden {
  display: none !important;
}

/* Arama raporu görünümü */
.call-report-view {
  padding: 0 1.5rem 2rem;
}
.call-report-inner {
  max-width: 800px;
  margin: 0 auto;
}
.call-report-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}
.call-report-form .settings-label { margin-bottom: 0.25rem; }
.call-report-form .input-field { min-width: 180px; }
.call-report-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.call-report-stat {
  font-size: 1rem;
  color: var(--text-muted);
}
.call-report-stat span {
  font-weight: 700;
  color: var(--primary);
  margin-right: 0.35rem;
}
.call-report-filter {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.call-report-filter .input-field {
  max-width: 280px;
}
.call-report-filter-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.call-report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.call-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.call-report-table th,
.call-report-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.call-report-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
}
.call-report-table tbody tr:last-child td { border-bottom: none; }
.call-report-table tbody tr:hover { background: rgba(37, 211, 102, 0.06); }
.call-report-result.hidden,
.call-report-error.hidden { display: none !important; }
.call-report-result .report-error { margin-top: 1rem; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-content-wide {
  max-width: 640px;
}

/* Rapor yükleme: Lottie tarzı hareketli animasyon */
.report-loading {
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.report-loading-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.report-loading-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  animation: report-loading-bounce 1.4s ease-in-out infinite both;
}

.report-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.report-loading-dot:nth-child(2) { animation-delay: -0.16s; }
.report-loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes report-loading-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.report-loading-text {
  margin: 0;
  font-size: 0.95rem;
}

.report-content {
  max-height: 70vh;
  overflow-y: auto;
  padding: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.65;
}

.report-section {
  margin-bottom: 1.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.report-section:last-child { margin-bottom: 0; }

.report-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.report-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
  line-height: 1.7;
  margin: 0;
  color: var(--text);
  max-width: 65ch;
}

.report-content .report-text {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#dashboardReportContent .report-text {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.7;
  max-width: 65ch;
}

/* Haftalık analiz raporu – yapılandırılmış görünüm */
.report-formatted {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text);
  max-width: 65ch;
}
.report-formatted .report-section {
  margin-bottom: 2rem;
}
.report-formatted .report-section:last-child {
  margin-bottom: 0;
}
.report-formatted .report-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.report-formatted .report-section-body {
  padding-left: 0;
}
.report-formatted .report-contact {
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.report-formatted .report-contact-name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.6rem;
  color: var(--text);
}
.report-formatted .report-contact-body {
  margin: 0;
}
.report-formatted .report-block-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
  color: var(--text);
}
.report-formatted .report-block-title:first-child {
  margin-top: 0;
}
.report-formatted .report-p {
  margin: 0 0 0.5rem;
  color: var(--text);
}
.report-formatted .report-p:last-child {
  margin-bottom: 0;
}
.report-formatted .report-note {
  margin: 1rem 0 0;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}
.report-formatted br {
  display: block;
  content: "";
  margin-top: 0.25rem;
}

.report-error {
  color: var(--danger);
  padding: 1rem 1.25rem;
  background: rgba(248, 81, 73, 0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(248, 81, 73, 0.25);
  font-size: 0.95rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.qr-hint {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.qr-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
}

.qr-placeholder {
  color: #666;
  font-size: 0.9rem;
}

.qr-connecting {
  color: #25d366;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  padding: 1rem;
}

.qr-connecting.hidden {
  display: none !important;
}

.qr-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.qr-image.hidden {
  display: none !important;
}

.success-step {
  text-align: center;
  padding: 1rem 0;
}

.success-step.hidden {
  display: none !important;
}

.success-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  background: var(--primary);
  color: #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

/* Input & form */
.input-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.input-field {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.5rem;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
}

.input-hint {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Sohbet görünümü: header gizle, tam ekran */
body.view-chat .header {
  display: none;
}

body.view-chat .app {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body.view-chat .chat-view {
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  border: none;
  border-radius: 0;
  flex: 1;
}

/* Chat view */
.chat-view {
  display: flex;
  height: calc(100vh - 140px);
  min-height: 400px;
  margin: 0 -1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-sidebar {
  width: 280px;
  min-width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
}

.btn-back:hover {
  color: var(--primary);
}

.chat-sidebar-title {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-search-wrap {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.chat-list-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.chat-list-search::placeholder {
  color: var(--text-muted);
}

.chat-list-search:focus {
  outline: none;
  border-color: var(--primary);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.chat-list-loading,
.chat-list-error,
.chat-list-empty {
  padding: 1rem;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.chat-list-error {
  color: var(--danger);
}

.chat-list-back-btn,
.chat-list-retry-btn {
  margin-top: 0.75rem;
}
.chat-list-retry-btn {
  margin-right: 0.5rem;
}

.chat-list-item-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.chat-list-item {
  flex: 1;
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.chat-list-item-analyze {
  flex-shrink: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  background: rgba(37, 211, 102, 0.2);
  color: var(--primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-right: 0.5rem;
}

.chat-list-item-analyze:hover {
  background: rgba(37, 211, 102, 0.3);
}

.chat-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.chat-list-item-name {
  display: block;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.chat-list-item-preview {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
}

.chat-main-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 2rem;
}

.chat-main-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-main-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-search-in-wrap {
  margin-bottom: 0.5rem;
}

.chat-search-in {
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.chat-search-in::placeholder {
  color: var(--text-muted);
}

.chat-search-in:focus {
  outline: none;
  border-color: var(--primary);
}

.message-search-highlight {
  background: rgba(37, 211, 102, 0.4);
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}

.chat-profile-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chat-profile-avatar-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.chat-profile-pic {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-profile-pic.hidden {
  display: none !important;
}

.chat-profile-pic-letter {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
}

.chat-profile-pic-letter.hidden {
  display: none !important;
}

.chat-profile-info {
  flex: 1;
  min-width: 0;
}

.chat-profile-name-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}

.chat-profile-name-btn:hover {
  text-decoration: underline;
}

.btn-analyze-chat {
  flex-shrink: 0;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}

.current-chat-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.chat-profile-about {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.chat-profile-about.hidden {
  display: none !important;
}

.chat-profile-number {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--primary);
}

.chat-profile-number.hidden {
  display: none !important;
}

/* WhatsApp tarzı sohbet alanı */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  background-color: #E5DDD5;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 8c-2 0-4 2-4 4s2 4 4 4 4-2 4-4-2-4-4-4zm0 36c2 0 4-2 4-4s-2-4-4-4-4 2-4 4 2 4 4 4zm-8-8c0 2 2 4 4 4s4-2 4-4-2-4-4-4-4 2-4 4zm24 0c0 2 2 4 4 4s4-2 4-4-2-4-4-4-4 2-4 4z' fill='%23d4c5b5' fill-opacity='0.35'/%3E%3C/svg%3E");
}

.messages-loading,
.messages-error,
.messages-empty {
  margin: auto;
  color: #54656f;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.messages-error {
  color: #c62828;
}

.messages-loading-more {
  text-align: center;
  padding: 0.6rem;
  color: #54656f;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.loading-spinner.small {
  width: 0.9em;
  height: 0.9em;
  margin-right: 0;
}

.load-more-top {
  text-align: center;
  padding: 0.6rem 0.5rem;
  flex-shrink: 0;
}

.btn-load-more-old {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.95);
  color: #25a869;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.btn-load-more-old:hover {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* WhatsApp: mesaj satırı — gelen solda (avatar + balon), giden sağda */
.message {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  max-width: 85%;
  margin-bottom: 0.125rem;
  gap: 0.35rem;
}

.message:last-child {
  margin-bottom: 0.25rem;
}

.message-out {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Gelen mesaj avatar (grup için harf) */
.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #DFDFDF;
  color: #4a4a4a;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-out .message-avatar {
  display: none;
}

/* Grup: gönderen adı balonun üstünde, kalın */
.message-sender-name {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0b6dbf;
  margin-bottom: 0.2rem;
  padding: 0;
  border: none;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-out .message-sender-name {
  display: none;
}

.message-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
}

.message-out .message-bubble-wrap {
  align-items: flex-end;
}

/* WhatsApp balon: kuyruk için köşe kesik */
.message-bubble {
  padding: 0.5rem 0.75rem 0.35rem 0.85rem;
  border-radius: 18px;
  max-width: 100%;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.08);
}

.message-in .message-bubble {
  background: #FFFFFF;
  color: #111;
  border-radius: 18px 18px 18px 4px;
}

.message-out .message-bubble {
  background: #D9FDD3;
  color: #111;
  border-radius: 18px 18px 4px 18px;
}

.message-body {
  margin: 0 0 0.2rem;
  font-size: 0.9375rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-body:last-child {
  margin-bottom: 0;
}

/* Saat + onay işaretleri aynı satırda, sağ alt */
.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  margin-top: 0.15rem;
}

.message-time {
  font-size: 0.6875rem;
  color: #667781;
}

.message-out .message-time {
  color: rgba(0, 0, 0, 0.45);
}

.message-checks {
  font-size: 0.9rem;
  color: #53bdeb;
  line-height: 1;
}

.message-in .message-checks {
  display: none;
}

.message-out .message-checks {
  display: inline-flex;
}

/* Tarih ayırıcı — WhatsApp tarzı */
.message-date-sep {
  text-align: center;
  margin: 0.5rem 0;
  flex-shrink: 0;
}

.message-date-sep span {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: #54656f;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.message-media {
  margin-bottom: 0.4rem;
}

.message-media-img-wrap {
  cursor: pointer;
  display: inline-block;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.message-media-img-wrap:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.message-media-img-wrap:active {
  transform: scale(0.99);
}

.message-media-img {
  max-width: 100%;
  max-height: 320px;
  min-height: 80px;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.message-media-img-wrap:hover .message-media-img {
  opacity: 0.95;
}

.message-media-video {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  display: block;
}

.message-media-audio {
  max-width: 100%;
  min-width: 200px;
}

.message-media-download {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--primary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.message-media-download:hover {
  text-decoration: underline;
}

.message-contact {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.message-contact-name {
  font-weight: 600;
  font-size: 1rem;
}

.message-contact-number {
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
}

.message-contact-number:hover {
  text-decoration: underline;
}

.message-media-link {
  color: inherit;
}

.message-media-fallback {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.load-more-wrap {
  text-align: center;
  padding: 0.75rem;
  flex-shrink: 0;
}

.load-more-btn {
  font-size: 0.9rem;
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-input-wrap {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-input-wrap textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: none;
  font-family: inherit;
}

.chat-input-wrap textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-send {
  padding: 0 1.25rem;
  background: var(--primary);
  color: #111;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--primary-hover);
}

.hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.btn-attach {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.btn-attach:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(37, 211, 102, 0.08);
}

/* Mesaj tepkileri (reactions) */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.25rem;
  align-items: center;
}
.message-reaction {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 8px;
}
.message-out .message-reaction {
  background: rgba(0, 0, 0, 0.12);
}
.message-reaction-count {
  font-size: 0.7rem;
  opacity: 0.9;
}

/* Çıkartma boyutu */
.message-media-is-sticker .message-media-img-wrap,
.message-media-sticker {
  max-width: 140px;
  max-height: 140px;
}
.message-media-is-sticker .message-media-img {
  max-width: 140px;
  max-height: 140px;
  object-fit: contain;
}

/* Resim büyütme (lightbox) */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.lightbox.hidden {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10002;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-img {
  position: relative;
  z-index: 10001;
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Mobil uyumluluk */
.mobile-back-to-list {
  display: none;
}

@media (max-width: 768px) {
  body {
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .app {
    padding: 1rem 0.75rem;
    max-width: 100%;
  }

  .header {
    margin-bottom: 1.5rem;
    padding-top: 0.25rem;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .header-brand {
    text-align: center;
  }

  .logo {
    justify-content: center;
  }

  .header h1 {
    font-size: 1.35rem;
  }

  .subtitle {
    font-size: 0.875rem;
  }

  .header-user {
    justify-content: center;
  }

  .toolbar {
    margin-bottom: 1rem;
  }

  .btn {
    min-height: 44px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  .btn-sm {
    min-height: 44px;
    padding: 0.5rem 0.9rem;
  }

  .account-card {
    padding: 1rem;
  }

  .account-card .btn {
    min-height: 44px;
  }

  /* Chat view: tam ekran, mobilde tek panel */
  .chat-view {
    height: calc(100vh - 80px);
    min-height: 320px;
    margin: 0 -0.75rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .chat-sidebar {
    width: 100%;
    min-width: 0;
  }

  .chat-sidebar-header {
    min-height: 48px;
    padding: 0.75rem 1rem;
  }

  .btn-back {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    font-size: 1.1rem;
  }

  .chat-list-item {
    min-height: 52px;
    padding: 0.85rem 1rem;
  }

  /* Mobilde sohbet seçilince sadece sohbet alanı */
  .chat-view .chat-main {
    display: none;
  }

  .chat-view.mobile-chat-open .chat-sidebar {
    display: none;
  }

  .chat-view.mobile-chat-open .chat-main {
    display: flex;
    flex: 1;
    width: 100%;
    min-width: 0;
  }

  .mobile-back-to-list {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
  }

  .chat-main-header .chat-profile-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .btn-analyze-chat {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .chat-messages {
    padding: 0.75rem;
  }

  .message {
    max-width: 92%;
  }

  .chat-input-wrap {
    padding: 0.6rem 0.75rem;
  }

  .chat-input-wrap textarea {
    min-height: 48px;
    font-size: 16px; /* iOS zoom önleme */
  }

  .btn-send {
    min-width: 52px;
    min-height: 48px;
  }

  /* Modal mobil */
  .modal {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .modal-content,
  .modal-content-wide {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .modal-body {
    padding: 1.25rem;
  }

  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }

  .lightbox-close {
    min-width: 44px;
    min-height: 44px;
    top: env(safe-area-inset-top, 1rem);
    right: env(safe-area-inset-right, 1rem);
  }
}

@media (max-width: 480px) {
  .app {
    padding: 0.75rem 0.5rem;
  }

  .chat-view {
    margin: 0 -0.5rem;
  }

  .logo-icon {
    font-size: 1.4rem;
  }

  .header h1 {
    font-size: 1.2rem;
  }
}

/* Toast (sağ alt) */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
  pointer-events: none;
}
.toast-container > * {
  pointer-events: auto;
}
.toast {
  padding: 0.75rem 1rem;
  background: var(--bg-elevated, #1f2937);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toast-in 0.25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-message { flex: 1; min-width: 0; }
.toast-action {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 500;
}
.toast-action:hover {
  filter: brightness(1.1);
}
.toast-close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast-close:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}
