/* ============================================================
   Components
   ------------------------------------------------------------
   Yeniden kullanılan UI bileşenleri: butonlar, kartlar,
   paneller, form alanları, arama, çipler, sonuç kutuları,
   PDF görüntüleyici ve hesaplayıcı sekmeleri.
   ============================================================ */

/* Butonlar --------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 15px;
  transition: .18s;
  min-height: 48px;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 118, 110, .25);
}

.btn-primary:hover {
  background: var(--primary-2);
}

.btn-primary:active {
  transform: scale(.98);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--line);
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn-row .btn {
  flex: 1;
}

/* Form alanları --------------------------------------------- */
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  margin: 0 0 6px;
  letter-spacing: .02em;
}

.field input,
.field select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  background: var(--surface);
  font-size: 16px;
  color: var(--ink);
  transition: .18s;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.patient-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Hızlı eylem kartları -------------------------------------- */
.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.action {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 20px 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: .2s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  min-height: 160px;
}

.action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.action:active {
  transform: scale(.98);
}

.action-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
}

.action-icon svg {
  width: 28px;
  height: 28px;
  stroke-width: 2;
}

.action-icon.adult {
  background: linear-gradient(135deg, #0f766e, #0d9488);
}

.action-icon.kids {
  background: linear-gradient(135deg, #ea580c, #fb923c);
}

.action-icon.calc {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}

.action-icon.baby {
  background: linear-gradient(135deg, #db2777, #f9a8d4);
}

.action-icon.practice {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.action-body h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--ink);
}

.action-body p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.action-arrow {
  align-self: flex-end;
  font-size: 20px;
  color: var(--muted);
  transition: .2s;
}

.action:hover .action-arrow {
  color: var(--primary);
  transform: translateX(4px);
}

/* Arama ----------------------------------------------------- */
.search-shell {
  position: sticky;
  top: 71px;
  z-index: 20;
  background: var(--bg);
  padding: 12px 0 14px;
}

.search-wrap {
  position: relative;
}

.search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 14px 14px 46px;
  background: var(--surface);
  font-size: 16px;
  transition: .18s;
  box-shadow: var(--shadow-sm);
}

.search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 18px;
  height: 18px;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--surface-2);
}

.search-clear.visible {
  display: flex;
}

/* Filtre çipleri -------------------------------------------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  transition: .18s;
}

.chip:hover {
  background: var(--surface-2);
}

.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Konu kartları --------------------------------------------- */
.topics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.topic {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: .18s;
  box-shadow: var(--shadow-sm);
  min-height: 110px;
}

.topic:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.topic:active {
  transform: scale(.98);
}

.topic-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.topic-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  gap: 8px;
}

.page-pill {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  padding: 4px 9px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .02em;
}

.topic-section {
  margin-bottom: 18px;
}

.topic-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 18px 0 10px;
  color: var(--muted);
  font-weight: 800;
}

.topic-section-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.empty {
  padding: 50px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  text-align: center;
  color: var(--muted);
  background: var(--surface);
}

/* Hesaplayıcı sayfası --------------------------------------- */
.calc-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin: 0 0 18px;
  box-shadow: var(--shadow-sm);
}

.calc-tab {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-2);
  transition: .18s;
  text-align: center;
}

.calc-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 118, 110, .3);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--ink);
}

.panel-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
  line-height: 1.45;
}

.notice {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: #9a3412;
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid var(--accent);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.notice svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
}

@media (prefers-color-scheme: dark) {
  .notice {
    color: #fdba74;
  }
}

/* Sonuç kutusu ---------------------------------------------- */
.result {
  margin-top: 16px;
  background: linear-gradient(135deg, var(--primary-soft), transparent 60%), var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.result h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.dose-big {
  font-size: clamp(32px, 8vw, 48px);
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--primary);
  margin: 6px 0 18px;
  line-height: 1.1;
  word-break: break-word;
}

.dose-big.violet {
  color: var(--violet);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
}

.result-item-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.result-item-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

.result-item-value.muted {
  color: var(--muted);
  font-weight: 500;
}

.warning {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.4;
}

.warning svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.source-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .18s;
}

.source-link:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* Havayolu hesabı kartları --------------------------------- */
.airway-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.airway-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
}

.airway-card h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.airway-card .v {
  font-size: 24px;
  font-weight: 800;
  color: var(--violet);
  letter-spacing: -.02em;
  line-height: 1.1;
  word-break: break-word;
}

.airway-card .n {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

/* PDF Görüntüleyici ----------------------------------------- */
.viewer-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0a1413;
  display: flex;
  flex-direction: column;
}

.viewer-bar {
  height: auto;
  min-height: 64px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.viewer-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.viewer-title strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-title small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.viewer-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: .18s;
}

.viewer-btn:hover {
  background: var(--line);
}

.viewer-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.viewer-btn svg {
  width: 18px;
  height: 18px;
}

.viewer-back {
  font-size: 13px;
}

.viewer-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #1a2a27;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.viewer-img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
}

.viewer-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  background: #1a2a27;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line-2);
  border-top-color: var(--primary-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive grid kırılma noktaları ------------------------ */
@media (max-width: 680px) {
  .actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .action {
    min-height: 0;
    padding: 16px;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }

  .action-body {
    flex: 1;
  }

  .action-arrow {
    display: none;
  }

  .topics {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    display: flex;
  }
}

@media (min-width: 681px) and (max-width: 1100px) {
  .actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .actions .action:nth-child(3),
  .actions .action:nth-child(4) {
    flex-direction: row;
  }
}

@media (min-width: 1200px) {
  .topics {
    grid-template-columns: repeat(4, 1fr);
  }
}
