/* =============================================================================
   ERM Custom Widgets — Main Stylesheet
   Author: Soha Mahmoud
   ============================================================================= */


/* ── Market Tables ──────────────────────────────────────────────────────────── */

.erm-market-widget {
    display: flex;
    justify-content: center;
    /*margin: 30px 0;*/
}

.erm-market-card {
    width: 100%;
    max-width: 100%;
    background: #fff;
    border: 1px solid #e7e7e7;
    /*border-radius: 4px;*/
    padding: 18px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.market_movements { max-width: 100%; }

.erm-market-title {
    margin: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #222;
}

.erm-market-update {
    margin-top: 18px;
    margin-bottom: 14px;
    text-align: right;
    font-size: 10px;
    color: #777;
    border-top: 1px solid #efefef;
    padding-top: 12px;
}

.arab-market-update {
    border: 0 !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.erm-market-table {
    width: 100%;
    border-collapse: collapse;
}

.erm-market-table thead th {
    background: #f3f6f8;
    color: #555;
    font-size: 7px;
    font-weight: 700;
    padding: 10px 4px;
    text-align: right;
    border-bottom: 1px solid #ececec;
}

.erm-market-table tbody td {
    padding: 10px 4px;
    text-align: right;
    font-size: 8px;
    color: #222;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.erm-market-name {
    font-size: 12px;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.erm-market-index  { font-weight: 500; color: #2d2d2d; }
.erm-market-change,
.erm-market-percent { font-weight: 700; }

.erm-market-table .is-positive { color: #2bb673; }
.erm-market-table .is-negative { color: #e46a6a; }

.erm-market-error {
    background: #fff1f1;
    border: 1px solid #f5c2c2;
    color: #c0392b;
    padding: 14px 18px;
    border-radius: 10px;
    text-align: center;
    margin: 20px 0;
}

.erm-market-closed {
    font-size: 13px;
    text-align: center;
    color: #aaa;
    padding: 20px 0;
}

.col-name   { text-align: right !important; }
.col-symbol { text-align: right !important; }

.erm-sector-symbol {
    font-size: 11px;
    color: #888;
    font-weight: 600;
}

.erm-stock-symbol {
    display: block;
    color: #999;
    font-size: 10px;
    margin-top: 2px;
}

.erm-crypto-symbol {
    color: #aaa;
    font-size: 10px;
    margin-right: 4px;
}


/* ── Crypto Icons ───────────────────────────────────────────────────────────── */

.erm-crypto-table .erm-crypto-name {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    color: #2764ff;
}

.erm-crypto-table tbody td,
.erm-crypto-table thead th { padding: 10px 8px; }

.erm-crypto-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 9px;
    background: #111;
    flex-shrink: 0;
}

.erm-crypto-btc { background: #f7931a; }
.erm-crypto-eth { background: #627eea; }
.erm-crypto-ltc { background: #345d9d; }
.erm-crypto-nmc { background: #186c9d; }
.erm-crypto-ppc { background: #3cb054; }
.erm-crypto-ftc { background: #65afff; }
.erm-crypto-frc { background: #888888; }
.erm-crypto-default { background: #444; }

.erm-crypto-name strong { color: #2764ff; }


/* ── DFM Market Statistics ──────────────────────────────────────────────────── */

.erm-dfm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.erm-dfm-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

.erm-dfm-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    background: #fff8e1;
    color: #f57c00;
    border: 1px solid #ffe082;
    font-weight: 600;
}

.erm-dfm-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
    padding: 12px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #eef2f7;
}

.erm-dfm-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 80px;
    text-align: center;
}

.erm-dfm-stat-label {
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
}

.erm-dfm-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: #222;
}

.erm-dfm-section { margin-top: 20px; }

.erm-dfm-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #444;
    border-right: 3px solid #1a73e8;
    padding-right: 8px;
    margin: 0 0 10px 0;
}


/* ── Gainers & Losers Bars ──────────────────────────────────────────────────── */

.erm-gl-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: 20px 0;
    border: 1px solid #efefef;
    border-radius: 4px;
    overflow: hidden;
}

.erm-gl-col { padding: 14px 16px; }
.erm-gl-col:first-child { border-left: 1px solid #efefef; }

.erm-gl-title {
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 14px 0;
    text-align: right;
}

.erm-gl-title--positive { color: #2bb673; }
.erm-gl-title--negative { color: #e46a6a; }

.erm-gl-item { margin-bottom: 14px; }

.erm-gl-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    gap: 8px;
}

.erm-gl-name {
    font-size: 13px;
    font-weight: 600;
    color: #222;
    text-align: right;
    flex: 1;
}

.erm-gl-pct {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.erm-gl-bar-wrap {
    width: 100%;
    background: #f0f0f0;
    border-radius: 2px;
    height: 5px;
    margin-bottom: 3px;
}

.erm-gl-bar {
    height: 5px;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.erm-gl-bar--positive { background: #2bb673; }
.erm-gl-bar--negative { background: #e46a6a; }

.erm-gl-symbol { font-size: 10px; color: #aaa; text-align: left; }


/* ── Tape Ticker ────────────────────────────────────────────────────────────── */

.erm-tape-ticker-wrapper {
    width: 100%;
    overflow: hidden;
    background: #111827;
    color: #fff;
    height: 40px;
    border-top: 1px solid rgba(255,255,255,0.06);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    direction: ltr; /* LTR so scroll goes right → left */
}

.erm-tape-ticker-inner {
    display: flex;
    width: max-content; /* KEY: sized by content = exactly 2 sets */
    animation: erm-tape-scroll 90s linear infinite;
    will-change: transform;
    align-items: center;
    height: 40px;
}

.erm-tape-ticker-wrapper:hover .erm-tape-ticker-inner {
    animation-play-state: paused;
}

/* THE PROVEN ANIMATION:
   -50% of max-content width = exactly one set width
   CSS resets to 0 — copy 2 is in copy 1's position → zero gap */
@keyframes erm-tape-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.erm-tape-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 18px;
    height: 40px;
    white-space: nowrap;
    font-size: 12.5px;
    border-inline-end: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.erm-tape-symbol  { font-size: 10px; color: rgba(255,255,255,0.35); font-weight: 600; }
.erm-tape-name    { font-weight: 600; color: #fff; }
.erm-tape-price   { color: rgba(255,255,255,0.72); }
.erm-tape-arrow,
.erm-tape-change,
.erm-tape-percent { font-size: 11px; }

.erm-tape-ticker-item.is-positive .erm-tape-arrow,
.erm-tape-ticker-item.is-positive .erm-tape-change,
.erm-tape-ticker-item.is-positive .erm-tape-percent { color: #34d399; }

.erm-tape-ticker-item.is-negative .erm-tape-arrow,
.erm-tape-ticker-item.is-negative .erm-tape-change,
.erm-tape-ticker-item.is-negative .erm-tape-percent { color: #f87171; }


/* ── Weather Widget ─────────────────────────────────────────────────────────── */

.erm-weather--inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #333;
    direction: rtl;
    padding: 4px 0;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.erm-weather--inline .erm-weather-icon  { font-size: 18px; line-height: 1; }
.erm-weather--inline .erm-weather-temp  { font-weight: 700; font-size: 14px; color: #222; }
.erm-weather--inline .erm-weather-city  { font-size: 14px; color: #444; font-weight: 500; }

.erm-weather--card {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    direction: rtl;
    min-width: 140px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.erm-weather--card .erm-weather-icon { font-size: 28px; margin-bottom: 4px; }
.erm-weather--card .erm-weather-temp { font-size: 22px; font-weight: 700; color: #1a1a2e; }
.erm-weather--card .erm-weather-city { font-size: 13px; color: #777; font-weight: 500; }


/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
    .erm-market-widget { margin: 0; }
    .erm-market-card   { padding: 14px; }
    .erm-market-title  { font-size: 10px; }
    .erm-market-update { font-size: 10px; }
    .erm-market-table thead th { font-size: 10px; padding: 8px 4px; }
    .erm-market-table tbody td { font-size: 8px; padding: 10px 4px; }
    .erm-market-name   { font-size: 13px; }
    .erm-dfm-stat      { min-width: 60px; }
    .erm-dfm-stat-value { font-size: 13px; }
    .erm-gl-wrapper    { grid-template-columns: 1fr; }
    .erm-gl-col:first-child { border-left: none; border-bottom: 1px solid #efefef; }
}


/* ── Advanced Market Statistics (erm_market_statistics shortcode) ───────────── */

.erm-api-widget {
    direction: rtl;
    font-family: inherit;
    color: #111827;
    margin: 24px 0;
}

.erm-api-widget * { box-sizing: border-box; }

.erm-api-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 10px 24px rgba(15,23,42,0.04);
}

.erm-api-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.erm-api-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
}

.erm-api-updated { color: #6b7280; font-size: 10px; margin-top: 6px; }

.erm-api-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 14px;
    border: 1px solid #fbbf24;
    border-radius: 999px;
    background: #fffbeb;
    color: #f59e0b;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.erm-api-summary {
    display: grid;
    grid-template-columns: repeat(6, minmax(100px, 1fr));
    gap: 0;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 24px;
}

.erm-api-summary-item {
    padding: 16px 14px;
    text-align: center;
    border-left: 1px solid #e5e7eb;
}

.erm-api-summary-item:last-child { border-left: 0; }
.erm-api-label { display: block; color: #8b95a1; font-size: 10px; margin-bottom: 8px; }
.erm-api-value { display: block; color: #111827; font-size: 15px; font-weight: 800; }

.erm-api-sections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.erm-api-section {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 18px;
    min-width: 0;
}

.erm-api-section h3 { margin: 0 0 14px; font-size: 13px; font-weight: 800; }
.erm-api-section.is-up   h3 { color: #10b981; }
.erm-api-section.is-down h3 { color: #ef4444; }

.erm-api-list { display: grid; gap: 14px; }

.erm-api-row { min-width: 0; }

.erm-api-row-main {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    align-items: baseline;
    font-weight: 800;
    color: #111827;
}

.erm-api-row-name   { overflow-wrap: anywhere; }
.erm-api-row-change { color: #334155; white-space: nowrap; }

.erm-api-bar {
    height: 5px;
    background: #eeeeee;
    border-radius: 999px;
    margin: 8px 0 6px;
    overflow: hidden;
}

.erm-api-bar-fill { display: block; height: 100%; border-radius: inherit; }
.erm-api-section.is-up   .erm-api-bar-fill { background: #2fb672; }
.erm-api-section.is-down .erm-api-bar-fill { background: #e85d64; }

.erm-api-symbol { display: block; color: #9ca3af; font-size: 12px; direction: ltr; text-align: left; }

/* Country statistics grid */
.erm-api-country-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 18px;
}

.erm-api-country {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px;
    background: #fff;
}

.erm-api-country h3 { margin: 0 0 4px; font-size: 12px; font-weight: 800; }
.erm-api-country small { display: block; color: #6b7280; margin-bottom: 14px; font-size: 10px; }

.erm-api-country-stat {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid #eef2f7;
    padding: 10px 0;
    font-size: 11px;
}

.erm-api-error,
.erm-api-empty {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    border-radius: 8px;
    padding: 14px 16px;
    direction: rtl;
    font-size: 13px;
}

/* Responsive for advanced stats */
@media (max-width: 900px) {
    .erm-api-summary,
    .erm-api-sections,
    .erm-api-country-grid { grid-template-columns: 1fr; }
    .erm-api-summary-item { border-left: 0; border-bottom: 1px solid #e5e7eb; }
    .erm-api-summary-item:last-child { border-bottom: 0; }
}

@media (max-width: 560px) {
    .erm-api-card { padding: 16px; }
    .erm-api-header { flex-direction: column; }
    .erm-api-title { font-size: 12px; }
    .erm-api-value { font-size: 10px; }
    .erm-api-row-main { font-size: 10px; }
}
