/* HospitalCRM — Kommo (amoCRM) düzeni: koyu ince sol menü, beyaz üst şerit, gri çalışma alanı. */
:root {
    --sb-bg: #2e3640;
    --sb-hover: #3a4450;
    --sb-text: #aeb6c0;
    --sb-active: #4c8bf5;
    --page-bg: #f0f2f5;
    --line: #e1e4e8;
    --text: #313942;
    --muted: #8a939d;
    --blue: #4c8bf5;
    --topbar-h: 56px;
    --sb-w: 76px;
}

/* PT Sans'ta ₺ işareti yok: sadece bu karakter sistem yazı tipinden gelsin. */
@font-face { font-family: "TRYSign"; src: local("Segoe UI"), local("Arial"), local("Roboto"), local("Helvetica"); unicode-range: U+20BA; }
@font-face { font-family: "TRYSign"; font-weight: 700; src: local("Segoe UI Bold"), local("Arial Bold"), local("Roboto Bold"); unicode-range: U+20BA; }

html, body { height: 100%; }
body {
    font-family: "TRYSign", "PT Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--page-bg);
}
a { color: #2a6bd8; }
.btn-primary { --bs-btn-bg: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: #3a78e0; --bs-btn-hover-border-color: #3a78e0; }
.btn { border-radius: 3px; }
.form-control, .form-select { border-radius: 3px; }
.text-upper { text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Sol menü ---------- */
.sb {
    position: fixed; inset: 0 auto 0 0; width: var(--sb-w);
    background: var(--sb-bg); display: flex; flex-direction: column; z-index: 1030;
}
.sb-logo {
    height: var(--topbar-h); display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 20px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06);
}
.sb-nav { flex: 1; overflow-y: auto; padding: 6px 0; }
.sb-item {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 2px; color: var(--sb-text); text-decoration: none; font-size: 11px; line-height: 1.1; text-align: center;
}
.sb-item i { font-size: 21px; }
.sb-item:hover { background: var(--sb-hover); color: #fff; }
.sb-item.active { background: var(--sb-hover); color: #fff; }
.sb-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sb-active); }
.sb-badge {
    position: absolute; top: 5px; right: 12px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: #f25a5a; color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.sb-bottom { border-top: 1px solid rgba(255,255,255,.06); padding: 6px 0; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: #5b6b7c; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }

/* ---------- Ana alan ---------- */
.main { margin-left: var(--sb-w); min-height: 100%; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 1020;
}
.topbar h1 { font-size: 15px; font-weight: 700; text-transform: uppercase; margin: 0; letter-spacing: .03em; white-space: nowrap; }
.topbar .tools { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar .search { max-width: 380px; flex: 1; }
.page { padding: 16px 20px; flex: 1; }
.page-flush { padding: 0; flex: 1; display: flex; min-height: 0; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.panel-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 14px; }
.panel > .table, .panel .table-responsive > .table { margin-bottom: 0; }
.table { --bs-table-bg: transparent; }
.table > thead th { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-bottom-width: 1px; background: #fafbfc; }
.table td, .table th { padding: 8px 10px; vertical-align: middle; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #f5f8fd; }
.muted { color: var(--muted); }
.flash { position: fixed; top: 64px; right: 20px; z-index: 1080; min-width: 280px; max-width: 480px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }

/* Segment düğmeleri (Tümü / Santral / Pazarlama) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; background: #fff; }
.seg a { padding: 5px 12px; color: var(--text); text-decoration: none; font-size: 13px; border-right: 1px solid var(--line); white-space: nowrap; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: #e8f0fe; color: #1f5fbf; font-weight: 700; }

/* ---------- Pipeline ---------- */
.board { display: flex; overflow-x: auto; height: calc(100vh - var(--topbar-h)); background: var(--page-bg); }
.col-stage { flex: 0 0 272px; display: flex; flex-direction: column; border-right: 1px solid #e3e6ea; min-height: 0; }
.col-head { padding: 10px 12px 8px; text-align: center; background: var(--page-bg); }
.col-head .name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #4a5561; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-head .bar { height: 3px; border-radius: 2px; margin: 6px 0 5px; }
.col-head .sum { font-size: 12px; color: var(--muted); }
.col-body { flex: 1; overflow-y: auto; padding: 4px 8px 80px; }
.lcard {
    background: #fff; border: 1px solid #e3e6ea; border-radius: 3px; padding: 8px 10px; margin-bottom: 6px;
    cursor: grab; font-size: 13px; position: relative;
}
.lcard:hover { border-color: #c9d3df; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.lcard.unseen { border-left: 3px solid #f25a5a; }
.lcard .top { display: flex; gap: 6px; }
.lcard .title { font-weight: 700; color: var(--text); text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lcard .title:hover { color: #1f5fbf; }
.lcard .date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.lcard .sub { color: #5d6873; font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lcard .foot { display: flex; align-items: center; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.lcard .amount { font-weight: 700; font-size: 12px; margin-left: auto; }
.tag { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 2px; background: #eef1f4; color: #4a5561; white-space: nowrap; }
.tag-red { background: #fde2e2; color: #c0392b; }
.tag-yellow { background: #fff3c4; color: #8a6d00; }
.tag-blue { background: #e1ecff; color: #1f5fbf; }
.tag-green { background: #dcf5e7; color: #1e7a45; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.col-empty { text-align: center; color: #b3bac2; font-size: 12px; padding: 12px 0; }
.col-more { text-align: center; font-size: 12px; padding: 4px; }

/* Sürüklerken altta çıkan bırakma alanları */
.dropzones {
    position: fixed; left: var(--sb-w); right: 0; bottom: 0; height: 84px; display: none; z-index: 1040;
    background: rgba(46,54,64,.92);
}
.dropzones.show { display: flex; }
.dz { flex: 1; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border: 2px dashed transparent; margin: 10px; border-radius: 4px; position: relative; overflow: hidden; }
.dz > .dz-list { position: absolute; inset: 0; }
.dz > .dz-list > * { display: none; }
.dz-won { border-color: #7ed79b; color: #b7f0c8; }
.dz-lost { border-color: #f08c8c; color: #f7c3c3; }
.dz:hover { background: rgba(255,255,255,.10); border-style: solid; }
.sortable-fallback { transform: rotate(2deg); opacity: .95 !important; }

/* ---------- Kayıt detayı (iki bölmeli) ---------- */
.lead-view { display: flex; height: calc(100vh - var(--topbar-h)); width: 100%; }
.lead-side { width: 400px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.lead-side .head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.lead-side .head h2 { font-size: 20px; font-weight: 700; margin: 2px 0 8px; }
.stagebar { display: flex; gap: 2px; margin-bottom: 8px; }
.stagebar span { flex: 1; height: 6px; border-radius: 1px; background: #e6e8ea; }
.lead-side .sec { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.lead-side .sec-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; margin-bottom: 8px; display: flex; align-items: center; }
.field { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; }
.field .k { width: 120px; flex-shrink: 0; color: var(--muted); }
.field .v { flex: 1; min-width: 0; word-break: break-word; }
.lead-feed { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f5f6f8; }
.feed { flex: 1; overflow-y: auto; padding: 16px 24px; }
.feed-day { text-align: center; margin: 14px 0 8px; }
.feed-day span { background: #e4e7eb; color: #5d6873; font-size: 11px; padding: 2px 10px; border-radius: 10px; }
.fe { display: flex; gap: 10px; margin-bottom: 10px; }
.fe .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.fe .bubble { background: #fff; border: 1px solid #e3e6ea; border-radius: 4px; padding: 8px 12px; max-width: 680px; white-space: pre-wrap; }
.fe.note .bubble { background: #fffbe0; border-color: #f1e3a0; }
.fe.call .bubble { background: #eef6ff; border-color: #cfe2fb; }
.fe.sale .bubble { background: #eafaf0; border-color: #bfe8cf; }
.fe.sys { justify-content: center; }
.fe.sys { margin-bottom: 4px; }
.fe.sys .bubble { background: transparent; border: 0; color: var(--muted); font-size: 12px; padding: 0; text-align: center; white-space: normal; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: 10px 16px; }
.composer .tabs { display: flex; gap: 14px; margin-bottom: 6px; font-size: 13px; }
.composer .tabs a { color: var(--muted); text-decoration: none; padding-bottom: 3px; cursor: pointer; }
.composer .tabs a.on { color: var(--text); font-weight: 700; border-bottom: 2px solid var(--blue); }
.composer textarea { resize: none; border: 1px solid var(--line); }
.composer .pane { display: none; }
.composer .pane.on { display: block; }

/* ---------- Sohbetler ---------- */
.chat-view { display: flex; height: calc(100vh - var(--topbar-h)); width: 100%; }
.chat-list { width: 340px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.chat-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f0f2f4; text-decoration: none; color: var(--text); }
.chat-item:hover { background: #f7f9fc; }
.chat-item.on { background: #e8f0fe; }
.chat-item.unread .name, .chat-item.unread .preview { font-weight: 700; }
.chat-item .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-item .preview { font-size: 12px; color: #5d6873; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .who { font-size: 11px; color: var(--muted); }
.min-w-0 { min-width: 0; }
.chat-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f5f6f8; }
.thread-head { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.msg { display: flex; margin-bottom: 8px; }
.msg.out { justify-content: flex-end; }
.msg .bubble { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 7px 10px; max-width: min(640px, 75%); }
.msg.out .bubble { background: #dcf8c6; border-color: #cbeab3; }
.msg .txt { white-space: pre-wrap; word-break: break-word; }
.msg .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.chat-img { max-width: 260px; max-height: 260px; border-radius: 6px; display: block; }

/* ---------- Pano ---------- */
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
a.panel { text-decoration: none; color: inherit; display: block; }
a.panel:hover { border-color: #c9d3df; }

/* ---------- Giriş ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sb-bg); padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 4px; padding: 28px; }
.auth-card .brand { font-size: 22px; font-weight: 700; margin-bottom: 18px; }

/* ---------- Mobil ---------- */
@media (max-width: 767.98px) {
    :root { --sb-w: 0px; }
    .sb { inset: auto 0 0 0; width: 100%; height: 56px; flex-direction: row; }
    .sb-logo, .sb-bottom .sb-user-name { display: none; }
    .sb-nav { display: flex; overflow-x: auto; overflow-y: hidden; padding: 0; flex: 1; }
    .sb-bottom { display: flex; border-top: 0; padding: 0; }
    .sb-item { padding: 7px 8px 5px; min-width: 62px; justify-content: center; }
    .sb-item i { font-size: 18px; }
    .sb-badge { right: 8px; top: 3px; }
    .sb-item.active::before { top: auto; width: auto; height: 3px; right: 0; }
    .main { margin-left: 0; padding-bottom: 56px; }
    .topbar { padding: 0 10px; gap: 8px; overflow-x: auto; }
    .topbar h1 { font-size: 13px; }
    .topbar .search { min-width: 150px; }
    .topbar .btn-primary.text-upper { font-size: 0; padding: 4px 9px; }
    .topbar .btn-primary.text-upper i { font-size: 14px; }
    .board, .lead-view { height: calc(100vh - var(--topbar-h) - 56px); }
    .lead-view { flex-direction: column; height: auto; }
    .chat-view { height: calc(100vh - var(--topbar-h) - 56px); }
    .chat-list { width: 100%; }
    .chat-list.has-thread { display: none; }
    .chat-list.has-thread + .chat-thread { display: flex; }
    .lead-side { width: 100%; border-right: 0; }
    .lead-feed { min-height: 60vh; }
    .page { padding: 12px; }
    .dropzones { left: 0; bottom: 56px; }
}
