/* ═══════════════════════════════════════════════════════════════════
   Currency Calculator – App Styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Theme variables ────────────────────────────────────────────── */
:root,
[data-bs-theme="light"] {
    --cc-bg: #f0f2f5;
    --cc-surface: #ffffff;
    --cc-surface-hover: #f8f9fa;
    --cc-border: #e0e0e0;
    --cc-text: #1a1a1a;
    --cc-text-secondary: #6c757d;
    --cc-accent: #3b82f6;
    --cc-accent-soft: rgba(59, 130, 246, 0.08);
    --cc-danger: #ef4444;
    --cc-shadow: 0 1px 3px rgba(0,0,0,.06);
    --cc-shadow-active: 0 0 0 2px var(--cc-accent-soft), 0 1px 4px rgba(59,130,246,.12);
}

[data-bs-theme="dark"] {
    --cc-bg: #0f1117;
    --cc-surface: #1a1d27;
    --cc-surface-hover: #22252f;
    --cc-border: #2a2d3a;
    --cc-text: #e4e4e7;
    --cc-text-secondary: #9ca3af;
    --cc-accent: #60a5fa;
    --cc-accent-soft: rgba(96, 165, 250, 0.1);
    --cc-danger: #f87171;
    --cc-shadow: 0 1px 3px rgba(0,0,0,.2);
    --cc-shadow-active: 0 0 0 2px var(--cc-accent-soft), 0 1px 4px rgba(96,165,250,.15);
}

/* ── Base ────────────────────────────────────────────────────────── */
html, body {
    font-family: Inter, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--cc-bg);
    color: var(--cc-text);
    -webkit-font-smoothing: antialiased;
}

h1:focus { outline: none; }

/* ── Header ─────────────────────────────────────────────────────── */
.app-header {
    background: var(--cc-surface);
    border-bottom: 1px solid var(--cc-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.app-header .header-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
}

.header-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--cc-text-secondary);
    cursor: pointer;
    transition: background .15s, color .15s;
    font-size: 1.1rem;
    padding: 0;
}

.header-btn:hover {
    background: var(--cc-accent-soft);
    color: var(--cc-accent);
}

/* ── Currency row card ──────────────────────────────────────────── */
.cc-row {
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: 14px;
    padding: .65rem .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    transition: box-shadow .15s, border-color .15s;
    box-shadow: var(--cc-shadow);
    position: relative;
}

.cc-row.is-active {
    border-color: var(--cc-accent);
    box-shadow: var(--cc-shadow-active);
}

.cc-row .currency-flag {
    width: 28px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

.cc-row .currency-icon-crypto {
    font-size: 1.45rem;
    line-height: 1;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    font-weight: 700;
    color: var(--cc-accent);
}

.cc-row .currency-info {
    flex-shrink: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.cc-row .currency-name {
    font-size: .72rem;
    color: var(--cc-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-row .currency-code {
    font-weight: 700;
    font-size: .88rem;
    cursor: pointer;
}

.cc-row .currency-code:hover {
    color: var(--cc-accent);
}

.cc-row .amount-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--cc-text);
    font-size: 1.15rem;
    font-weight: 600;
    text-align: right;
    padding: .25rem .35rem;
    font-variant-numeric: tabular-nums;
    outline: none;
}

.cc-row .amount-input:focus {
    outline: none;
}

.cc-row .amount-input::placeholder {
    color: var(--cc-text-secondary);
    opacity: .5;
}

.cc-row .row-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--cc-text-secondary);
    cursor: pointer;
    font-size: .9rem;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s, color .15s;
}

.cc-row .row-btn:hover {
    background: rgba(239,68,68,.1);
    color: var(--cc-danger);
}

.cc-row .row-btn:disabled {
    opacity: .3;
    pointer-events: none;
}

.cc-row .stale-icon {
    color: #f59e0b;
    font-size: .85rem;
    flex-shrink: 0;
}

/* ── Currency selector dropdown overlay ─────────────────────────── */
.cc-selector-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.cc-selector {
    background: var(--cc-surface);
    border-radius: 18px 18px 0 0;
    max-height: 55vh;
    width: 100%;
    max-width: 420px;
    overflow-y: auto;
    padding: .75rem 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.15);
}

@media (min-width: 576px) {
    .cc-selector-backdrop {
        align-items: center;
    }
    .cc-selector {
        border-radius: 18px;
        max-height: 60vh;
    }
}

.cc-selector-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    cursor: pointer;
    transition: background .12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--cc-text);
    font-size: .95rem;
}

.cc-selector-item:hover {
    background: var(--cc-surface-hover);
}

.cc-selector-item .si-flag {
    width: 28px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

.cc-selector-item .si-crypto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    width: 28px;
    color: var(--cc-accent);
}

.cc-selector-item .si-code {
    font-weight: 700;
    min-width: 2.6rem;
}

.cc-selector-item .si-name {
    color: var(--cc-text-secondary);
    font-size: .85rem;
}

/* ── Add-row button ─────────────────────────────────────────────── */
.cc-add-row {
    background: var(--cc-surface);
    border: 2px dashed var(--cc-border);
    border-radius: 14px;
    padding: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--cc-text-secondary);
    transition: border-color .15s, color .15s, background .15s;
    font-size: .9rem;
    gap: .35rem;
}

.cc-add-row:hover {
    border-color: var(--cc-accent);
    color: var(--cc-accent);
    background: var(--cc-accent-soft);
}

.cc-add-row:disabled {
    opacity: .35;
    pointer-events: none;
}

/* ── Footer ──────────────────────────────────────────────────────── */
.cc-footer {
    text-align: center;
    padding: .5rem 0;
}

.cc-footer-info {
    font-size: .78rem;
    color: var(--cc-text-secondary);
}

.cc-footer-info .stale {
    color: var(--cc-danger);
}

.cc-footer-actions {
    display: flex;
    justify-content: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.footer-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
    padding: .3rem .65rem;
    border-radius: 8px;
    border: 1px solid var(--cc-border);
    background: var(--cc-surface);
    color: var(--cc-text-secondary);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.footer-btn:hover {
    border-color: var(--cc-accent);
    color: var(--cc-accent);
}

.footer-btn:disabled {
    opacity: .4;
    pointer-events: none;
}

.footer-btn.refreshing i {
    animation: spin .8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cc-copyright {
    font-size: .7rem;
    color: var(--cc-text-secondary);
    opacity: .6;
}

/* ── Ad slot placeholders ───────────────────────────────────────── */
.cc-ad-slot {
    min-height: 50px;
    background: var(--cc-surface);
    border: 1px dashed var(--cc-border);
    border-radius: 10px;
    margin: .5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    color: var(--cc-text-secondary);
}

/* ── Toast ──────────────────────────────────────────────────────── */
.cc-toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.cc-toast {
    background: var(--cc-surface);
    color: var(--cc-text);
    border: 1px solid var(--cc-border);
    border-radius: 12px;
    padding: .55rem 1.2rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    font-size: .88rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity .25s, transform .25s;
    pointer-events: auto;
    text-align: center;
    max-width: 340px;
}

.cc-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Modal (pure CSS) ───────────────────────────────────────────── */
.cc-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.cc-modal {
    background: var(--cc-surface);
    border-radius: 18px;
    max-width: 400px;
    width: 100%;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    position: relative;
}

.cc-modal h2 {
    font-size: 1.15rem;
    margin-bottom: .75rem;
    font-weight: 700;
}

.cc-modal .close-btn {
    position: absolute;
    top: .75rem;
    right: .75rem;
    background: none;
    border: none;
    color: var(--cc-text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* ── Language menu ───────────────────────────────────────────────── */
.cc-lang-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: 12px;
    padding: .35rem 0;
    min-width: 140px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 310;
}

.cc-lang-menu-item {
    display: block;
    width: 100%;
    padding: .4rem 1rem;
    border: none;
    background: none;
    color: var(--cc-text);
    font-size: .88rem;
    text-align: left;
    cursor: pointer;
    transition: background .12s;
}

.cc-lang-menu-item:hover {
    background: var(--cc-surface-hover);
}

.cc-lang-menu-item.active {
    color: var(--cc-accent);
    font-weight: 600;
}

.cc-lang-backdrop {
    position: fixed;
    inset: 0;
    z-index: 305;
    background: transparent;
}

/* ── Crypto warning icons ───────────────────────────────────────── */
.crypto-warn-stale {
    color: #f59e0b;
    font-size: .82rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform .15s;
}

.crypto-warn-stale:hover {
    transform: scale(1.15);
}

.crypto-warn-volatile {
    color: var(--cc-accent);
    font-size: .82rem;
    flex-shrink: 0;
    cursor: pointer;
    opacity: .6;
    transition: transform .15s, opacity .15s;
}

.crypto-warn-volatile:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* ── About modal variations ─────────────────────────────────────── */
.cc-modal-about {
    max-height: 80vh;
    overflow-y: auto;
}

.cc-modal-sm {
    max-width: 320px;
    padding: 1.25rem;
}

.about-text {
    font-size: .88rem;
    color: var(--cc-text-secondary);
    line-height: 1.55;
    margin-bottom: .75rem;
}

.about-section-title {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--cc-text-secondary);
    margin: .85rem 0 .4rem;
    padding-bottom: .25rem;
    border-bottom: 1px solid var(--cc-border);
}

.about-list {
    font-size: .88rem;
    padding-left: 1.1rem;
    margin-bottom: .5rem;
}

.about-list li {
    margin-bottom: .25rem;
}

.about-list a {
    color: var(--cc-accent);
    text-decoration: none;
}

.about-list a:hover {
    text-decoration: underline;
}

.about-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .5rem;
}

.about-tag {
    background: var(--cc-accent-soft);
    color: var(--cc-accent);
    font-size: .78rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 6px;
}

.about-disclaimer {
    font-size: .82rem;
    color: var(--cc-text-secondary);
    padding-left: 1.2rem;
    margin-bottom: .5rem;
    line-height: 1.5;
}

.about-disclaimer li {
    margin-bottom: .2rem;
}

.about-footer {
    border-top: 1px solid var(--cc-border);
    padding-top: .6rem;
    margin-top: .6rem;
    font-size: .84rem;
    color: var(--cc-text-secondary);
}

.about-footer a {
    color: var(--cc-accent);
    text-decoration: none;
}

.about-footer a:hover {
    text-decoration: underline;
}

/* ── Loading / errors ───────────────────────────────────────────── */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after { content: "An error has occurred." }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #3b82f6;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}