/* CrediScanner: our styles on top of Bootstrap 5.3 (no build step). Brand colours as in design/brand/README.md. */
:root,
[data-bs-theme="light"] {
    --bs-primary: #0B7A75;
    --bs-primary-rgb: 11, 122, 117;
    --bs-link-color: #0B7A75;
    --bs-link-color-rgb: 11, 122, 117;
    --bs-link-hover-color: #075955;
    --brand-ink: #13293D;
}

[data-bs-theme="dark"] {
    --bs-primary: #43C7BE;
    --bs-primary-rgb: 67, 199, 190;
    --bs-link-color: #43C7BE;
    --bs-link-color-rgb: 67, 199, 190;
    --bs-link-hover-color: #7BD9D2;
    --bs-body-bg: #0F1B26;
    --brand-ink: #EAF2F7;
}

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: #075955;
    --bs-btn-hover-border-color: #075955;
    --bs-btn-active-bg: #075955;
    --bs-btn-active-border-color: #075955;
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #0F1B26;
    --bs-btn-hover-bg: #7BD9D2;
    --bs-btn-hover-border-color: #7BD9D2;
    --bs-btn-hover-color: #0F1B26;
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
}

[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-hover-color: #0F1B26;
    --bs-btn-active-color: #0F1B26;
}

.form-range::-webkit-slider-thumb { background-color: var(--bs-primary); }
.form-range::-moz-range-thumb { background-color: var(--bs-primary); }

/* Logo: one image per theme */
.logo { height: 30px; width: auto; }
.logo-dark { display: none; }
[data-bs-theme="dark"] .logo-light { display: none; }
[data-bs-theme="dark"] .logo-dark { display: inline; }

/* Offer cards: compact on phones (two lines until "Подробно") */
.min-w-0 { min-width: 0; }
.offer-total {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--brand-ink);
    white-space: nowrap;
}
#results.loading { opacity: .5; transition: opacity .15s; }

@media (min-width: 768px) {
    .offer-total { font-size: 1.25rem; }
}

/* Calculator form: compact on phones so the first results show on the first screen */
.page-title { font-size: 1.25rem; font-weight: 600; }
@media (max-width: 575.98px) {
    .btn-group-sm-phone > .btn { padding: .35rem .25rem; font-size: .875rem; }
    .calc-number { font-size: 1.1rem; padding: .375rem .5rem; }
    .calculator .input-group-text { padding: .375rem .5rem; font-size: .875rem; }
    .calculator .form-label { font-size: .875rem; }
}
@media (min-width: 768px) {
    .page-title { font-size: 1.75rem; }
}

/* Lender logos: on a small white plate, so dark-text logos stay readable in the dark theme too */
.lender-logo {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border-radius: .375rem;
    padding: 3px 6px;
    height: 32px;
    flex-shrink: 0;
}
/* A fixed height: some SVG logos have only a viewBox and would collapse to nothing with max-height alone. */
.lender-logo img { height: 26px; width: auto; max-width: 120px; object-fit: contain; }
.lender-logo-icon { padding: 3px; width: 32px; justify-content: center; }
.lender-logo-icon img { height: 26px; max-width: 26px; }
[data-bs-theme="light"] .lender-logo { box-shadow: inset 0 0 0 1px var(--bs-border-color); }

/* "Нагоре" button: bottom right, shown after scrolling down (app.js) */
.to-top {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s, visibility .2s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }

/* Menu */
.site-header .nav-link.active { color: var(--bs-primary); font-weight: 600; }
.site-header .dropdown-item.active,
.site-header .dropdown-item:active { background-color: var(--bs-primary); color: #fff; }
[data-bs-theme="dark"] .site-header .dropdown-item.active { color: #0F1B26; }

/* Offer card layout. Phones and medium screens: logo + total on top, product and lines below, actions at the
   bottom. From 992 px: the logo has its own column on the left (large, centred), product in the middle, total and
   the lender button on the right (below 992 px the middle column is too narrow for the three boxes). */
.offer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "logo price"
        "main main"
        "actions actions";
    column-gap: 12px;
    row-gap: 4px;
    align-items: start;
}
.offer-logo { grid-area: logo; display: flex; align-items: center; gap: 8px; min-width: 0; }
/* The link to the lender's page around the logo and name: laid out like the column itself */
.offer-logo-link { display: flex; align-items: center; gap: 8px; min-width: 0; border-radius: var(--bs-border-radius); }
.offer-logo-link:hover .lender-logo { box-shadow: 0 0 0 2px var(--bs-primary-border-subtle); }
.offer-main { grid-area: main; }
.offer-price { grid-area: price; }
.offer-actions { grid-area: actions; margin-top: 4px; }
.lender-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 992px) {
    .offer-grid {
        grid-template-columns: 190px minmax(0, 1fr) auto;
        grid-template-areas:
            "logo main price"
            "logo main actions";
        column-gap: 24px;
    }
    .offer-card .card-body { padding: 16px 20px !important; }
    .offer-logo {
        align-self: stretch;
        flex-direction: column;
        justify-content: center;
        border-right: 1px solid var(--bs-border-color);
        padding-right: 20px;
    }
    /* One plate size for every logo, filling the column: wide logos are limited by the width, square ones
       (A1, Viva Credit) by the height, so they are not left small in the middle of the column */
    .offer-logo-link { flex-direction: column; justify-content: center; width: 100%; }
    .offer-logo .lender-logo { width: 100%; height: 96px; padding: 8px 12px; justify-content: center; }
    .offer-logo .lender-logo img { height: 80px; max-width: 100%; }
    .offer-logo .lender-logo-icon { width: 64px; }
    .offer-logo .lender-logo-icon img { height: 48px; max-width: 48px; }
    .offer-logo .lender-name { white-space: normal; text-align: center; }
    .offer-actions { justify-content: flex-end !important; flex-direction: row-reverse; align-self: end; }
}

/* Lender without a logo: its name, larger, in place of the logo */
.lender-name-only { font-size: 1.15rem; font-weight: 700; color: var(--brand-ink); }
@media (min-width: 768px) {
    .offer-logo .lender-name-only { font-size: 1.4rem; line-height: 1.2; }
}

/* Instalment / term / number of instalments: three boxes side by side, label above, value large */
.offer-stats {
    display: grid;
    /* the instalment box is wider: it is the value people look at first */
    grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr));
    gap: 6px;
}
.offer-stat {
    background: var(--bs-tertiary-bg);
    border-radius: .375rem;
    padding: 6px 8px;
    text-align: center;
}
.offer-stat dt {
    font-size: .75rem;
    font-weight: 400;
    color: var(--bs-secondary-color);
    margin: 0;
}
.offer-stat dd {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    color: var(--brand-ink);
}
@media (min-width: 768px) {
    .offer-stats { gap: 10px; max-width: 640px; }
    .offer-stat { padding: 10px 12px; }
    .offer-stat dt { font-size: .875rem; }
}

/* Largest screens (Bootstrap xl, 1200 px and up): the three boxes larger still */
@media (min-width: 1200px) {
    .offer-stats { gap: 12px; max-width: 760px; }
    .offer-stat { padding: 12px 14px; }
    .offer-stat dt { font-size: 1rem; }
    /* the total to repay: smaller than the instalment */
    .offer-total { font-size: 1.5rem; }
    .offer-price .small { font-size: 1rem; }
}

/* 992-1199 px: column layout, slightly smaller total. The buttons go to their own row under the boxes: in the right
   column their width (about 730 px) left the boxes too narrow for their values. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .offer-grid {
        grid-template-areas:
            "logo main price"
            "logo actions actions";
    }
    .offer-actions { margin-top: 8px; }
    .offer-stat { padding: 8px 8px; }
    .offer-total { font-size: 1.2rem; }
}

/* The value follows the width of its own box (container query units), so "44 седмици" or "1 234,56 €" always
   fit: large in wide boxes (up to 30 px), smaller in narrow ones (down to about 14 px). */
.offer-stat { container-type: inline-size; }
.offer-stat dd { font-size: clamp(.875rem, 15cqi, 1.9rem); line-height: 1.25; }

/* Instalment: the largest value of the card, on a light brand background */
.offer-stat-main { background: var(--bs-primary-bg-subtle); }
.offer-stat-main dd { font-size: clamp(1.1rem, 17cqi, 2.5rem); font-weight: 700; }

/* The same boxes on a second line (second price, another product): four of them (with the total), smaller and
   on a plainer background, so the main line still stands out */
.offer-stats-sub { grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr)); gap: 6px; }
.offer-stats-sub .offer-stat { padding: 4px 6px; }
.offer-stats-sub .offer-stat dt { font-size: .7rem; }
.offer-stats-sub .offer-stat dd { font-size: clamp(.75rem, 12cqi, 1.15rem); font-weight: 600; }
.offer-stats-sub .offer-stat-main { background: var(--bs-tertiary-bg); box-shadow: inset 0 0 0 1px var(--bs-primary-border-subtle); }
.offer-stats-sub .offer-stat-main dd { font-size: clamp(.85rem, 14cqi, 1.4rem); font-weight: 700; }
@media (min-width: 768px) {
    .offer-stats-sub { gap: 8px; max-width: 640px; }
    .offer-stats-sub .offer-stat { padding: 6px 8px; }
    .offer-stats-sub .offer-stat dt { font-size: .75rem; }
}
@media (min-width: 1200px) { .offer-stats-sub { max-width: 760px; } }

/* "За сума: ..." above the boxes when the amount differs from the asked one */
.offer-shown { font-weight: 600; font-size: 1.15rem; line-height: 1.3; }
@media (min-width: 992px) { .offer-shown { font-size: 1.35rem; } }
@media (min-width: 1200px) { .offer-shown { font-size: 1.6rem; } }

/* Second lines of a card (second price, group product): the instalment readable at a glance but smaller than
   the main one, the total below it in small print */
.offer-sub-price { text-align: right; line-height: 1.2; }
.offer-sub-installment { font-size: 1rem; font-weight: 700; color: var(--brand-ink); }
@media (min-width: 768px) { .offer-sub-installment { font-size: 1.15rem; } }
.offer-sub-per { font-size: .875rem; color: var(--bs-secondary-color); }
.offer-sub-total { font-size: .8rem; font-weight: 600; color: var(--bs-secondary-color); }
.offer-sub-total-amount { font-size: .95rem; }
@media (min-width: 1200px) {
    .offer-sub-installment { font-size: 1.4rem; }
    .offer-sub-total { font-size: .875rem; }
    .offer-sub-total-amount { font-size: 1.05rem; }
}

/* Calculator stays at the top while the results scroll; compact once stuck (app.js .is-stuck) */
.calculator { position: sticky; top: 0; z-index: 1020; }
.calculator.is-stuck {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 0;
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .12);
    padding-top: .5rem;
    padding-bottom: .5rem;
}
.calculator.is-stuck .calc-categories { margin-bottom: .5rem !important; }
.calculator.is-stuck .calc-categories > .btn { padding-top: .2rem; padding-bottom: .2rem; font-size: .875rem; }
.calculator.is-stuck .form-label { font-size: .8rem; margin-bottom: 0 !important; }
.calculator.is-stuck .input-group { margin-bottom: .25rem !important; }
.calculator.is-stuck .calc-number { font-size: 1rem; padding-top: .25rem; padding-bottom: .25rem; }
.calculator.is-stuck .input-group-text { padding-top: .25rem; padding-bottom: .25rem; }
/* Phones: when stuck only the two values and their sliders (the units say which is which) */
@media (max-width: 767.98px) {
    .calculator.is-stuck .calc-categories,
    .calculator.is-stuck .form-label { display: none !important; }
}

/* "Проверено на ..." under the total */
.offer-checked { font-size: .75rem; }

/* "Подробно": the reference lines (parameters, rates) in small print; prices keep their size */
.offer-params, .offer-rates { font-size: .875rem; }

/* "Избрани": a picked card stands out; the bar sits at the bottom, the back-to-top button above it */
.offer-card.is-picked { border-color: var(--bs-warning); box-shadow: 0 0 0 1px var(--bs-warning); }
.offer-pick.active { background: var(--bs-warning); color: #000; }
.picked-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    padding: .5rem 0;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    box-shadow: 0 -.25rem .75rem rgba(0, 0, 0, .1);
}
body.has-picked-bar { padding-bottom: 4rem; }
body.has-picked-bar .to-top { bottom: 4.5rem; }

/* ⓘ explanation buttons (popovers): a bold "i" in a circle, in the brand colour, easy to spot and tap */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15em;
    height: 1.15em;
    margin: 0 .15rem;
    padding: 0;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    background: none;
    font: 700 .8em/1 Georgia, "Times New Roman", serif;
    font-style: italic;
    color: var(--bs-primary);
    cursor: help;
    vertical-align: .05em;
}
.info-tip:hover, .info-tip:focus-visible { background: var(--bs-primary); color: #fff; border-color: var(--bs-primary); }
/* Under the sticky calculator (z-index 1020), so an explanation never covers the sliders */
.popover { --bs-popover-max-width: 320px; --bs-popover-zindex: 1015; font-size: .875rem; }

/* Phones: the pick button is only its star, so the card's buttons stay on one line */
@media (max-width: 575.98px) {
    .offer-pick .pick-label { display: none; }
    .offer-actions .btn { white-space: nowrap; }
}

/* The group page links stay with the full form only; the stuck (compact) form keeps just the values */
.calculator.is-stuck .group-links { display: none !important; }

/* Lender pages (/bg/kreditori): a larger logo box than on the offer cards; tiles lift on hover. */
.lender-page-logo { height: 56px; width: 120px; padding: 6px 10px; justify-content: center; }
.lender-page-logo img { height: 44px; max-width: 100%; }
.lender-page-logo.lender-logo-icon { width: 56px; }
.lender-page-logo.lender-logo-icon img { height: 40px; max-width: 40px; }
.lender-tile { transition: box-shadow .15s ease-in-out; }
.lender-tile:hover, .lender-tile:focus-visible { box-shadow: var(--bs-box-shadow-sm); }
.lender-terms td, .lender-terms th { font-variant-numeric: tabular-nums; }
