/* MT5 Base Styles */
.adminuiux-in-iframe ::-webkit-scrollbar {
  height: 0;
  width: 0;
}

/* CSS Variables for MT5 Theme */
:root {
    --primary-color: #007aff;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #000000;
    --text-secondary: #8e8e93;
    --border-color: #e5e5ea;
    --up-color: #34c759;
    --down-color: #ff3b30;
    --buy-color: #007aff;
    --sell-color: #ff3b30;
}

/* Dark mode variables */
body.dark-mode {
    --primary-color: #0a84ff;
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --border-color: #38383a;
    --up-color: #30d158;
    --down-color: #ff453a;
    --buy-color: #0a84ff;
    --sell-color: #ff453a;
}

/* CSS Variables - ensure they're defined */
:root {
    --primary-color: #007aff;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --buy-color: #0066cc;
    --sell-color: #cc3300;
    --up-color: #00cc00;
    --down-color: #ff3333;
    --input-bg: #f8f8f8;
}

body.dark-mode {
    --primary-color: #0a84ff;
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    --border-color: #3a3a3c;
    --input-bg: #2c2c2e;
}

/* History Page Styles */
.history-tabs {
    display: flex;
    /*background: var(--primary-color);*/
    position: sticky;
    top: 60px; /* Position below header */
    /*z-index: 100;*/
    margin: 0;
    padding: 0;
}

.history-tab {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    /*color: rgba(255, 255, 255, 0.7);*/
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.history-tab.active {
    color: black;
    border-bottom-color: black;
}

.history-tab-content {
    display: none;
    min-height: calc(100vh - 180px);
}

.history-tab-content.active {
    display: block;
}

/* Positions Tab Styles */
.positions-header {
    background: var(--bg-primary);
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.profit-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-item-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-label-bold {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-value-right {
    font-size: 18px;
    font-weight: 700;
    text-align: right;
}

.profit-positive {
    color: var(--up-color);
}

.profit-negative{
    color:
}

.deposit-blue, .balance-blue, .blue-text {
    color: #007aff;
}

body.dark-mode .deposit-blue,
body.dark-mode .balance-blue,
body.dark-mode .blue-text {
    color: #0a84ff;
}

.positions-list-mt5 {
    padding: 0;
}

.position-row-mt5 {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.position-left {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.position-title-row {
    margin-bottom: 4px;
    line-height: 1.3;
}

.position-label-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.position-pair-bold {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.position-comma {
    color: var(--text-primary);
}

.position-trade-type {
    font-size: 15px;
    font-weight: 400;
}

.position-trade-type.buy {
    color: var(--buy-color);
}

.position-trade-type.sell {
    color: var(--sell-color);
}

.position-prices {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
}

.position-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-width: 120px;
}

.position-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.position-profit-value {
    font-size: 16px;
    font-weight: 700;
    text-align: right;
}

.green-profit {
    color: var(--up-color);
}

.red-profit {
    color: var(--down-color);
}

.blue-profit {
    color: #007aff;
}

body.dark-mode .blue-profit {
    color: #0a84ff;
}

/* Orders Tab Styles */
.orders-list-mt5 {
    padding: 0;
}

.order-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.order-main {
    flex: 1;
}

.order-pair-type {
    margin-bottom: 4px;
    line-height: 1.3;
}

.order-pair {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.order-comma {
    color: var(--text-primary);
}

.order-type-text {
    font-size: 15px;
    font-weight: 400;
}

.order-type-text.buy {
    color: var(--buy-color);
}

.order-type-text.sell, .order-type-text.sell-stop {
    color: var(--sell-color);
}

.order-volume {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
}

.order-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.order-datetime {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.order-status {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.orders-summary {
    padding: 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.summary-line {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.summary-line.total {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 6px;
    font-weight: 600;
}

.summary-label {
    color: var(--text-primary);
    font-weight: 400;
}

.summary-count {
    color: var(--primary-color);
    font-weight: 600;
}

/* Deals Tab Styles */
.deals-list-mt5 {
    padding: 0;
}

.deal-row-mt5 {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.deal-left {
    flex: 1;
}

.deal-title-row {
    margin-bottom: 4px;
    line-height: 1.3;
}

.deal-pair-bold {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.deal-comma {
    color: var(--text-primary);
}

.deal-type-text {
    font-size: 15px;
    font-weight: 400;
}

.deal-type-text.buy {
    color: var(--buy-color);
}

.deal-type-text.sell {
    color: var(--sell-color);
}

.deal-direction {
    font-size: 15px;
    font-weight: 400;
    color: var(--text-primary);
}

.deal-volume-price {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
}

.deal-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-width: 100px;
}

.deal-datetime {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.deal-profit-amount {
    font-size: 16px;
    font-weight: 700;
    text-align: right;
    color: var(--up-color);
}

.deals-summary-section {
    padding: 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.summary-balance-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 15px;
}

.summary-balance-row.balance-total {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 6px;
    font-weight: 700;
}

.summary-balance-label {
    color: var(--text-primary);
    font-weight: 400;
}

.summary-balance-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .position-right,
    .order-right,
    .deal-right {
        min-width: 100px;
    }

    .history-tab {
        font-size: 12px;
        padding: 12px 8px;
    }

    .history-tabs {
        top: 56px; /* Adjust for smaller header on mobile */
    }
}

/* Main content adjustments for sidebar layout */
/*.adminuiux-content.has-sidebar {
    padding: 0 !important;
}

.adminuiux-content.has-sidebar .history-tabs {
    margin: 0;
    width: 100%;
}

.adminuiux-content.has-sidebar .history-tab-content {
    width: 100%;
}

.adminuiux-content.has-sidebar .trade-container {
    width: 100%;
    max-width: 100%;
}*/

/* Ensure proper background for content */
.positions-header,
.position-row-mt5,
.order-row,
.deal-row-mt5,
.orders-summary,
.deals-summary-section,
.account-info {
    background: var(--bg-secondary) !important;
}

.position-card {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Trade Page Styles */
.trade-container {
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
}

.account-info {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.account-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.account-label {
    color: var(--text-secondary);
}

.account-value {
    font-weight: 600;
    color: var(--text-primary);
}

.positions-section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.position-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.position-symbol {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 8px;
    display: inline-block;
}

.position-type {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.position-type.buy {
    background: var(--buy-color);
}

.position-type.sell {
    background: var(--sell-color);
}

.position-profit {
    font-size: 20px;
    font-weight: 700;
    text-align: right;
}

.position-profit.positive {
    color: var(--up-color);
}

.position-profit.negative {
    color: var(--down-color);
}

.position-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.detail-item {
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.position-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.action-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

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

.action-btn.close {
    background: var(--sell-color);
    color: white;
    border-color: var(--sell-color);
}

.new-order-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s;
}

.new-order-btn:hover {
    transform: scale(1.05);
}

.new-order-btn:active {
    transform: scale(0.95);
}

/* Empty State Styles */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 14px;
}

/* Input Background Variable */
:root {
    --input-bg: #f8f8f8;
}

body.dark-mode {
    --input-bg: #2c2c2e;
}

/* ============================================
   MT5 CHART PAGE STYLES
   ============================================ */

/* Chart Header */
.chart-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    z-index: 1000;
}

.chart-header-left,
.chart-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.header-icon-btn:hover,
.header-icon-btn:active {
    background: var(--bg-secondary);
}

.header-timeframe-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}

.header-timeframe-btn:hover {
    background: var(--bg-secondary);
}

/* Chart Main Container */
.chart-main {
    margin-top: 50px !important;
    padding: 0 !important;
    background: var(--bg-primary);
}

/* Price Ticker */
.price-ticker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
}

.ticker-left,
.ticker-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ticker-btn {
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ticker-btn:active {
    opacity: 0.8;
}

.sell-btn {
    background: var(--sell-color);
    color: white;
}

.buy-btn {
    background: var(--buy-color);
    color: white;
}

.ticker-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ticker-price {
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

.ticker-volume {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-display {
    width: 60px;
    padding: 6px 20px 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 13px;
    text-align: center;
}

.volume-arrows {
    position: absolute;
    right: 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--text-secondary);
}

.volume-arrows svg {
    width: 10px;
    height: 4px;
}

/* Symbol Info Banner */
.symbol-info-banner {
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.symbol-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.symbol-description {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Chart Canvas Container */
.chart-canvas-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 170px);
    background: var(--bg-primary);
}

#priceChart {
    width: 100%;
    height: 100%;
    display: block;
}

/* Chart Info Overlay */
.chart-info-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    z-index: 10;
    pointer-events: none;
}

.chart-info-overlay div {
    display: flex;
    gap: 8px;
}

/* Chart Orders Overlay */
.chart-orders-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.order-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    display: flex;
    align-items: center;
    pointer-events: all;
    cursor: move;
}

.order-line.buy-order {
    background: var(--buy-color);
}

.order-line.sell-order {
    background: var(--sell-color);
}

.order-line.tp-order {
    background: #34c759;
}

.order-line.sl-order {
    background: #ff3b30;
}

.order-label {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    margin-left: 8px;
}

.order-price {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    position: absolute;
    right: 8px;
}

.order-actions {
    position: absolute;
    right: 8px;
    display: flex;
    gap: 4px;
}

.order-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.order-action-btn.delete-btn {
    background: #ff3b30;
    border-color: #ff3b30;
}

.order-action-btn.close-btn {
    background: #ff9500;
    border-color: #ff9500;
}

/* Indicator Subwindow */
.indicator-subwindow {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.indicator-label {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

#indicatorChart {
    width: 100%;
    height: calc(100% - 30px);
    display: block;
}

/* Timeframe Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-body {
    overflow-y: auto;
    padding: 20px;
}

.timeframe-section {
    margin-bottom: 24px;
}

.timeframe-section:last-child {
    margin-bottom: 0;
}

.timeframe-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.timeframe-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.timeframe-option {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.timeframe-option:hover {
    border-color: var(--primary-color);
}

.timeframe-option.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Drawing Toolbar */
.drawing-toolbar {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    z-index: 100;
}

.tool-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tool-btn:first-child {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 50%;
}

.tool-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tool-btn:hover {
    opacity: 0.8;
}

/* Drawing Objects on Chart */
.chart-trendline {
    position: absolute;
    pointer-events: all;
    cursor: move;
}

.trendline-path {
    stroke: #ff3b30;
    stroke-width: 2;
    fill: none;
}

.trendline-handle {
    fill: #ff3b30;
    cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-header {
        height: 44px;
    }

    .chart-main {
        margin-top: 44px !important;
    }

    .chart-canvas-container {
        height: calc(100vh - 154px);
    }

    .header-icon-btn {
        width: 36px;
        height: 36px;
    }

    .timeframe-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}