/**
 * CMC Currency Cross Rates [cmc_cross_rates]
 * Depends on currencies.css for erm-premium-* base styles.
 */

/* ── Currency pair tabs ──────────────────────────────────────────────────── */
.cmc-cr-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cmc-cr-widget .cmc-cr-tab {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    box-shadow: none;
    outline: none;
    flex: 1;
    justify-content: center;
    min-width: 0;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
}

.cmc-cr-widget .cmc-cr-tab:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.cmc-cr-widget .cmc-cr-tab.active {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
    font-weight: 700;
}

.cmc-cr-widget .cmc-cr-tab.active .cmc-cr-tab-name { color: #2563eb; }

.cmc-cr-flag {
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.cmc-cr-tab-code { font-weight: 700; font-size: 11px; }

/* Hidden in sidebar — too wide; shown only when space allows */
.cmc-cr-tab-name {
    display: none;
}

/* ── Converter boxes ─────────────────────────────────────────────────────── */
.cmc-cr-converter {
    display: flex;
    align-items: stretch;
    gap: 5px;
    margin-bottom: 8px;
}

.cmc-cr-conv-box {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 5px 7px;
    min-width: 0;
    transition: border-color 0.15s;
}

.cmc-cr-conv-box:focus-within {
    border-color: #93c5fd;
    background: #f0f7ff;
}

.cmc-cr-conv-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.cmc-cr-conv-flag {
    width: 16px;
    height: 11px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.10);
}

.cmc-cr-conv-names {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
}

.cmc-cr-conv-code {
    font-size: 10px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
    white-space: nowrap;
}

/* Arabic name hidden in sidebar — too wide */
.cmc-cr-conv-name {
    display: none;
}

.cmc-cr-conv-arrow {
    font-size: 8px;
    color: #94a3b8;
    flex-shrink: 0;
}

.cmc-cr-conv-value {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.cmc-cr-conv-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 13px!important;
    font-weight: 800;
    color: #0f172a;
    font-family: inherit;
    line-height: 1.1!important;;
    outline: none;
    padding: 0;
    -moz-appearance: textfield;
    width: 100%;
    height:23px!important;;
}

.cmc-cr-conv-input::-webkit-outer-spin-button,
.cmc-cr-conv-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cmc-cr-conv-sym {
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}

/* ── Swap button ─────────────────────────────────────────────────────────── */
.cmc-cr-swap-btn {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid #e2e8f0!important;
    border-radius: 50%!important;
    background-color: #fff!important;
    color: #2563eb!important;
    font-size: 13px!important;
    cursor: pointer!important;
    flex-shrink: 0;
    align-self: center;
    transition: background 0.15s, border-color 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    outline: none;
    font-family: inherit;
    line-height: 1;
    padding: 0;
}

.cmc-cr-swap-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

/* Swapped state: visual reorder via flex order */
.cmc-cr-converter--swapped .cmc-cr-conv-box--quote { order: 2; }
.cmc-cr-converter--swapped .cmc-cr-conv-box--base  { order: 0; }
.cmc-cr-converter--swapped .cmc-cr-swap-btn        { order: 1; }

/* ── Rate info lines ─────────────────────────────────────────────────────── */
.cmc-cr-rate-lines {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.cmc-cr-rl {
    font-size: 9px;
    color: #64748b;
    direction: ltr;
    display: inline-block;
}

/* ── Meta bar (date + download) ──────────────────────────────────────────── */
.cmc-cr-conv-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cmc-cr-dl-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.cmc-cr-dl-btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #16a34a!important;;
    border: none;
    border-radius: 4px!important;;
    padding: 3px 7px!important;
    font-size: 9px!important;;
    font-weight: 600!important;;
    color: #fff!important;;
    cursor: pointer;
    font-family: inherit!important;;
    line-height: 1.4;
    outline: none;
    box-shadow: none;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    transition: background 0.15s;
    max-width: 140px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cmc-cr-dl-btn:hover { background: #15803d; }

.cmc-cr-dl-btn svg { flex-shrink: 0; }

.cmc-cr-trending-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    border-radius: 8px;
    background: #dc2626;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.cmc-cr-date-display {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    color: #64748b;
    white-space: nowrap;
}

/* ── Overview section ────────────────────────────────────────────────────── */
.cmc-cr-overview {
    border-top: 1px solid #f1f5f9;
    padding-top: 12px;
    margin-bottom: 0;
}

.cmc-cr-ov-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 4px;
}

.cmc-cr-ov-pair {
    font-size: 11px;
    font-weight: 700;
    color: #1e293b;
}

.cmc-cr-ov-weekly {
    font-size: 10px;
    font-weight: 600;
    direction: ltr;
    display: inline-block;
}

.cmc-cr-ov-weekly--pos { color: #16a34a; }
.cmc-cr-ov-weekly--neg { color: #dc2626; }

.cmc-cr-ov-body {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 10px;
    align-items: start;
    margin-bottom: 10px;
}

.cmc-cr-ov-chart-area { min-width: 0; }

.cmc-cr-ov-chart-lbl {
    font-size: 9px;
    color: #94a3b8;
    margin-bottom: 4px;
    direction: rtl;
}

.cmc-cr-sparkline {
    height: 80px;
    width: 100%;
    overflow: hidden;
}

.cmc-cr-sparkline svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── Stats column ────────────────────────────────────────────────────────── */
.cmc-cr-ov-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cmc-cr-ov-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.cmc-cr-ov-stat-lbl {
    font-size: 9px;
    color: #64748b;
    white-space: nowrap;
}

.cmc-cr-ov-stat-val {
    font-size: 10px;
    font-weight: 700;
    color: #0f172a;
    direction: ltr;
    display: inline-block;
}

.cmc-cr-stat--high { color: #16a34a; }
.cmc-cr-stat--low  { color: #dc2626; }

/* ── Period buttons ──────────────────────────────────────────────────────── */
.cmc-cr-periods {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    direction: rtl;
}

.cmc-cr-widget .cmc-cr-period {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #f8fafc;
    font-size: 9px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
    text-align: center;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    outline: none;
    box-shadow: none;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
}

.cmc-cr-widget .cmc-cr-period:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.cmc-cr-widget .cmc-cr-period.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* ── Footer stats bar ────────────────────────────────────────────────────── */
.cmc-cr-footer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    border-top: 1px solid #f1f5f9;
    padding-top: 10px;
}

.cmc-cr-ft-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
    padding: 6px 4px;
    border-radius: 6px;
    background: #f8fafc;
}

.cmc-cr-ft-label {
    font-size: 8px;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}

.cmc-cr-ft-val {
    font-size: 10px;
    font-weight: 700;
    color: #0f172a;
    direction: ltr;
    display: inline-block;
    white-space: nowrap;
}

/* ── Error ───────────────────────────────────────────────────────────────── */
.cmc-error {
    background: #FFDAD6;
    color: #93000A;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 12px;
    text-align: center;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 340px) {
    .cmc-cr-footer         { grid-template-columns: repeat(2, 1fr); }
    .cmc-cr-ov-body        { grid-template-columns: 1fr; }
    .cmc-cr-conv-input     { font-size: 16px; }
    .cmc-cr-tab-name       { display: none; }
    .cmc-cr-conv-meta      { flex-direction: column; align-items: flex-start; }
}
