/* Arzpaya Plugin Trade - Persian Trading Interface */

.arzpaya-trade-widget {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    font-family: IRANSansWeb, sans-serif;
    direction: rtl;
    max-width: 400px;
}

/* Trade Buttons */
.trade-buttons {
    display: flex;
    width: 100%;
    margin-bottom: 20px;
    position: relative;
}

.buy-btn,
.sell-btn {
    flex: 1;
    height: 40px;
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    font-family: IRANSansWeb, sans-serif;
}

.buy-btn {
    background: #93b1ff;
    color: white;
    border-radius: 8px;
    margin-left: 10px;
    transition: background 0.2s ease;
}

.buy-btn.active {
    background: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.sell-btn {
    background: #f87171; /* قرمز روشن‌تر از active */
    color: white;
    border-radius: 8px;
    margin-right: 10px;
    transition: background 0.2s ease;
}

.sell-btn.active {
    background: #dc2626; /* رنگ اصلی اکتیو */
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}


/* Trade Form */
.trade-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.input-section {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px;
    background: transparent;
    transition: border-color 0.3s ease;
}

.input-section:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.amount-input-container {
    flex: 1;
    position: relative;
}

.amount-input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    padding: 8px 16px;
    text-align: right;
    color: #374151;
    font-family: IRANSansWeb, sans-serif;
}

.amount-input::placeholder {
    color: #9ca3af;
    font-size: 12px;
}

.currency-selector {
    flex-shrink: 0;
    border-right: 1px solid #d1d5db;
    padding-right: 12px;
    margin-right: auto;
    position: relative;
}

.currency-display {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.currency-display:hover {
    background-color: #f3f4f6;
}

.currency-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.currency-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.currency-name {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-transform: uppercase;
}

.dropdown-arrow {
    font-size: 10px;
    color: #6b7280;
    transition: transform 0.2s ease;
    margin-right: 4px;
}

.currency-selector.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Currency Dropdown */
.currency-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: -10px;
    width: 114px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: 4px;
}

/* Crypto Currency Dropdown - Same positioning as fiat dropdown, slightly more to the left */
.crypto-currency-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0px;
    width: 114px;
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: 4px;
    margin-right: -5px; /* Move slightly more to the left */
    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* Custom scrollbar for crypto currency dropdown (Webkit browsers) */
.crypto-currency-dropdown::-webkit-scrollbar {
    width: 6px;
}

.crypto-currency-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.crypto-currency-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.crypto-currency-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.currency-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.currency-option:last-child {
    border-bottom: none;
}

.currency-option:hover {
    background-color: #f9fafb;
}

.currency-option:first-child {
    border-radius: 8px 8px 0 0;
}

.currency-option:last-child {
    border-radius: 0 0 8px 8px;
}

.currency-option .currency-icon {
    width: 20px;
    height: 20px;
}

.currency-text {
    font-size: 14px;
    color: #374151;
    font-weight: 400;
}

/* Smaller font and spacing for crypto currency dropdown */
.crypto-currency-option {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    gap: 6px;
}

.crypto-currency-option .currency-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.crypto-currency-option .currency-text {
    font-size: 12px;
    line-height: 1.4;
}

/* Static Currency Display (for second input) */
.currency-display-static {
    flex-shrink: 0;
    border-right: 1px solid #d1d5db;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
}

.currency-display-static .currency-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.currency-display-static .currency-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.currency-display-static .currency-name {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-transform: uppercase;
}

/* Price Display */
.price-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.price-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: #e4f1ff;
    z-index: 0;
}

.price-display.progress-active::before {
    width: 100%;
    transition: width linear var(--progress-duration, 30s);
}

.price-display > * {
    position: relative;
    z-index: 1;
}


.price-label {
    display: flex;
    justify-content: start;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}

.price-value {
    display: flex;
    justify-content: end;
    align-items: center;
    gap: 8px;
}

.price-value .currency {
    font-size: 14px;
    color: #6b7280;
    text-transform: uppercase;
}

.price-value .amount {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

/* Trade Action Button */
.trade-action-btn {
    width: 100%;
    height: 40px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 16px;
    font-family: IRANSansWeb, sans-serif;
}

.trade-action-btn.buy-mode {
    background: var(--accent-primary); /* Blue for buy mode */
}

.trade-action-btn.buy-mode:hover {
    background: #2f5cda;
    transform: translateY(-1px);
}

.trade-action-btn.sell-mode {
    background: #dc2626; /* Red for sell mode */
}

.trade-action-btn.sell-mode:hover {
    background: #bc2020;
    transform: translateY(-1px);
}

.trade-action-btn:active {
    transform: translateY(0);
}

.trade-action-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Last Updated */
.last-updated {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.last-updated small {
    color: #9ca3af;
    font-size: 12px;
}

/* Loading State */
.arzpaya-trade-widget.loading .amount {
    color: #9ca3af;
    font-style: italic;
}

/* Animation for value updates */
.amount {
    transition: color 0.3s ease;
}

.amount.updated {
    color: #10b981;
    animation: highlight 0.5s ease;
}

@keyframes highlight {
    0% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(16, 185, 129, 0.1);
    }

    100% {
        background-color: transparent;
    }
}

/* Dark Theme Styles */
[data-theme="dark"] .arzpaya-trade-widget {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-body);
    box-shadow: var(--shadow-card);
}

/* Dark theme trade buttons */
[data-theme="dark"] .buy-btn {
    background: #4a90e2;
    color: white;
}

[data-theme="dark"] .buy-btn.active {
    background: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(61, 114, 254, 0.3);
}

[data-theme="dark"] .sell-btn {
    background: #e74c3c;
    color: white;
}

[data-theme="dark"] .sell-btn.active {
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.3);
}

/* Dark theme input sections */
[data-theme="dark"] .input-section {
    border: 1px solid var(--border-color);
    background: var(--card-bg);
}

[data-theme="dark"] .input-section:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

[data-theme="dark"] .amount-input {
    background: transparent;
    color: var(--text-body);
}

[data-theme="dark"] .amount-input::placeholder {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Dark theme currency selector */
[data-theme="dark"] .currency-selector {
    border-right: 1px solid var(--border-color);
}

[data-theme="dark"] .currency-display:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .currency-icon {
    background: var(--border-color);
}

[data-theme="dark"] .currency-name {
    color: var(--text-body);
}

[data-theme="dark"] .dropdown-arrow {
    color: var(--text-secondary);
}

/* Dark theme currency dropdown */
[data-theme="dark"] .currency-dropdown,
[data-theme="dark"] .crypto-currency-dropdown {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}

/* Dark theme scrollbar for crypto currency dropdown */
[data-theme="dark"] .crypto-currency-dropdown {
    scrollbar-color: rgba(255, 255, 255, 0.3) var(--border-color);
}

[data-theme="dark"] .crypto-currency-dropdown::-webkit-scrollbar-track {
    background: var(--border-color);
}

[data-theme="dark"] .crypto-currency-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .crypto-currency-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .currency-option,
[data-theme="dark"] .crypto-currency-option {
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .currency-option:hover,
[data-theme="dark"] .crypto-currency-option:hover {
    background-color: rgba(61, 114, 254, 0.1);
}

[data-theme="dark"] .currency-text {
    color: var(--text-body);
}

/* Dark theme for crypto currency option */
[data-theme="dark"] .crypto-currency-option .currency-text {
    color: var(--text-body);
}

/* Dark theme static currency display */
[data-theme="dark"] .currency-display-static {
    border-right: 1px solid var(--border-color);
}

[data-theme="dark"] .currency-display-static .currency-icon {
    background: var(--border-color);
}

[data-theme="dark"] .currency-display-static .currency-name {
    color: var(--text-body);
}

/* Dark theme price display */
[data-theme="dark"] .price-display {
    background: var(--border-color);
}

[data-theme="dark"] .price-display::before {
    background: rgba(61, 114, 254, 0.1);
}

[data-theme="dark"] .price-label {
    color: var(--text-secondary);
}

[data-theme="dark"] .price-value .currency {
    color: var(--text-secondary);
}

[data-theme="dark"] .price-value .amount {
    color: var(--text-primary);
}

/* Dark theme trade action button */
[data-theme="dark"] .trade-action-btn {
    background: var(--accent-primary);
    color: white;
}

[data-theme="dark"] .trade-action-btn.buy-mode {
    background: var(--accent-primary);
}

[data-theme="dark"] .trade-action-btn.buy-mode:hover {
    background: #2f5cda;
}

[data-theme="dark"] .trade-action-btn.sell-mode {
    background: #dc2626;
}

[data-theme="dark"] .trade-action-btn.sell-mode:hover {
    background: #bc2020;
}

[data-theme="dark"] .trade-action-btn:disabled {
    background: var(--text-secondary);
}

/* Dark theme last updated */
[data-theme="dark"] .last-updated {
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .last-updated small {
    color: var(--text-secondary);
}

/* Dark theme loading state */
[data-theme="dark"] .arzpaya-trade-widget.loading .amount {
    color: var(--text-secondary);
}

/* Auto dark theme support based on system preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .arzpaya-trade-widget {
        background: #1a2332;
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: #FFFFFF;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }

    :root:not([data-theme="light"]) .buy-btn {
        background: #4a90e2;
        color: white;
    }

    :root:not([data-theme="light"]) .buy-btn.active {
        background: #3D72FE;
        box-shadow: 0 0 0 2px rgba(61, 114, 254, 0.3);
    }

    :root:not([data-theme="light"]) .sell-btn {
        background: #e74c3c;
        color: white;
    }

    :root:not([data-theme="light"]) .sell-btn.active {
        background: #dc2626;
        box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.3);
    }

    :root:not([data-theme="light"]) .input-section {
        border: 1px solid rgba(255, 255, 255, 0.1);
        background: #1a2332;
    }

    :root:not([data-theme="light"]) .input-section:focus-within {
        border-color: #3D72FE;
        box-shadow: 0 0 0 1px #3D72FE;
    }

    :root:not([data-theme="light"]) .amount-input {
        background: transparent;
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]) .amount-input::placeholder {
        color: rgba(255, 255, 255, 0.85);
        font-size: 12px;
    }

    :root:not([data-theme="light"]) .currency-selector {
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .currency-display:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }

    :root:not([data-theme="light"]) .currency-icon {
        background: rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .currency-name {
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]) .dropdown-arrow {
        color: rgba(255, 255, 255, 0.85);
    }

    :root:not([data-theme="light"]) .currency-dropdown,
    :root:not([data-theme="light"]) .crypto-currency-dropdown {
        background: #1a2332;
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }

    /* Auto dark theme scrollbar for crypto currency dropdown */
    :root:not([data-theme="light"]) .crypto-currency-dropdown {
        scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .crypto-currency-dropdown::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .crypto-currency-dropdown::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
    }

    :root:not([data-theme="light"]) .crypto-currency-dropdown::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }

    :root:not([data-theme="light"]) .currency-option,
    :root:not([data-theme="light"]) .crypto-currency-option {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .currency-option:hover,
    :root:not([data-theme="light"]) .crypto-currency-option:hover {
        background-color: rgba(61, 114, 254, 0.1);
    }

    :root:not([data-theme="light"]) .currency-text {
        color: #FFFFFF;
    }

    /* Auto dark theme for crypto currency option */
    :root:not([data-theme="light"]) .crypto-currency-option .currency-text {
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]) .currency-display-static {
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .currency-display-static .currency-icon {
        background: rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .currency-display-static .currency-name {
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]) .price-display {
        background: rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .price-display::before {
        background: rgba(61, 114, 254, 0.1);
    }

    :root:not([data-theme="light"]) .price-label {
        color: rgba(255, 255, 255, 0.85);
    }

    :root:not([data-theme="light"]) .price-value .currency {
        color: rgba(255, 255, 255, 0.85);
    }

    :root:not([data-theme="light"]) .price-value .amount {
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]) .trade-action-btn {
        background: #3D72FE;
        color: white;
    }

    :root:not([data-theme="light"]) .trade-action-btn.buy-mode {
        background: #3D72FE;
    }

    :root:not([data-theme="light"]) .trade-action-btn.buy-mode:hover {
        background: #2f5cda;
    }

    :root:not([data-theme="light"]) .trade-action-btn.sell-mode {
        background: #dc2626;
    }

    :root:not([data-theme="light"]) .trade-action-btn.sell-mode:hover {
        background: #bc2020;
    }

    :root:not([data-theme="light"]) .trade-action-btn:disabled {
        background: rgba(255, 255, 255, 0.85);
    }

    :root:not([data-theme="light"]) .last-updated {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .last-updated small {
        color: rgba(255, 255, 255, 0.85);
    }

    :root:not([data-theme="light"]) .arzpaya-trade-widget.loading .amount {
        color: rgba(255, 255, 255, 0.85);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .arzpaya-trade-widget {
        padding: 16px;
        margin: 16px 0;
    }

    .trade-buttons {
        margin-bottom: 16px;
    }

    .buy-btn,
    .sell-btn {
        height: 36px;
        font-size: 14px;
    }

    .amount-input {
        font-size: 14px;
        padding: 6px 12px;
    }

    .price-value .amount {
        font-size: 16px;
    }

    .trade-action-btn {
        height: 36px;
        font-size: 14px;
    }
}