/* =========================================================================
   Bileşenler: arama, rozet, kart, tablo, sayfalama, harf paleti
   ========================================================================= */

/* --- Arama kutusu --- */
.search {
    position: relative;
    width: 100%;
}

.search__field {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    padding-inline: var(--sp-4);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search__field:focus-within {
    border-color: var(--brand-400);
    box-shadow: var(--ring);
}

.search__icon {
    width: 17px; height: 17px;
    color: var(--text-subtle);
    flex-shrink: 0;
}

.search__input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding-block: var(--sp-3);
    font-size: var(--text-base);
}
.search__input:focus { outline: none; }
.search__input::placeholder { color: var(--text-subtle); }

.search__clear {
    color: var(--text-subtle);
    display: none;
    padding: var(--sp-1);
    border-radius: var(--radius-pill);
}
.search__clear:hover { color: var(--text); background: var(--surface-hover); }
.search.has-value .search__clear { display: block; }

/* Büyük ana sayfa varyantı */
.search--hero .search__field {
    padding-inline: var(--sp-5);
    box-shadow: var(--shadow);
    border-color: transparent;
}
.search--hero .search__input { padding-block: var(--sp-5); font-size: var(--text-lg); }
.search--hero .search__icon { width: 21px; height: 21px; }

/* Otomatik tamamlama listesi */
.search__results {
    position: absolute;
    top: calc(100% + var(--sp-2));
    left: 0; right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
    max-height: min(60vh, 420px);
    overflow-y: auto;
}
.search__results:empty { display: none; }

.search__item {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    transition: background var(--transition);
}
.search__item:last-child { border-bottom: 0; }
.search__item:hover,
.search__item.is-active { background: var(--surface-hover); color: var(--text); }

.search__item-name { font-weight: 550; flex: 1; min-width: 0; }
.search__item-name mark {
    background: color-mix(in srgb, var(--brand-400) 30%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}
.search__item-sub {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-subtle);
    font-weight: 400;
}
.search__item-price {
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    white-space: nowrap;
}

.search__empty {
    padding: var(--sp-5);
    text-align: center;
    color: var(--text-subtle);
    font-size: var(--text-sm);
}

/* --- Rozetler --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px var(--sp-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge--neutral {
    background: var(--bg-sunken);
    color: var(--text-muted);
    border-color: var(--border);
}
.badge--brand {
    background: color-mix(in srgb, var(--brand-500) 12%, transparent);
    color: var(--brand-700);
    border-color: color-mix(in srgb, var(--brand-500) 28%, transparent);
}
:root[data-theme="dark"] .badge--brand { color: var(--brand-300); }

/* Reçete rozetleri — resmî reçete renklerine karşılık gelir */
.badge--rx-beyaz   { background: var(--rx-beyaz-bg);   color: var(--rx-beyaz-fg);   border-color: var(--rx-beyaz-edge); }
.badge--rx-kirmizi { background: var(--rx-kirmizi-bg); color: var(--rx-kirmizi-fg); border-color: var(--rx-kirmizi-edge); }
.badge--rx-yesil   { background: var(--rx-yesil-bg);   color: var(--rx-yesil-fg);   border-color: var(--rx-yesil-edge); }
.badge--rx-mor     { background: var(--rx-mor-bg);     color: var(--rx-mor-fg);     border-color: var(--rx-mor-edge); }
.badge--rx-turuncu { background: var(--rx-turuncu-bg); color: var(--rx-turuncu-fg); border-color: var(--rx-turuncu-edge); }
.badge--rx-diger   { background: var(--bg-sunken);     color: var(--text-muted);    border-color: var(--border); }

.badge__dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* --- Kart --- */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
}
.card--flush { padding: 0; overflow: hidden; }

.card__title {
    font-size: var(--text-md);
    margin-bottom: var(--sp-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}
.card__title a { font-size: var(--text-sm); font-weight: 500; }

.card__head {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
    font-weight: 620;
    font-size: var(--text-md);
}
.card__body { padding: var(--sp-5); }

/* --- İlaç kartı (ızgara görünümü) --- */
.drug-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.drug-card:hover {
    border-color: var(--brand-300);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.drug-card__name {
    font-weight: 620;
    font-size: var(--text-base);
    color: var(--text);
    line-height: var(--leading-snug);
}
.drug-card__ing {
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.drug-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-top: auto;
    padding-top: var(--sp-2);
}
.drug-card__price {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* --- İlaç listesi (satır görünümü) --- */
.drug-list {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.drug-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--sp-3) var(--sp-4);
    align-items: center;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.drug-row:last-child { border-bottom: 0; }
.drug-row:hover { background: var(--surface-hover); }

.drug-row__main { min-width: 0; }
.drug-row__name {
    font-weight: 600;
    color: var(--text);
    display: block;
    line-height: var(--leading-snug);
}
.drug-row__name:hover { color: var(--link); }
.drug-row__sub {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
}
.drug-row__aside {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    justify-self: end;
}
.drug-row__price {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
@media (max-width: 560px) {
    .drug-row { grid-template-columns: minmax(0, 1fr); }
    .drug-row__aside { justify-self: start; }
}

/* --- Özellik tablosu (ilaç detay) --- */
.spec-table { font-size: var(--text-base); }
.spec-table th,
.spec-table td {
    text-align: left;
    vertical-align: top;
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border);
}
.spec-table tr:last-child th,
.spec-table tr:last-child td { border-bottom: 0; }
.spec-table th {
    width: 190px;
    font-weight: 550;
    color: var(--text-muted);
    padding-right: var(--sp-4);
}
@media (max-width: 620px) {
    .spec-table th, .spec-table td { display: block; width: auto; border-bottom: 0; }
    .spec-table th { padding-bottom: 0; font-size: var(--text-sm); }
    .spec-table td { padding-top: var(--sp-1); }
    .spec-table tr { display: block; padding-block: var(--sp-2); border-bottom: 1px solid var(--border); }
}

.spec-table__value--mono {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

/* --- Fiyat kutusu --- */
.price-box {
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.price-box__amount {
    font-size: var(--text-2xl);
    font-weight: 680;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.price-box__note {
    font-size: var(--text-xs);
    color: var(--text-subtle);
}

/* --- ATC ağacı --- */
.atc-tree {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.9;
}
.atc-tree__line {
    display: block;
    color: var(--text-muted);
}
.atc-tree__line--leaf {
    color: var(--text);
    font-weight: 600;
}
.atc-tree__code {
    display: inline-block;
    min-width: 4.5em;
    color: var(--brand-600);
    font-weight: 600;
}
:root[data-theme="dark"] .atc-tree__code { color: var(--brand-300); }

/* --- Harf paleti --- */
.letters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}
.letters__item {
    min-width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding-inline: var(--sp-2);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-muted);
    transition: all var(--transition);
}
.letters__item:hover {
    border-color: var(--brand-400);
    color: var(--brand-700);
    background: var(--brand-50);
}
:root[data-theme="dark"] .letters__item:hover {
    background: var(--bg-sunken);
    color: var(--brand-300);
}
.letters__item.is-active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

/* --- Etiket bulutu --- */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: var(--text-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}
.chip:hover { border-color: var(--brand-300); color: var(--link); }
.chip__count {
    font-size: var(--text-xs);
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

/* --- Kırıntı navigasyonu --- */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    color: var(--text-subtle);
    margin-bottom: var(--sp-4);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--link); }
.breadcrumb__sep { opacity: 0.5; }

/* --- Sayfalama --- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    margin-top: var(--sp-8);
}
.pagination__link {
    min-width: 40px;
    height: 40px;
    padding-inline: var(--sp-3);
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 550;
    transition: all var(--transition);
}
.pagination__link:hover { border-color: var(--brand-400); color: var(--link); }
.pagination__link.is-active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}
.pagination__gap { padding-inline: var(--sp-2); color: var(--text-subtle); }

/* --- Düğmeler --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--radius);
    font-size: var(--text-base);
    font-weight: 580;
    border: 1px solid transparent;
    transition: all var(--transition);
}
.btn--primary {
    background: var(--brand-600);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--brand-700); color: #fff; }
.btn--ghost {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn--ghost:hover { border-color: var(--brand-400); color: var(--link); }
.btn svg { width: 17px; height: 17px; }

/* --- Bilgi/uyarı kutuları --- */
.notice {
    border-radius: var(--radius);
    padding: var(--sp-4);
    font-size: var(--text-sm);
    line-height: var(--leading-snug);
    border: 1px solid var(--border);
    background: var(--bg-sunken);
    color: var(--text-muted);
}
.notice strong { color: var(--text); }
.notice--warning {
    background: var(--rx-turuncu-bg);
    border-color: var(--rx-turuncu-edge);
    color: var(--rx-turuncu-fg);
}
.notice--warning strong { color: inherit; }

/* --- Boş durum --- */
.empty-state {
    text-align: center;
    padding: var(--sp-16) var(--sp-5);
    color: var(--text-muted);
}
.empty-state__icon {
    width: 46px; height: 46px;
    margin: 0 auto var(--sp-4);
    color: var(--text-subtle);
    opacity: 0.6;
}
.empty-state__title {
    font-size: var(--text-lg);
    color: var(--text);
    margin-bottom: var(--sp-2);
}

/* --- İstatistik şeridi --- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-3);
}
.stat {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-4) var(--sp-5);
}
.stat__value {
    font-size: var(--text-xl);
    font-weight: 680;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stat__label {
    font-size: var(--text-xs);
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: 2px;
}

/* --- Prospektüs (PDF) yerleştirme --- */
.doc-frame {
    width: 100%;
    height: min(80vh, 780px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-sunken);
}

/* Eskimiş fiyat uyarısı */
.price-box__stale {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    margin: var(--sp-4) 0 0;
    padding: var(--sp-3) var(--sp-4);
    background: var(--rx-turuncu-bg);
    border: 1px solid var(--rx-turuncu-edge);
    border-radius: var(--radius);
    color: var(--rx-turuncu-fg);
    font-size: var(--text-sm);
    line-height: var(--leading-snug);
}
.price-box__stale svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
