/* ==========================================================================
   Kitap Fiyat Karşılaştırma — arayüz stilleri (Bootstrap 5 üzerine)
   Mobil öncelikli; fiyatlar büyük ve belirgin, "EN UCUZ" yeşil rozetle.
   ========================================================================== */

:root {
    --kf-brand: #1d4ed8;
    --kf-brand-dark: #1e3a8a;
    --kf-brand-soft: #eef4ff;
    --kf-green: #15803d;
    --kf-green-strong: #16a34a;
    --kf-green-soft: #effaf2;
    --kf-bg: #f4f6fa;
    --kf-card: #ffffff;
    --kf-border: #e2e8f0;
    --kf-text: #1f2937;
    --kf-muted: #64748b;
    --kf-radius: 12px;
    --kf-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .04);
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --bs-body-color: var(--kf-text);
    --bs-body-bg: var(--kf-bg);
    --bs-link-color: var(--kf-brand);
    --bs-link-color-rgb: 29, 78, 216;
    --bs-link-hover-color: var(--kf-brand-dark);
    --bs-link-hover-color-rgb: 30, 58, 138;
    --bs-primary: #1d4ed8;
    --bs-primary-rgb: 29, 78, 216;
}

body {
    background: var(--kf-bg);
    color: var(--kf-text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
    position: absolute;
    z-index: 1100;
    left: 1rem;
    top: .5rem;
    background: #fff;
    padding: .5rem 1rem;
    border-radius: 8px;
}

.btn-primary {
    --bs-btn-bg: var(--kf-brand);
    --bs-btn-border-color: var(--kf-brand);
    --bs-btn-hover-bg: var(--kf-brand-dark);
    --bs-btn-hover-border-color: var(--kf-brand-dark);
    --bs-btn-active-bg: var(--kf-brand-dark);
    --bs-btn-active-border-color: var(--kf-brand-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--kf-brand);
    --bs-btn-border-color: #bcd0f7;
    --bs-btn-hover-bg: var(--kf-brand);
    --bs-btn-hover-border-color: var(--kf-brand);
    --bs-btn-active-bg: var(--kf-brand);
    --bs-btn-active-border-color: var(--kf-brand);
}

.btn-success {
    --bs-btn-bg: var(--kf-green-strong);
    --bs-btn-border-color: var(--kf-green-strong);
    --bs-btn-hover-bg: var(--kf-green);
    --bs-btn-hover-border-color: var(--kf-green);
    --bs-btn-active-bg: var(--kf-green);
    font-weight: 600;
}

/* ---------------------------------------------------------------- Header */

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--kf-border);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.site-header .navbar { padding: .6rem 0; }
.site-header .container { gap: 1rem; flex-wrap: nowrap; }

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    color: var(--kf-text);
    font-size: 1.05rem;
    white-space: nowrap;
}

.navbar-brand:hover { text-decoration: none; color: var(--kf-brand); }

.header-search { max-width: 560px; margin-left: auto; min-width: 0; }

@media (max-width: 575.98px) {
    .navbar-brand span { display: none; }
}

.site-main { flex: 1 0 auto; }

/* ---------------------------------------------------------------- Search */

.search-box {
    position: relative;
    display: flex;
    gap: .5rem;
}

.search-box .form-control {
    border-radius: 10px;
    border-color: #cbd5e1;
    background: #fff;
}

.search-box .form-control:focus {
    border-color: var(--kf-brand);
    box-shadow: 0 0 0 .2rem rgba(29, 78, 216, .15);
}

.search-box .btn { border-radius: 10px; display: inline-flex; align-items: center; gap: .4rem; }

.search-form-lg .form-control-lg { padding: .9rem 1.1rem; font-size: 1.15rem; }

.ac-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1040;
    list-style: none;
    margin: 0;
    padding: .25rem;
    background: #fff;
    border: 1px solid var(--kf-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    max-height: 70vh;
    overflow-y: auto;
}

.ac-item a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .6rem;
    border-radius: 8px;
    color: var(--kf-text);
}

.ac-item a:hover,
.ac-item[aria-selected="true"] a { background: var(--kf-brand-soft); text-decoration: none; }

.ac-item img { width: 32px; height: 48px; object-fit: cover; border-radius: 3px; flex: 0 0 32px; background: #eef2f7; }
.ac-title { font-weight: 600; line-height: 1.2; display: block; }
.ac-meta { font-size: .8rem; color: var(--kf-muted); display: block; }
.ac-price { margin-left: auto; font-weight: 700; white-space: nowrap; color: var(--kf-green); font-size: .9rem; }
.ac-empty { padding: .6rem; color: var(--kf-muted); font-size: .9rem; }

/* ---------------------------------------------------------------- Hero */

.hero {
    background: linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
    border-bottom: 1px solid var(--kf-border);
    padding: 3.5rem 0 2.5rem;
    text-align: center;
}

.hero-title { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; }
.hero-lead { color: var(--kf-muted); font-size: 1.1rem; margin-bottom: 1.5rem; }
.hero-search { max-width: 720px; margin: 0 auto; text-align: left; }
.hero-examples { margin-top: .9rem; color: var(--kf-muted); font-size: .95rem; }

.hero-features {
    list-style: none;
    padding: 0;
    margin: 2rem auto 0;
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-width: 960px;
    font-size: .9rem;
    color: var(--kf-muted);
}

.hero-features li { background: #fff; border: 1px solid var(--kf-border); border-radius: var(--kf-radius); padding: .75rem 1rem; }
.hero-features strong { color: var(--kf-text); display: block; }

/* ---------------------------------------------------------------- Sections / cards */

.page-container { padding-top: 1.5rem; padding-bottom: 3rem; }
.page-container.narrow { max-width: 820px; }
.page-title { font-size: clamp(1.35rem, 3vw, 1.75rem); font-weight: 700; margin-bottom: 1rem; }
.section-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 1rem; }
.home-section { margin: 2.25rem 0; }

.empty-state {
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: var(--kf-radius);
    padding: 1.5rem;
    text-align: center;
    color: var(--kf-muted);
}

.book-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.book-card {
    background: var(--kf-card);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    padding: .75rem;
    box-shadow: var(--kf-shadow);
    display: flex;
    flex-direction: column;
}

.book-card-link { color: var(--kf-text); }
.book-card-link:hover { text-decoration: none; color: var(--kf-brand); }
.book-cover { position: relative; aspect-ratio: 2 / 3; background: #eef2f7; border-radius: 6px; overflow: hidden; margin-bottom: .6rem; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card-badge { position: absolute; top: .4rem; left: .4rem; }
.book-card-title { font-size: .95rem; font-weight: 600; line-height: 1.3; margin: 0 0 .25rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card-author, .book-card-publisher { font-size: .8rem; color: var(--kf-muted); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card-price { margin: auto 0 0; padding-top: .5rem; display: flex; align-items: baseline; gap: .35rem; }
.book-card-price strong { font-size: 1.1rem; color: var(--kf-green); }
.book-card-note { margin: .25rem 0 0; }

.book-list { display: flex; flex-direction: column; gap: .75rem; }

.book-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: var(--kf-card);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    padding: .75rem;
    box-shadow: var(--kf-shadow);
}

.book-row-cover img { width: 72px; height: 108px; object-fit: cover; border-radius: 5px; background: #eef2f7; }
.book-row-body { flex: 1; min-width: 0; }
.book-row-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 .25rem; }
.book-row-title a { color: var(--kf-text); }
.book-row-meta { margin: 0; font-size: .9rem; }
.book-row-isbn { margin: .25rem 0 0; }
.book-row-price { display: flex; flex-direction: column; align-items: flex-end; text-align: right; min-width: 120px; }
.book-row-price .price { font-size: 1.3rem; color: var(--kf-green); font-weight: 800; white-space: nowrap; }
.book-row-price > span { white-space: nowrap; }

@media (max-width: 575.98px) {
    .book-row { flex-wrap: wrap; }
    .book-row-price { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: .15rem .5rem; width: 100%; justify-content: flex-start; text-align: left; min-width: 0; }
    .book-row-price .btn { margin-top: 0 !important; margin-left: auto; align-self: center; }
}

/* ---------------------------------------------------------------- Book detail */

.book-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    background: var(--kf-card);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    padding: 1.25rem;
    box-shadow: var(--kf-shadow);
}

@media (min-width: 768px) {
    .book-header { grid-template-columns: 220px 1fr; padding: 1.75rem; }
}

.book-header-cover { text-align: center; }
.book-header-cover img { width: 100%; max-width: 220px; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; background: #eef2f7; box-shadow: 0 6px 18px rgba(15, 23, 42, .12); }
.book-title { font-size: clamp(1.4rem, 3.2vw, 2rem); font-weight: 800; letter-spacing: -.01em; margin-bottom: .35rem; }
.book-byline { font-size: 1.05rem; margin-bottom: 1rem; }

.book-facts {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin-bottom: 1.25rem;
    font-size: .9rem;
}

.book-facts dt { font-weight: 500; color: var(--kf-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.book-facts dd { margin: 0; font-weight: 600; }

.cheapest-box {
    border: 2px solid var(--kf-green-strong);
    background: var(--kf-green-soft);
    border-radius: var(--kf-radius);
    padding: 1rem 1.25rem;
    max-width: 460px;
}

.cheapest-label { display: flex; align-items: center; gap: .5rem; color: var(--kf-green); font-weight: 600; }
.cheapest-price { font-size: clamp(2rem, 6vw, 2.6rem); font-weight: 800; color: var(--kf-green); line-height: 1.1; margin-top: .25rem; }
.cheapest-store { font-weight: 600; font-size: 1.05rem; }
.cheapest-note { color: #92400e; background: #fffbeb; border-radius: 8px; padding: .5rem .75rem; }

.badge-cheapest {
    background: var(--kf-green-strong);
    color: #fff;
    font-weight: 700;
    letter-spacing: .04em;
}

.no-offer-box {
    border: 1px dashed #cbd5e1;
    border-radius: var(--kf-radius);
    padding: 1rem 1.25rem;
    max-width: 460px;
    background: #f8fafc;
}

.price-range { margin: 1rem 0 0; color: var(--kf-muted); }

.alert-form { max-width: 560px; }

/* ---------------------------------------------------------------- Offers */

.offers-section, .history-section, .description-section { margin-top: 2rem; }

.offer-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }

.offer {
    display: grid;
    grid-template-columns: 1fr;
    gap: .5rem;
    background: var(--kf-card);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    padding: 1rem;
    box-shadow: var(--kf-shadow);
    transition: box-shadow .15s ease;
}

.offer:hover { box-shadow: 0 6px 24px rgba(15, 23, 42, .08); }
.offer-cheapest { border: 2px solid var(--kf-green-strong); background: linear-gradient(90deg, var(--kf-green-soft), #fff 60%); }
.offer-unavailable { opacity: .75; background: #fafbfc; }
.offer-stale { border-style: dashed; }
.offer-updating { opacity: .55; }

.offer-store { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.store-name { font-weight: 700; font-size: 1.05rem; }

.offer-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; }
.offer-price .price { font-size: 1.6rem; font-weight: 800; color: var(--kf-text); line-height: 1.1; }
.offer-cheapest .offer-price .price { color: var(--kf-green); }
.old-price { color: var(--kf-muted); font-size: .9rem; }
.discount { color: #b91c1c; font-weight: 600; }
.price-drop { color: var(--kf-green); background: var(--kf-green-soft); border-radius: 6px; padding: 0 .4rem; font-size: .85rem; font-weight: 700; }

.offer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; font-size: .88rem; }
.offer-meta .shipping-unknown { color: #92400e; }
.offer-meta .checked { color: var(--kf-muted); font-size: .8rem; }
.offer-action .btn { width: 100%; }

@media (min-width: 768px) {
    .offer {
        grid-template-columns: minmax(150px, 1.1fr) minmax(170px, 1.2fr) 2fr auto;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.25rem;
    }
    .offer-action .btn { width: auto; white-space: nowrap; }
    .offer-price { flex-direction: column; align-items: flex-start; gap: .1rem; }
}

.store-status summary { cursor: pointer; color: var(--kf-muted); font-size: .9rem; }
.status-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; background: #94a3b8; vertical-align: middle; }
.status-ok { background: var(--kf-green-strong); }
.status-error { background: #dc2626; }
.status-stale, .status-hidden, .status-pending { background: #f59e0b; }
.status-not_found, .status-out_of_stock { background: #64748b; }
.status-unavailable { background: #cbd5e1; }

/* ---------------------------------------------------------------- History */

.history-summary { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-bottom: .75rem; font-size: .95rem; }
.history-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }

.chart-wrap {
    position: relative;
    background: var(--kf-card);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    padding: 1rem;
    height: 320px;
}

.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; }
.chart-empty.d-none { display: none !important; }

.book-description {
    background: var(--kf-card);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    padding: 1.25rem;
    line-height: 1.65;
}

/* ---------------------------------------------------------------- Pages */

.prose h2 { margin-top: 1.5rem; }
.prose li { margin-bottom: .35rem; }
.error-search { max-width: 560px; }
.debug-trace { white-space: pre-wrap; word-break: break-word; }

/* ---------------------------------------------------------------- Footer */

.site-footer {
    margin-top: 3rem;
    padding: 1.75rem 0;
    background: #fff;
    border-top: 1px solid var(--kf-border);
    font-size: .9rem;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
