* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0e27;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    -webkit-tap-highlight-color: transparent;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    background: #1a1f3a;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2f4a;
    height: 60px;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
    color: #4fc3f7;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.balance-info {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 14px;
}

.balance-info .separator {
    color: #2a2f4a;
}

.profit {
    padding: 4px 12px;
    background: rgba(76, 175, 80, 0.2);
    border-radius: 4px;
    border: 1px solid rgba(76, 175, 80, 0.5);
}

.profit.negative {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
    color: #f44336;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* Important for flexbox children */
}

/* Order Panel */
.order-panel {
    width: 280px;
    background: #1a1f3a;
    border-right: 1px solid #2a2f4a;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 15px;
    border-bottom: 1px solid #2a2f4a;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.panel-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    color: #8a8fa3;
    font-weight: 500;
}

.form-control {
    background: #0a0e27;
    border: 1px solid #2a2f4a;
    color: #e0e0e0;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: #4fc3f7;
}

.volume-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.volume-buttons {
    display: flex;
    gap: 5px;
}

.btn-volume {
    flex: 1;
    padding: 8px;
    background: #0a0e27;
    border: 1px solid #2a2f4a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-volume:hover {
    background: #14182d;
    border-color: #4fc3f7;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

/* Stop Loss & Take Profit Container */
.sl-tp-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sl-tp-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sl-tp-label {
    font-size: 11px;
    color: #8a8fa3;
    font-weight: 500;
}

.sl-tp-input {
    width: 100%;
    padding: 8px;
    font-size: 13px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-buy, .btn-sell {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-buy:active, .btn-sell:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-buy {
    background: #4caf50;
    color: white;
}

.btn-buy:hover {
    background: #45a049;
}

.btn-sell {
    background: #f44336;
    color: white;
}

.btn-sell:hover {
    background: #da190b;
}

.price-info {
    background: #0a0e27;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #2a2f4a;
}

.price-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.price-row:last-child {
    margin-bottom: 0;
}

.price-row .label {
    color: #8a8fa3;
}

.price-row .value {
    font-weight: 600;
}

/* Chart Container */
.chart-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #14182d;
    min-width: 400px;
    min-height: 0; /* Important for flexbox children */
}

.chart-header {
    padding: 10px 15px;
    border-bottom: 1px solid #2a2f4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-controls {
    display: flex;
    gap: 5px;
}

.btn-chart {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #2a2f4a;
    color: #8a8fa3;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-chart:hover {
    border-color: #4fc3f7;
    color: #4fc3f7;
}

.btn-chart.active {
    background: #4fc3f7;
    border-color: #4fc3f7;
    color: white;
}

.chart-tools {
    display: flex;
    gap: 5px;
}

.btn-tool {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid #2a2f4a;
    color: #8a8fa3;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.btn-tool:hover {
    border-color: #4fc3f7;
    color: #4fc3f7;
}

.btn-tool.active {
    background: #2a2f4a;
    border-color: #4fc3f7;
    color: #4fc3f7;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 400px;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent scrollbars */
}

.chart-loading,
.chart-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.chart-loading .spinner {
    border: 3px solid #2a2f4a;
    border-top: 3px solid #fff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chart-loading p {
    color: #8a8fa3;
    margin: 0;
}

.chart-error p {
    color: #f44336;
    margin: 0;
    font-weight: 600;
}

.hidden { display: none; }

/* Info Panel */
.info-panel {
    width: 320px;
    background: #1a1f3a;
    border-left: 1px solid #2a2f4a;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #2a2f4a;
}

.tab {
    flex: 1;
    padding: 15px;
    background: transparent;
    border: none;
    color: #8a8fa3;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab:hover {
    background: #0a0e27;
}

.tab.active {
    color: #4fc3f7;
    border-bottom: 2px solid #4fc3f7;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.tab-content.hidden {
    display: none;
}

.positions-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.position-item {
    background: #0a0e27;
    border: 1px solid #2a2f4a;
    padding: 12px;
    border-radius: 4px;
    font-size: 13px;
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.position-symbol {
    font-weight: 600;
}

.position-type {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.position-type.buy {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.position-type.sell {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.position-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 12px;
    color: #8a8fa3;
}

.position-value {
    color: #e0e0e0;
}

.position-close {
    background: #f44336;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
    width: 100%;
}

.position-close:hover {
    background: #da190b;
}

.btn-secondary {
    background: #2a2f4a;
    border: 1px solid #3a3f5a;
    color: #e0e0e0;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #3a3f5a;
}

.empty-state {
    text-align: center;
    color: #8a8fa3;
    font-size: 13px;
    margin-top: 40px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1f3a;
}

::-webkit-scrollbar-thumb {
    background: #2a2f4a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3f5a;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .app-header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px;
    }

    .header-center {
        width: 100%;
        order: 3;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #2a2f4a;
    }

    .balance-info {
        flex-direction: column;
        gap: 5px;
        font-size: 12px;
    }

    .separator {
        display: none;
    }

    .main-content {
        flex-direction: column;
    }

    .order-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #2a2f4a;
        max-height: 300px;
    }

    .chart-container {
        min-width: 100%;
    }

    .chart-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .chart-controls,
    .chart-tools {
        flex-wrap: wrap;
        gap: 5px;
    }

    .btn-chart,
    .btn-tool {
        font-size: 11px;
        padding: 4px 8px;
    }

    .info-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #2a2f4a;
        max-height: 250px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-buy,
    .btn-sell {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .panel-content {
        padding: 15px;
    }

    .chart-wrapper {
        min-height: 300px;
    }

    .btn-chart {
        font-size: 10px;
        padding: 3px 6px;
    }

    .btn-tool {
        font-size: 14px;
        padding: 4px 6px;
    }

    h1 {
        font-size: 16px;
    }

    .balance-info {
        font-size: 11px;
    }

    .order-panel,
    .info-panel {
        max-height: 200px;
    }
}

/* Better overflow handling for mobile */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .app-container {
        min-height: 100vh;
    }

    .main-content {
        flex-direction: column;
        overflow-y: auto;
    }

    .chart-container {
        order: 1;
        min-height: 400px;
    }

    .order-panel {
        order: 2;
        max-height: 250px;
    }

    .info-panel {
        order: 3;
        max-height: 250px;
    }
}

/* Touch-friendly improvements for mobile */
@media (hover: none) and (pointer: coarse) {
    .btn-buy,
    .btn-sell,
    .btn-chart,
    .btn-tool,
    .btn-volume,
    .btn-secondary {
        min-height: 44px;
    }

    .position-close {
        min-height: 40px;
    }
}

