/* ArzPaya Efficiency Table — frontend styles */

.arzeff {
    --arzeff-border: #e5e7eb;
    --arzeff-head-bg: #f5f6fa;
    --arzeff-head-text: #4b5563;
    --arzeff-cell-bg: #ffffff;
    --arzeff-text: #1f2937;
    --arzeff-muted: #64748b;
    --arzeff-surface: #f8fafc;
    --arzeff-accent: #3d72fe;
    --arzeff-accent-soft: #eff6ff;
    --arzeff-up: #16a34a;
    --arzeff-down: #ef4444;
    --arzeff-neutral: #9ca3af;
    --arzeff-radius: 14px;

    direction: rtl;
    font-family: inherit;
    color: var(--arzeff-text);
    width: 100%;
    box-sizing: border-box;
}

.arzeff *,
.arzeff *::before,
.arzeff *::after {
    box-sizing: border-box;
}

.arzeff-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.arzeff-title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.5;
    color: var(--arzeff-text);
    text-align: start;
}

.arzeff-markets {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    background: var(--arzeff-surface);
    border: 1px solid var(--arzeff-border);
    border-radius: 12px;
    padding: 4px;
}

.arzeff-market-btn {
    border: none;
    background: transparent;
    color: var(--arzeff-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.arzeff-market-btn:hover {
    color: var(--arzeff-accent);
    background: var(--arzeff-accent-soft);
}

.arzeff-market-btn.is-active {
    background: var(--arzeff-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(61, 114, 254, 0.3);
}

.arzeff-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--arzeff-border);
    border-radius: var(--arzeff-radius);
}

.arzeff-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 480px;
}

.arzeff-table th,
.arzeff-table td {
    text-align: center;
    padding: 12px 8px;
    border-inline-start: 1px solid var(--arzeff-border);
}

.arzeff-table th:first-child,
.arzeff-table td:first-child {
    border-inline-start: none;
}

.arzeff-table thead th {
    background: var(--arzeff-head-bg);
    color: var(--arzeff-head-text);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .2px;
}

.arzeff-table tbody td {
    background: var(--arzeff-cell-bg);
    font-size: 14px;
    border-top: 1px solid var(--arzeff-border);
}

.arzeff-val {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    white-space: nowrap;
}

.arzeff-arrow {
    font-size: 10px;
    line-height: 1;
}

.arzeff-up {
    color: var(--arzeff-up);
}

.arzeff-down {
    color: var(--arzeff-down);
}

.arzeff-flat,
.arzeff-neutral {
    color: var(--arzeff-neutral);
}

.arzeff-error {
    direction: rtl;
    padding: 14px 16px;
    border-radius: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .arzeff-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .arzeff-title {
        flex: 1 1 auto;
        min-width: 0;
        text-align: start;
    }

    .arzeff-markets {
        flex-shrink: 0;
        align-self: auto;
    }

    /* Card grid instead of horizontal scroll — 6 timeframes in 3×2 */
    .arzeff-table-wrap {
        overflow: visible;
        border: none;
        border-radius: 0;
        background: transparent;
        /* Prevent outer card borders from clipping on the RTL start edge */
        padding-inline-start: 1px;
    }

    .arzeff-table {
        min-width: 0;
        display: block;
        border-collapse: separate;
        border-spacing: 0;
    }

    .arzeff-table thead {
        display: none;
    }

    .arzeff-table tbody {
        display: block;
    }

    /* Desktop table borders must not leak into the card grid */
    .arzeff-table th,
    .arzeff-table td {
        border-inline-start: none;
        border-top: none;
    }

    .arzeff-table tbody tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        max-width: 100%;
    }

    .arzeff-table tbody td {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 72px;
        min-width: 0;
        padding: 10px 6px;
        border: 1px solid var(--arzeff-border);
        border-radius: 10px;
        background: var(--arzeff-cell-bg);
    }

    /* Override desktop :first-child { border-inline-start: none } (clips RTL outer edge) */
    .arzeff-table tbody td:first-child {
        border: 1px solid var(--arzeff-border);
    }

    .arzeff-table tbody td::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 600;
        color: var(--arzeff-head-text);
        line-height: 1.2;
    }
}

@media (max-width: 480px) {
    .arzeff-title {
        font-size: 14px;
    }

    .arzeff-table tbody tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .arzeff-table tbody td {
        min-height: 68px;
        padding: 8px 4px;
    }

    .arzeff-table tbody td::before {
        font-size: 11px;
    }

    .arzeff-val {
        font-size: 13px;
    }
}

/* ------------------------------------------------------------------ */
/* Dark mode — follows the theme ([data-theme="dark"]) + OS fallback   */
/* ------------------------------------------------------------------ */
[data-theme="dark"] .arzeff {
    --arzeff-border: rgba(255, 255, 255, 0.1);
    --arzeff-head-bg: rgba(255, 255, 255, 0.04);
    --arzeff-head-text: rgba(255, 255, 255, 0.72);
    --arzeff-cell-bg: var(--card-bg, #1a2332);
    --arzeff-text: var(--text-body, #ffffff);
    --arzeff-muted: #94a3b8;
    --arzeff-surface: #0f172a;
    --arzeff-accent: #3d72fe;
    --arzeff-accent-soft: rgba(61, 114, 254, 0.18);
    --arzeff-up: #4ade80;
    --arzeff-down: #f87171;
    --arzeff-neutral: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] .arzeff-error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.3);
    color: #fca5a5;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .arzeff {
        --arzeff-border: rgba(255, 255, 255, 0.1);
        --arzeff-head-bg: rgba(255, 255, 255, 0.04);
        --arzeff-head-text: rgba(255, 255, 255, 0.72);
        --arzeff-cell-bg: var(--card-bg, #1a2332);
        --arzeff-text: var(--text-body, #ffffff);
        --arzeff-muted: #94a3b8;
        --arzeff-surface: #0f172a;
        --arzeff-accent: #3d72fe;
        --arzeff-accent-soft: rgba(61, 114, 254, 0.18);
        --arzeff-up: #4ade80;
        --arzeff-down: #f87171;
        --arzeff-neutral: rgba(255, 255, 255, 0.45);
    }

    :root:not([data-theme="light"]) .arzeff-error {
        background: rgba(248, 113, 113, 0.12);
        border-color: rgba(248, 113, 113, 0.3);
        color: #fca5a5;
    }
}
