/* ============ Kişisel Doktor (web) — mobil öncelikli, duyarlı ============ */
:root {
  --bg-1: #e6f2f0; --bg-2: #eef3f9;
  --surface: #fff; --surface-2: #f6f9f9;
  --border: #dce6e6; --text: #16302e; --text-soft: #55716e; --muted: #8aa0a0;
  --primary: #0d9488; --primary-dark: #0b7d73; --primary-soft: #d6efec;
  --danger: #dc2626; --shadow: 0 10px 30px rgba(13,148,136,.10);
  --shadow-sm: 0 2px 8px rgba(20,60,58,.06); --radius: 16px; --radius-sm: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2)); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; font-size: .85em; }

/* -------- ortak form / buton -------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 14px; }
input, textarea, select { font: inherit; padding: 12px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn-primary { border: 0; background: var(--primary); color: #fff; padding: 13px 16px; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer; transition: background .15s; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.small { width: auto; padding: 9px 14px; font-size: 13px; }
.btn-ghost { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); padding: 9px 14px;
  border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; font-size: 13px; }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.link-btn { background: 0; border: 0; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 13px; margin-top: 14px; padding: 6px; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin: 12px 0 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; line-height: 1.45; }

/* -------- giriş / bağlan ekranları -------- */
.center-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow);
  padding: 28px 24px; border: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.brand-logo { font-size: 28px; width: 54px; height: 54px; display: grid; place-items: center; background: var(--primary-soft); border-radius: 15px; }
.brand-logo.tiny { width: 32px; height: 32px; font-size: 19px; border-radius: 9px; }
.brand h1 { margin: 0; font-size: 21px; letter-spacing: -.3px; }
.brand-sub { margin: 3px 0 0; color: var(--text-soft); font-size: 12.5px; word-break: break-all; }
.lead { color: var(--text-soft); font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; }
.form { display: flex; flex-direction: column; }
.tabs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.tab { flex: 1; border: 0; background: 0; padding: 11px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text-soft); }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.help { margin-top: 16px; font-size: 13px; color: var(--text-soft); }
.help summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.help ol { margin: 10px 0 0; padding-left: 18px; line-height: 1.6; }
.help code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ============================ UYGULAMA KABUĞU ============================ */
.app { min-height: 100vh; min-height: 100dvh; display: grid;
  grid-template: "top" auto "content" 1fr "nav" auto / 1fr; }

.topbar { grid-area: top; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px; }
.topbar-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.user-name { font-weight: 600; font-size: 13.5px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { grid-area: nav; display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; z-index: 10; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: 0;
  padding: 7px 4px; border-radius: 11px; cursor: pointer; color: var(--text-soft); font-weight: 600; }
.nav-item .ni { font-size: 20px; line-height: 1; }
.nav-item .nl { font-size: 11px; }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); }

.content { grid-area: content; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.view { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.view.active { display: flex; }
.view-pad { padding: 18px 16px 24px; overflow-y: auto; height: 100%; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.view-head h2 { margin: 0; font-size: 19px; letter-spacing: -.3px; }
.view-sub { margin: 4px 0 0; color: var(--text-soft); font-size: 13px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------- SOHBET -------------------------------- */
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.msg { display: flex; gap: 10px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { padding: 12px 15px; border-radius: 16px; box-shadow: var(--shadow-sm); line-height: 1.55; font-size: 15px; }
.msg.doctor .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 5px; }
.msg.user .bubble { background: var(--primary); color: #fff; border-top-right-radius: 5px; }
.msg .who { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 17px; }
.msg.doctor .who { background: var(--primary-soft); }
.msg.user .who { background: #dbeafe; }
.msg .attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg .attachments img { max-width: 140px; max-height: 140px; border-radius: 8px; }
.msg .attachments .doc-chip { background: var(--surface-2); padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.msg.user .attachments .doc-chip { background: rgba(255,255,255,.25); }
.empty-chat { margin: auto; text-align: center; color: var(--text-soft); max-width: 360px; padding: 20px; }
.empty-chat .big { font-size: 42px; margin-bottom: 10px; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.status-line { align-self: center; color: var(--muted); font-size: 12.5px; font-style: italic; }

.attach-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px; }
.attach-preview .chip { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 6px 5px 12px; font-size: 12.5px; }
.attach-preview .chip button { border: 0; background: var(--surface-2); border-radius: 50%; width: 20px; height: 20px; cursor: pointer; }

.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); }
.attach-btn { width: 42px; height: 42px; min-width: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); cursor: pointer; font-size: 18px; }
#chat-text { border: 0; resize: none; max-height: 140px; padding: 11px 4px; }
#chat-text:focus { box-shadow: none; }
.btn-send { width: 44px; height: 44px; min-width: 44px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; font-size: 18px; cursor: pointer; }
.btn-send:disabled { background: var(--muted); }

/* ------------------------------- KAYIT ------------------------------- */
.record-view, .record-edit { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.record-edit { display: flex; flex-direction: column; gap: 12px; }
#record-text { min-height: 320px; resize: vertical; font-family: "SF Mono", Consolas, monospace; font-size: 13px; line-height: 1.6; }

/* ------------------------------ DOSYALAR ------------------------------ */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.file-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); cursor: pointer; }
.file-card .thumb { height: 110px; background: var(--surface-2); display: grid; place-items: center; font-size: 38px; overflow: hidden; }
.file-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-card .meta { padding: 9px 11px; }
.file-card .fname { font-size: 12px; font-weight: 600; word-break: break-all; }
.empty-note { color: var(--text-soft); padding: 30px 0; text-align: center; }

/* ------------------------------ AYARLAR ------------------------------ */
.card2 { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 4px; margin-bottom: 16px; }
.card2 h3 { margin: 0 0 14px; font-size: 15px; }
.check-row { flex-direction: row; align-items: center; gap: 10px; }
.check-row input { width: auto; } .check-row span { font-weight: 500; color: var(--text); }

/* ------------------------------ MARKDOWN ------------------------------ */
.markdown { line-height: 1.6; word-wrap: break-word; }
.markdown h1,.markdown h2,.markdown h3 { line-height: 1.3; margin: 1em 0 .4em; }
.markdown h1 { font-size: 1.35em; } .markdown h2 { font-size: 1.15em; color: var(--primary-dark); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.markdown h3 { font-size: 1.03em; } .markdown p { margin: .5em 0; }
.markdown ul,.markdown ol { margin: .4em 0; padding-left: 1.25em; } .markdown li { margin: .2em 0; }
.markdown code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.markdown strong { font-weight: 700; }
.markdown table { border-collapse: collapse; margin: .6em 0; width: 100%; display: block; overflow-x: auto; }
.markdown th,.markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; font-size: .9em; white-space: nowrap; }
.markdown th { background: var(--surface-2); }
.msg.user .markdown h2 { color: #fff; border-color: rgba(255,255,255,.3); }
.msg.user .markdown code { background: rgba(255,255,255,.2); }

/* ------------------------------- TOAST ------------------------------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom));
  background: #16302e; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); z-index: 100; max-width: 90%; text-align: center; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--primary); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cddcda; border-radius: 6px; }

/* ============================ MASAÜSTÜ ============================ */
@media (min-width: 760px) {
  .app { grid-template: "top top" auto "nav content" 1fr / 232px 1fr; }
  .nav { flex-direction: column; gap: 4px; border-top: 0; border-right: 1px solid var(--border); padding: 16px 12px; position: static; }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; }
  .nav-item .ni { font-size: 18px; } .nav-item .nl { font-size: 14.5px; }
  .content { border-left: 0; }
  .chat-messages { padding: 24px 28px; }
  .view-pad { padding: 24px 30px; }
  .chat-input { padding: 14px 24px; }
  .msg { max-width: 82%; }
  .toast { bottom: 24px; }
}
@media (min-width: 1100px) { .msg { max-width: 70%; } }
