/* ==========================================================================
   crm.css — app.js gövdesindeki sayfalar (sahibi: app.js gövdesi)
   Müşteri Yönetimi (liste, aşama panosu, Fırsatlar, müşteri kartı), Projeler / Alanlar / Görevler,
   Takvim, Tablolar, Kullanıcılar, Ekip Paneli, Duyurular, E-posta.
   Yalnızca styles.css belirteçleri (renk, yarıçap, gölge) kullanılır; açık tema. Sınıf öneki: crm-
   index.html bağlamadıysa app.js açılışta bir kez ekler.
   ========================================================================== */

/* ---------- Ortak ---------- */
.crm-ic { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; line-height: 0; }
.crm-ic svg { width: 18px; height: 18px; }
.btn-sm .crm-ic svg, .mini-btn .crm-ic svg { width: 15px; height: 15px; }
.crm-hint { margin: 0 0 12px; }
.crm-pad { padding: 16px 20px; margin: 0; }
.crm-tab-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.crm-row-title { font-weight: 600; color: var(--heading); }
.crm-table-card { margin-bottom: 20px; }
.crm-table-card .card-head h3 .tab-count { margin-left: 2px; }
.crm-table-card .table-wrap { border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.crm-actions-cell { width: 1%; white-space: nowrap; }
.crm-actions-cell .row-actions { flex-wrap: nowrap; justify-content: flex-end; }
.crm-row-passive td { color: var(--muted); background: var(--surface-2); }
.crm-subfield-label { margin: 8px 0 4px; }
.crm-pre { white-space: pre-wrap; color: var(--ink); font-size: 13px; }
.crm-list-card { padding: 4px 0; }
.crm-panel-foot { text-align: right; margin-top: 10px; }
.crm-row-static { cursor: default; }
.crm-row-static:hover { border-color: var(--line); }
.btn.crm-btn-danger-line { color: var(--danger); border-color: #F3B4B4; }
.btn.crm-btn-danger-line:hover { background: var(--tone-red-soft); border-color: var(--danger); color: var(--danger); }

/* Bölümlü düğme (Liste | Pano) */
.crm-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); flex: 0 0 auto; }
.crm-seg-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border: 0; background: transparent; color: var(--muted); font: 600 13px/1.2 var(--font); cursor: pointer; }
.crm-seg-btn + .crm-seg-btn { border-left: 1px solid var(--line-strong); }
.crm-seg-btn:hover { background: var(--surface-2); color: var(--ink); }
.crm-seg-btn.active { background: var(--tone-green-soft); color: var(--primary-d); }
.crm-seg-btn .crm-ic svg { width: 16px; height: 16px; }

/* ---------- Pano (kanban) ortak: proje ve müşteri aşama sütunları ---------- */
.crm-kanban { margin-top: 0; }
.crm-kcol { border-top: 3px solid var(--tone); }
.crm-kcol.drop-over { background: var(--tone-soft); border-color: var(--tone); }
.crm-kdot { width: 9px; height: 9px; border-radius: 50%; background: var(--tone); flex: 0 0 auto; }
.crm-kempty { padding: 18px 10px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); }
.crm-kcol .kanban-col-value { margin: -6px 0 2px; }
.kanban-card[draggable="true"], .customer-card[draggable="true"] { cursor: grab; }
.kanban-card[draggable="true"]:active, .customer-card[draggable="true"]:active { cursor: grabbing; }

/* Proje kartı */
.crm-pcard { display: flex; flex-direction: column; gap: 8px; }
.crm-pcard-title { font-weight: 700; font-size: 15px; color: var(--heading); }
.crm-pcard-desc { font-size: 13px; color: var(--muted); }
.crm-pcard-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.crm-pcard-meta .crm-ic { color: var(--muted); }
.crm-pcard-foot { display: flex; align-items: center; gap: 10px; }
.crm-pcard-foot .progress { flex: 1; height: 8px; }
.crm-pcard-count { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Alanlar ---------- */
.crm-area-grid .area-card-body:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.crm-notes { max-width: 860px; }

/* Alan takvimi satırları */
.crm-event-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); }
.crm-event-row:first-child { border-top: 0; }
.crm-event-row.gecmis { opacity: 0.6; }
.crm-event-date { display: flex; flex-direction: column; align-items: center; min-width: 92px; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--tone-teal-soft); color: var(--tone-teal-ink); font-size: 12px; }
.crm-event-date strong { font-size: 13px; color: var(--tone-teal-ink); }
.crm-event-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

/* ---------- Müşteri Yönetimi ---------- */
.crm-kpi4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.crm-kpi5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-card.clickable { cursor: pointer; }
.crm-toolbar select.input { min-width: 170px; }
.crm-firm { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.crm-firm-sub { font-size: 12px; color: var(--muted); }
.crm-contact { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.crm-contact a { color: var(--ink); }
.crm-contact a.muted { color: var(--muted); }
.crm-cust-table td { vertical-align: middle; }
.crm-row-due td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.crm-stage-board { gap: 12px; }
.crm-stage-board .kanban-col { min-width: 168px; padding: 12px; }
.crm-stage-board .customer-card { padding: 12px; }
.crm-stage-board .kanban-col-title { font-size: 13px; }
.crm-ccard { flex-shrink: 0; }
.crm-ccard .customer-card-footer { flex-wrap: wrap; gap: 4px 8px; }
.crm-ccard .customer-card-value { white-space: nowrap; margin-left: auto; }
.crm-ccard .customer-card-company { min-height: 16px; }
.crm-ccard-follow { margin: -4px 0 8px; font-size: 12px; }
.crm-forecast { margin-bottom: 20px; }
.crm-forecast > .panel { margin-bottom: 0; }

/* Müşteri kartı (pencere) */
/* İçerideki geniş tablolar (yatay kaydırmalı) pencereyi ekrandan taşırmasın: genişlik dışarıdan belirlenir */
.crm-cust-modal { display: flex; flex-direction: column; gap: 0; min-width: 0; contain: inline-size; }
.modal:has(.crm-cust-modal) { min-width: 0; }
.crm-cust-head { display: flex; align-items: flex-start; gap: 14px; padding: 2px 0 14px; flex-wrap: wrap; }
.crm-cust-avatar { width: 52px; height: 52px; border-radius: var(--radius-lg); background: var(--tone-blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: 0 0 auto; }
.crm-cust-title { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.crm-cust-name { font-size: 20px; font-weight: 700; color: var(--heading); line-height: 1.25; overflow-wrap: anywhere; }
.crm-cust-sub { font-size: 13px; color: var(--muted); }
.crm-cust-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.crm-cust-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crm-cust-modal .tabbar { margin-bottom: 14px; }
.crm-cust-modal .cm-pane > .panel:last-child, .crm-cust-modal .cm-pane > .card:last-child { margin-bottom: 0; }
.crm-cust-modal .cm-pane > .card { margin-bottom: 16px; }
.crm-info-val { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.crm-notes-box { margin-top: 12px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.crm-notes-box .field-label { margin-bottom: 4px; }
.crm-doc-btns .btn { flex: 1 1 160px; }
.crm-delete { margin-top: 4px; }
.crm-meeting .project-row-side { text-align: right; }
.crm-meeting.gecmis { opacity: 0.55; }
.crm-meeting-when { font-weight: 700; color: var(--primary-d); white-space: nowrap; }
.crm-log-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.crm-date-input { width: auto; }
.activity-tab-btn { display: inline-flex; align-items: center; gap: 6px; }
.activity-tab-btn .crm-ic svg { width: 14px; height: 14px; }
.crm-tl-type { margin-left: 6px; font-weight: 500; }
.crm-tl-title { margin-top: 24px; }
.crm-cost-card .card-head { flex-wrap: wrap; }
.crm-cost-card .card-head .btn-row { gap: 12px; }
.crm-quick-dates { margin-bottom: 10px; }
.crm-cust-form .field-row > .field { flex: 1 1 0; }
.crm-profile-hint { margin: -8px 0 14px; }

/* ---------- Kullanıcılar ---------- */
.crm-user-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crm-user-table td { white-space: nowrap; }
.crm-icon-mini { padding: 4px 8px; }
.crm-icon-mini svg { width: 16px; height: 16px; }

/* ---------- Takvim ---------- */
.crm-cal .cal-header { margin-bottom: 10px; }
.crm-cal .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.crm-cal .cal-day { min-width: 0; }
.crm-cal .cal-nav-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 14px; font-weight: 600; }
.crm-cal .cal-nav-btn svg { width: 18px; height: 18px; }
.crm-cal-nav { display: flex; gap: 6px; }
.crm-cal-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.crm-cal .cal-day:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cal-badge.crm-cal-wo { background: var(--tone-orange-soft); color: var(--tone-orange-ink); }
.cal-badge.crm-cal-wo.task-late { background: var(--tone-red-soft); color: var(--danger); }
.crm-day .sub-title:first-child { margin-top: 0; }
.crm-participants { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; }

/* Dokunmatik ekranda HTML5 sürükle-bırak çalışmaz: ipucu gizlenir (durum / aşama kartın formundan değişir) */
@media (pointer: coarse) { .crm-dnd-hint { display: none; } }

/* ---------- Duyarlı ---------- */
@media (max-width: 1180px) {
  .crm-kpi5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-stage-board .kanban-col { min-width: 220px; }
}
@media (max-width: 900px) {
  .crm-kpi4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-toolbar .toolbar-spacer { display: none; }
}
@media (max-width: 640px) {
  .crm-kpi4, .crm-kpi5 { grid-template-columns: 1fr 1fr; }
  .crm-hide-sm, .crm-hide-sm-sales { display: none; }
  .crm-cust-table th, .crm-cust-table td { padding: 10px 8px; }
  .crm-cust-table .crm-firm { min-width: 140px; }
  .crm-toolbar > .search-box { flex: 1 1 100%; max-width: none; }
  .crm-toolbar select.input { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .crm-seg { width: 100%; }
  .crm-seg-btn { flex: 1; justify-content: center; min-height: 44px; }
  .crm-stage-board .kanban-col, .crm-kanban .kanban-col { min-width: 82vw; }
  .crm-event-row { flex-wrap: wrap; padding: 12px; }
  .crm-event-date { flex-direction: row; gap: 6px; min-width: 0; }
  .crm-cust-head { gap: 10px; }
  .crm-cust-avatar { width: 44px; height: 44px; font-size: 16px; }
  .crm-cust-name { font-size: 18px; }
  .crm-cust-actions { width: 100%; }
  .crm-cust-actions > * { flex: 1 1 auto; min-height: 44px; }
  .crm-info-val { justify-content: flex-start; text-align: left; }
  .crm-cust-modal .info-row { flex-wrap: wrap; }
  .crm-log-foot { justify-content: stretch; }
  .crm-log-foot .crm-date-input { flex: 1; }
  .crm-log-foot .btn { width: 100%; }
  .crm-actions-cell .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  /* Kullanıcılar: telefonda tablo satırı karta dönüşür (ad · profil · PIN · işlemler) */
  .crm-user-table thead { display: none; }
  .crm-user-table, .crm-user-table tbody { display: block; }
  .crm-user-table tr { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .crm-user-table tr:last-child { border-bottom: 0; }
  .crm-user-table td { display: block; padding: 0; border: 0; white-space: normal; }
  .crm-user-table td.crm-hide-sm { display: none; }
  .crm-user-table td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .crm-user-table td:nth-child(2) { grid-column: 2; grid-row: 1; }
  .crm-user-table td:nth-child(4) { grid-column: 2; grid-row: 2; }
  .crm-user-table td:nth-child(5) { grid-column: 3; grid-row: 1; }
  .crm-user-table td.crm-actions-cell { grid-column: 1 / -1; grid-row: 3; width: auto; padding-top: 4px; }
  .crm-user-table .row-actions .mini-btn { flex: 1 1 auto; }
  .crm-team .presence-row { flex-wrap: wrap; row-gap: 2px; }
  .crm-team .presence-att { order: 5; flex: 1 1 100%; padding-left: 18px; white-space: normal; }
  .mytaskrow { flex-direction: column; align-items: stretch; gap: 10px; }
  .mytaskside { justify-content: space-between; flex-wrap: wrap; }
  /* Takvim: dar hücrede başlık yerine renkli nokta */
  .crm-cal { padding: 10px; }
  .crm-cal .cal-header { flex-wrap: wrap; }
  .crm-cal .cal-title { order: -1; flex: 1 1 100%; text-align: center; font-size: 16px; }
  .crm-cal .cal-grid { gap: 3px; }
  .crm-cal .cal-day { min-height: 54px; padding: 4px; flex-direction: row; flex-wrap: wrap; align-content: flex-start; gap: 3px; }
  .crm-cal .cal-date-num { flex: 1 1 100%; margin-bottom: 2px; font-size: 13px; }
  .crm-cal .cal-badge { width: 8px; height: 8px; padding: 0; margin: 0; border-radius: 50%; font-size: 0; background: var(--blue); }
  .crm-cal .cal-badge.task { background: var(--tone-gray); }
  .crm-cal .cal-badge.crm-cal-wo { background: var(--orange); }
  .crm-cal .cal-badge.task-late { background: var(--danger); }
  .crm-cal .cal-day-label { font-size: 11px; }
}
