/*
 * UI polish layer for the calculator page.
 * Loaded from calculator.html's head block, i.e. BEFORE css/base.css (which
 * base.html links after the head block), so selectors here are deliberately a
 * notch more specific.
 */

/* ---------- Row value pills ---------- */

/* Empty pills: quiet placeholder instead of a loud purple "—" */
.asset-row .base-value-pill.pill-empty {
    background: #f1f5f9;
    color: #a0aec0;
    box-shadow: inset 0 0 0 1px #e2e8f0;
    font-weight: 500;
}

/* Grams pill is redundant when the row's unit is already grams */
.asset-row:has(.input-weight-unit option[value="g"]:checked) .weight-grams-pill {
    display: none;
}

.asset-row .base-value-pill {
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* ---------- Remove button ---------- */

.asset-row .btn-remove {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 20px;
    font-weight: 400;
    color: #a0aec0;
    opacity: 1;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.asset-row .btn-remove:hover,
.asset-row .btn-remove:focus-visible {
    background: #fff5f5;
    color: #e53e3e;
}

/* ---------- Add buttons ---------- */

.calculator-inputs .btn-add {
    background: transparent;
    color: #5a67d8;
    border: 1.5px dashed #c3dafe;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.calculator-inputs .btn-add:hover {
    background: #ebf4ff;
    border-color: #7f9cf5;
}

/* ---------- Row enter / leave animation ---------- */

@keyframes zc-row-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}
.asset-row.zc-row-new {
    animation: zc-row-in 0.18s ease-out;
}

/* ---------- Value change feedback ---------- */

@keyframes zc-value-flash {
    0%   { background-color: rgba(246, 224, 94, 0.55); }
    100% { background-color: transparent; }
}
.result-value.zc-flash,
.zc-summary-amount.zc-flash {
    animation: zc-value-flash 0.6s ease-out;
    border-radius: 4px;
}

/* Tabular figures stop totals from jittering as digits change */
.result-value,
.base-value-pill,
.weight-grams-pill,
.zc-summary-amount {
    font-variant-numeric: tabular-nums;
}

/* ---------- Nisab indicator ---------- */

.nisab-status-icon:empty {
    display: none;
}

/* ---------- Sticky "Zakat due" summary bar (single-column layouts) ---------- */

.zc-summary-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
            backdrop-filter: saturate(1.4) blur(10px);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -6px 20px rgba(26, 32, 44, 0.08);
    transform: translateY(110%);
    transition: transform 0.22s ease;
}
.zc-summary-bar.is-visible {
    transform: none;
}
.zc-summary-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.zc-summary-label {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.zc-summary-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.zc-summary-bar.is-due .zc-summary-amount {
    color: #975a16;
}
.zc-summary-sub {
    font-size: 0.78rem;
    color: #718096;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.zc-summary-btn {
    flex: 0 0 auto;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
}

@media (max-width: 1279px) {
    .zc-summary-bar {
        display: flex;
    }
    /* Keep the last content clear of the fixed bar */
    body.zc-has-summary-bar .page-shell {
        padding-bottom: 76px;
    }
}

@media print {
    .zc-summary-bar {
        display: none !important;
    }
}

/* ---------- Desktop: answer first ---------- */

@media (min-width: 1280px) {
    /* Put the results card (with Zakat Due) above the nisab gauge and the
       date assistant so the key number is visible without scrolling. */
    .calculator-results.sidebar > #result { order: 1; }
    .calculator-results.sidebar > #nisabIndicatorContainer { order: 2; }
    .calculator-results.sidebar > #dateAssistantContainer { order: 3; }
}

/* ---------- Mobile: tighter intro so inputs start above the fold ---------- */

@media (max-width: 767px) {
    .container > h1 {
        font-size: 1.6rem;
        margin-bottom: 2px;
    }
    .container > .subtitle {
        margin-bottom: 16px;
        font-size: 0.9rem;
    }
    .container > .info-box {
        padding: 10px 12px;
        margin-bottom: 12px;
        font-size: 0.9rem;
        line-height: 1.45;
    }
    .container > .cadence-banner {
        padding: 8px 12px;
        margin-bottom: 16px;
        font-size: 0.88rem;
    }
    .container > .cadence-banner .cadence-note {
        display: none;
    }
}

/* ---------- Phone: rows never clip off the right edge ---------- */

@media (max-width: 600px) {
    .asset-row .group-name {
        flex: 1 1 100%;
    }
    /* Amount + currency share a full-width line */
    .asset-row .group-middle {
        flex: 1 1 100%;
        min-width: 0;
    }
    .asset-row .group-middle > input.input-amount,
    .asset-row .group-middle > input.input-weight {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
        min-width: 0;
    }
    .asset-row .group-middle .currency-autocomplete.currency-autocomplete,
    .asset-row .group-middle .currency-autocomplete.currency-compact {
        flex: 0 0 120px;
        width: 120px;
        max-width: 120px;
        min-width: 0;
    }
    .asset-row .group-middle-secondary {
        flex: 0 1 auto;
        min-width: 0;
    }
}

/* ---------- Pricing data-quality warning ---------- */

.pricing-warning {
    background: #fffaf0;
    border-left: 4px solid #dd6b20;
    border-radius: 0 8px 8px 0;
    padding: 10px 14px;
    margin-bottom: 16px;
    color: #7b341e;
    font-size: 0.9rem;
    line-height: 1.45;
}
.pricing-warning[hidden] {
    display: none;
}
.pricing-warning p + p {
    margin-top: 6px;
}

/* ---------- Ramadan countdown banner ---------- */

.ramadan-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -8px 0 18px;
    padding: 10px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
    color: #f7fafc;
    text-decoration: none;
    font-size: 0.92rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.18);
}
.ramadan-banner:hover {
    filter: brightness(1.06);
}
.ramadan-banner-icon {
    font-size: 1.5rem;
    color: #f6e05e;
    flex: 0 0 auto;
}
.ramadan-banner-text {
    flex: 1 1 auto;
    min-width: 0;
}
.ramadan-banner-text strong {
    color: #fefcbf;
}
.ramadan-banner-cta {
    flex: 0 0 auto;
    font-weight: 700;
    color: #f6e05e;
    white-space: nowrap;
}
@media (max-width: 600px) {
    .ramadan-banner {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 6px 10px;
        align-items: start;
        font-size: 0.86rem;
    }
    .ramadan-banner-icon {
        font-size: 1.25rem;
        line-height: 1.2;
    }
    .ramadan-banner-cta {
        grid-column: 2;
    }
}
@media print {
    .ramadan-banner { display: none; }
}

/* ---------- French: longer option labels ("Argent", "Platine") ---------- */

html[lang="fr"] .asset-row .input-metal {
    min-width: 100px;
}
