/* =====================================================
   GLOBAL PRICES
===================================================== */

.main-tabs-wrapper {
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.main-tabs {
    position: relative;
    display: flex;
    width: 100%;
    padding: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 166, 35, 0.3) transparent;
    background: transparent;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.main-tab-indicator {
    position: absolute;
    top: 6px;
    bottom: 6px;
    right: auto;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 1), inset 0 -1px 0 rgba(255, 255, 255, 0.5);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    overflow: hidden;
}

.main-tab-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 100%);
    border-radius: 14px 14px 0 0;
    pointer-events: none;
}

.main-tab-indicator::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.4) 0%, rgba(255, 200, 150, 0.1) 25%,
            rgba(200, 255, 200, 0.1) 50%, rgba(150, 200, 255, 0.1) 75%,
            rgba(255, 255, 255, 0.4) 100%) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}

.main-tab {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.2rem;
    background: transparent;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
    white-space: nowrap;
}

.main-tab.active {
    color: var(--brand-gold-dark);
}

.main-tab:hover:not(.active) {
    color: var(--text-secondary);
}

.main-tab-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-tab-icon svg {
    width: 20px;
    height: 20px;
}

.main-tab-count {
    padding: 0.12rem 0.45rem;
    background: rgba(245, 166, 35, 0.15);
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--brand-gold-dark);
    transition: background 0.3s, color 0.3s;
}

.main-tab.active .main-tab-count {
    background: rgba(245, 166, 35, 0.25);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sub-chips-wrapper {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 166, 35, 0.2) transparent;
    padding: 1rem 1.25rem 0.9rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 24px 24px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.sub-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: transparent;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 50px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.sub-chip:hover {
    border-color: rgba(245, 166, 35, 0.4);
    color: var(--text-secondary);
    background: rgba(245, 166, 35, 0.04);
}

.sub-chip.active {
    border-color: var(--brand-gold);
    color: var(--brand-gold-dark);
    background: rgba(245, 166, 35, 0.08);
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.15);
}

.sub-chip-icon {
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sub-chip-icon svg {
    width: 14px;
    height: 14px;
}

.sub-chip-count {
    padding: 0.08rem 0.35rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.25s;
}

.sub-chip.active .sub-chip-count {
    background: rgba(245, 166, 35, 0.18);
    color: var(--brand-gold-dark);
}

.sub-panel {
    display: none;
}

.sub-panel.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

.sub-panel.active .table-container {
    border-radius: 0 0 24px 24px;
    border-top: none;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.pair-flags {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    line-height: 1;
}

.pair-flags .flag-top,
.pair-flags .flag-bottom {
    font-size: 1.0rem;
    line-height: 1.25;
    display: block;
}

.table-container {
    position: relative;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.table-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
    pointer-events: none;
    z-index: 1;
    border-radius: 24px 24px 0 0;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: inherit;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 166, 35, 0.3) transparent;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
}

thead {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #faf8f5;
}

th {
    padding: 1rem 0.85rem;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.78rem;
}

th:first-child {
    padding-right: 1.4rem;
}

tbody tr {
    transition: background-color 0.25s;
}

@media (hover: hover) {
    tbody tr:hover {
        background: rgba(245, 166, 35, 0.04);
    }
}

tbody tr.row-active {
    background: rgba(245, 166, 35, 0.06);
}

tbody tr.row-active td:nth-child(2) {
    background: #fdf6ec;
}

tbody tr:last-child td {
    border-bottom: none;
}

td {
    padding: 0.3rem 0.85rem;
    white-space: nowrap;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

td:first-child {
    padding-right: 1.4rem;
}

.row-num {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.82rem;
}

.name-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
}

.name-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.flag {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.item-name {
    font-weight: 600;
    font-size: 0.88rem;
}

.item-name-en {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: system-ui;
    direction: ltr;
    text-align: right;
}

.price-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.mcap-value {
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.28rem 0.55rem;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 600;
    direction: ltr;
}

.change-badge.positive {
    background: rgba(52, 199, 89, 0.1);
    color: var(--accent-green);
}

.change-badge.negative {
    background: rgba(255, 59, 48, 0.1);
    color: var(--accent-red);
}

.change-badge.zero {
    background: rgb(62 112 208 / 10%);
    color: #3c79e1;
}

td[data-key="تغییرات روز"] {
    font-weight: 600;
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

tr:has(td[data-key="تغییر"] .positive) td[data-key="تغییرات روز"] {
    color: var(--accent-green);
    text-align: right;
}

tr:has(td[data-key="تغییر"] .positive) td[data-key="تغییرات روز"]::before {
    content: "+";
}

tr:has(td[data-key="تغییر"] .negative) td[data-key="تغییرات روز"] {
    color: var(--accent-red);
    text-align: right;
}

tr:has(td[data-key="تغییر"] .zero) td[data-key="تغییرات روز"] {
    color: #3c79e1;
    text-align: right;
}

.unit-badge {
    padding: 0.28rem 0.55rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    direction: ltr;
}

.date-cell {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sample-badge {
    padding: 0.3rem 0.75rem;
    background: rgba(245, 166, 35, 0.12);
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--brand-gold-dark);
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.4rem;
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}

.table-footer span {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.footer-updated {
    display: none;
}

.mobile-unit-badge {
    display: none;
}

th:nth-child(2),
td:nth-child(2) {
    position: -webkit-sticky;
    position: sticky;
    right: 0;
    z-index: 6;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

tbody td:nth-child(2) {
    background: #fdfcfa;
    transition: background-color 0.25s;
}

@media (hover: hover) {
    tbody tr:hover td:nth-child(2) {
        background: #fdf8f1;
    }
}

thead th:nth-child(2) {
    z-index: 12;
    background: #faf8f5;
}

.ios-frozen th:nth-child(1),
.ios-frozen td:nth-child(1),
.ios-frozen th:nth-child(2),
.ios-frozen td:nth-child(2) {
    position: static !important;
    z-index: auto !important;
    box-shadow: none !important;
    -webkit-backface-visibility: visible !important;
    backface-visibility: visible !important;
}

.frozen-overlay {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 20;
    overflow: hidden;
    pointer-events: auto;
}

table th:nth-child(1),
table td:nth-child(1),
table th:nth-child(2),
table td:nth-child(2) {
    width: 1px;
    white-space: nowrap;
}

.frozen-overlay table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
    width: auto !important;
    min-width: 0 !important;
}

.frozen-overlay th {
    padding: 0.3rem 0.85rem;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.78rem;
    background: #faf8f5;
}

.frozen-overlay td {
    padding: 0.3rem 0.85rem;
    white-space: nowrap;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    background: #fdfcfa;
}

.frozen-overlay th:first-child,
.frozen-overlay td:first-child {
    padding-right: 1.4rem;
}

.frozen-overlay tbody tr.row-active td {
    background: #fdf6ec;
}

.frozen-overlay tbody tr:last-child td {
    border-bottom: none;
}

@media (max-width: 768px) {
    .main-tab {
        padding: 0.6rem 0.85rem;
        font-size: 0.8rem;
    }

    .sub-chip {
        padding: 0.35rem 0.65rem;
        font-size: 0.72rem;
    }

    .sub-chips-wrapper {
        border-radius: 16px 16px 0 0;
    }

    .sub-panel.active .table-container {
        border-radius: 0 0 16px 16px;
    }

    .table-container {
        border-radius: 16px;
    }

    .table-container::before {
        display: none;
    }

    .table-wrapper {
        overflow-x: visible;
        -webkit-overflow-scrolling: auto;
    }

    .frozen-overlay {
        display: none !important;
    }

    th:nth-child(2),
    td:nth-child(2) {
        position: static !important;
        z-index: auto !important;
        box-shadow: none !important;
    }

    thead th:nth-child(2) {
        box-shadow: none !important;
    }

    tbody td:nth-child(2) {
        box-shadow: none !important;
        background: transparent !important;
    }

    table {
        min-width: 0 !important;
        width: 100% !important;
    }

    thead {
        display: none;
    }

    tbody tr {
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-rows: auto auto;
        align-items: baseline;
        padding: 0.3rem 1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        gap: 0.15rem 0.3rem;
    }

    tbody tr:last-child {
        border-bottom: none;
    }

    tbody td {
        padding: 0;
        border-bottom: none;
        white-space: normal;
        background: transparent !important;
        box-shadow: none !important;
    }

    tbody td:first-child {
        display: none;
    }

    tbody td:nth-child(n+3) {
        display: none;
    }

    tbody td:nth-child(2) {
        display: block;
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: center;
        min-width: 0;
        padding-left: 0.75rem;
    }

    .name-cell {
        gap: 0.5rem;
    }

    .name-text {
        display: block;
    }

    .item-name {
        font-size: 0.95rem;
        font-weight: 700;
        line-height: 1.5;
        margin-left: 0.4rem;
    }

    .item-name-en {
        display: block;
        font-size: 0.72rem;
        margin-top: 0.1rem;
        color: var(--text-muted);
    }

    .mobile-unit-badge {
        display: inline-flex;
        align-items: center;
        padding: 0.08rem 0.4rem;
        border: 1px solid rgba(0, 0, 0, 0.15);
        border-radius: 4px;
        font-size: 0.6rem;
        font-weight: 500;
        color: var(--text-muted);
        direction: ltr;
        line-height: 1.3;
        white-space: nowrap;
        vertical-align: middle;
    }

    tbody td[data-key="قیمت"] {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        grid-column: 2 / 4;
        grid-row: 1;
        font-size: 0.9rem;
        font-weight: 700;
        white-space: nowrap;
        direction: ltr;
    }

    tbody td[data-key="تغییرات روز"] {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        grid-column: 3;
        grid-row: 2;
        font-size: 0.78rem;
        font-weight: 600;
        white-space: nowrap;
        direction: ltr;
    }

    tbody tr:has(td[data-key="تغییر"] .positive) td[data-key="تغییرات روز"] {
        color: var(--accent-green);
    }

    tbody tr:has(td[data-key="تغییر"] .negative) td[data-key="تغییرات روز"] {
        color: var(--accent-red);
    }

    tbody tr:has(td[data-key="تغییر"] .zero) td[data-key="تغییرات روز"] {
        color: #3c79e1;
    }

    tbody td[data-key="تغییر"] {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        grid-column: 2;
        grid-row: 2;
        white-space: nowrap;
        direction: ltr;
    }

    tbody td[data-key="تغییر"] .change-badge {
        padding: 0;
        background: transparent !important;
        border-radius: 0;
        font-size: 0.78rem;
        font-weight: 600;
    }

    tbody td[data-key="تغییر"] .change-badge::before {
        content: "(";
    }

    tbody td[data-key="تغییر"] .change-badge::after {
        content: ")";
    }

    tbody td[data-key="بازده سالانه"] {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        grid-column: 2 / 4;
        grid-row: 1;
        font-size: 0.9rem;
        font-weight: 700;
        white-space: nowrap;
        direction: ltr;
    }

    tbody td[data-key="بازده روزانه"] {
        display: flex !important;
        align-items: center;
        grid-column: 2 / 4;
        grid-row: 2;
        white-space: nowrap;
        direction: ltr;
    }

    tbody td[data-key="روزانه"] .change-badge {
        padding: 0;
        background: transparent !important;
        border-radius: 0;
        font-size: 0.78rem;
        font-weight: 600;
    }

    .flag {
        font-size: 1.2rem;
    }

    .pair-flags .flag-top,
    .pair-flags .flag-bottom {
        font-size: 0.9rem;
    }

    tbody tr.row-active {
        background: rgba(245, 166, 35, 0.06);
    }

    tbody tr.row-active td:nth-child(2) {
        background: transparent !important;
    }

    .table-footer {
        padding: 0.7rem 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .footer-updated {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .footer-updated svg {
        width: 14px;
        height: 14px;
    }
}