/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ff6b6b;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background-color: #51cf66;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.card h2 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

.btn-large {
    padding: 15px 30px;
    font-size: 16px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Market Info */
.market-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.symbol-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.symbol-selector label {
    font-weight: 500;
}

.symbol-selector select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.price-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.price-item .label {
    font-weight: 500;
    color: #6c757d;
}

.price-item .value {
    font-weight: 600;
    color: #495057;
}

/* AI Section */
.ai-section {
    text-align: center;
}

.recommendation-result {
    margin-top: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.recommendation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.action {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
}

.action.buy {
    background-color: #28a745;
}

.action.sell {
    background-color: #dc3545;
}

.action.hold {
    background-color: #6c757d;
}

.action.wait {
    background-color: #ffc107;
    color: #000;
}

.confidence {
    font-size: 1rem;
    font-weight: 500;
    color: #495057;
}

.reasoning {
    text-align: left;
    margin-bottom: 10px;
    line-height: 1.5;
}

.timestamp {
    font-size: 0.9rem;
    color: #6c757d;
    text-align: right;
}

/* Trading Form */
.trade-form {
    max-width: 400px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Table */
.table-container {
    overflow-x: auto;
    margin-top: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

table tr:hover {
    background-color: #f8f9fa;
}

.no-data {
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Statistics */
.statistics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.stat-label {
    font-weight: 500;
    color: #6c757d;
}

.stat-value {
    font-weight: 600;
    color: #495057;
}

/* History Controls */
.history-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    border-top: 1px solid #dee2e6;
    margin-top: 30px;
}

footer a {
    color: #007bff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Position context */
.position-context {
    margin-top: 15px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #28a745;
}

.position-section h4 {
    color: #28a745;
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.position-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.position-text {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #495057;
    margin: 0;
}

.recommendation-context {
    background: #e3f2fd;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #2196f3;
}

.recommendation-context strong {
    color: #1976d2;
    display: block;
    margin-bottom: 8px;
}

.recommendation-context p {
    margin: 0;
    color: #424242;
    font-size: 0.95rem;
}

/* Conversation details */
.conversation-details {
    margin-top: 20px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.conversation-section h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.conversation-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.conversation-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #667eea;
}

.conversation-item h5 {
    color: #495057;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.conversation-item.user-prompt>.conversation-text {
    height: 100%;
}

.conversation-text {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    /* max-height: 200px; */
    /* overflow-y: auto; */
    color: #495057;
}

.conversation-json {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    /* max-height: 300px; */
    /* overflow-y: auto; */
    color: #495057;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .price-display {
        grid-template-columns: 1fr;
    }

    .statistics {
        grid-template-columns: 1fr;
    }

    .symbol-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .recommendation-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .conversation-details {
        padding: 15px;
    }

    .conversation-item {
        padding: 12px;
    }

    .conversation-text,
    .conversation-json {
        font-size: 0.8rem;
        padding: 10px;
        /* max-height: 150px; */
    }

    .position-context {
        padding: 15px;
    }

    .position-text {
        font-size: 0.8rem;
        padding: 10px;
    }

    .recommendation-context {
        padding: 12px;
    }
}

/* Navigation */
.nav {
    background: white;
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: #f8f9fa;
    color: #007bff;
}

.nav-link.active {
    background: #007bff;
    color: white;
}

/* Account Section */
.account-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.account-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.account-balance,
.account-positions {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.account-balance h3,
.account-positions h3 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

.balance-list,
.positions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.balance-item,
.position-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    font-size: 0.9rem;
}

.balance-item .currency,
.position-item .symbol {
    font-weight: 600;
    color: #495057;
    min-width: 60px;
}

.balance-item .amount,
.position-item .amount {
    font-family: 'Courier New', monospace;
    color: #212529;
    font-weight: 500;
}

.balance-item .status {
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.balance-item .status.available {
    background-color: #d4edda;
    color: #155724;
}

.balance-item .status.used {
    background-color: #f8d7da;
    color: #721c24;
}

.position-item .side {
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    min-width: 50px;
    text-align: center;
}

.position-item .side.long {
    background-color: #d4edda;
    color: #155724;
}

.position-item .side.short {
    background-color: #f8d7da;
    color: #721c24;
}

.position-item .pnl {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    min-width: 80px;
    text-align: right;
}

.position-item .pnl.positive {
    color: #28a745;
}

.position-item .pnl.negative {
    color: #dc3545;
}

/* Responsive Account Section */
@media (max-width: 768px) {
    .account-controls {
        flex-direction: column;
    }

    .balance-item,
    .position-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .balance-item .currency,
    .position-item .symbol {
        min-width: auto;
    }

    .position-item .pnl {
        text-align: left;
        min-width: auto;
    }
}

/* AI Decisions Section */
.ai-decisions-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.decisions-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.decisions-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #007bff;
}

.tab-btn.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.tab-content {
    display: none;
}

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

.decisions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.decision-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #007bff;
}

.decision-item.bullish {
    border-left-color: #28a745;
}

.decision-item.bearish {
    border-left-color: #dc3545;
}

.decision-item.neutral {
    border-left-color: #ffc107;
}

.decision-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.decision-stance {
    font-weight: 600;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.decision-stance.bullish {
    color: #28a745;
}

.decision-stance.bearish {
    color: #dc3545;
}

.decision-stance.neutral {
    color: #ffc107;
}

.decision-confidence {
    font-size: 0.9rem;
    color: #6c757d;
}

.decision-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.decision-reasoning {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #495057;
}

.decision-conditions {
    background: white;
    border-radius: 6px;
    padding: 10px;
}

.decision-conditions h5 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #6c757d;
}

.decision-conditions ul {
    margin: 0;
    padding-left: 20px;
}

.decision-conditions li {
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 4px;
}

.decision-market {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    background: white;
    border-radius: 6px;
    padding: 10px;
}

.market-stat {
    display: flex;
    flex-direction: column;
}

.market-stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 2px;
}

.market-stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
}

.decision-timestamp {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: right;
}

/* Decision Log specific styles */
.log-item {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.log-change {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 6px;
}

.log-change-arrow {
    font-size: 1.5rem;
    color: #6c757d;
}

.log-stance {
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.log-stance.bullish {
    background: #d4edda;
    color: #155724;
}

.log-stance.bearish {
    background: #f8d7da;
    color: #721c24;
}

.log-stance.neutral {
    background: #fff3cd;
    color: #856404;
}

.log-reason {
    font-size: 0.9rem;
    font-style: italic;
    color: #6c757d;
    margin-bottom: 10px;
}

/* Responsive AI Decisions */
@media (max-width: 768px) {
    .decisions-controls {
        flex-direction: column;
    }

    .decisions-tabs {
        flex-direction: column;
    }

    .decision-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .decision-market {
        grid-template-columns: 1fr 1fr;
    }

    .log-change {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================ */
/* PENDING TRADES STYLES */
/* ============================================ */

.pending-trades-section {
    margin-top: 15px;
}

.pending-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.pending-trades-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pending-trade-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #6c757d;
    transition: all 0.3s ease;
}

.pending-trade-item.pending {
    border-left-color: #ffc107;
}

.pending-trade-item.confirmed {
    border-left-color: #17a2b8;
}

.pending-trade-item.executed {
    border-left-color: #28a745;
}

.pending-trade-item.rejected {
    border-left-color: #dc3545;
}

.pending-trade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.trade-symbol-action {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trade-symbol {
    font-weight: bold;
    font-size: 1.1em;
    color: #2c3e50;
}

.trade-action {
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
}

.trade-action.buy {
    background-color: #d4edda;
    color: #155724;
}

.trade-action.sell {
    background-color: #f8d7da;
    color: #721c24;
}

.status {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

.status.pending {
    background-color: #fff3cd;
    color: #856404;
}

.status.confirmed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status.executed {
    background-color: #d4edda;
    color: #155724;
}

.status.rejected {
    background-color: #f8d7da;
    color: #721c24;
}

.status.expired {
    background-color: #e2e3e5;
    color: #383d41;
}

.pending-trade-body {
    margin-bottom: 15px;
}

.trade-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 6px;
}

.trade-info div {
    font-size: 0.9em;
}

.trade-target {
    display: inline-block;
    margin-right: 15px;
    padding: 5px 10px;
    background: #e7f3ff;
    border-radius: 4px;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.trade-target.stop-loss {
    background: #ffe7e7;
    color: #c00;
}

.trade-reasoning {
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-left: 3px solid #007bff;
    border-radius: 4px;
    font-size: 0.95em;
    line-height: 1.5;
}

.trade-conditions {
    margin: 10px 0;
    padding: 10px;
    background: #fff9e6;
    border-radius: 4px;
}

.trade-conditions ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

.trade-conditions li {
    font-size: 0.9em;
    margin: 3px 0;
}

.execution-info {
    margin: 10px 0;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 4px;
    font-size: 0.9em;
}

.trade-timestamps {
    margin-top: 10px;
    color: #6c757d;
    font-size: 0.85em;
}

.pending-trade-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

.btn-success {
    background-color: #28a745;
    color: white;
    border: none;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Recommendation Targets */
.recommendation-targets {
    margin: 15px 0;
}

.recommendation-targets .targets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.recommendation-targets .target {
    padding: 8px 12px;
    background: #e7f3ff;
    border-radius: 6px;
    font-size: 0.9em;
}

.recommendation-targets .target.stop-loss {
    background: #ffe7e7;
}

.recommendation-targets .conditions {
    margin-top: 10px;
    padding: 10px;
    background: #fff9e6;
    border-radius: 6px;
}

.recommendation-targets .conditions ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

.recommendation-targets .conditions li {
    font-size: 0.9em;
    margin: 3px 0;
}

.recommendation-actions {
    margin-top: 15px;
}
/* Open Orders Section */
.account-open-orders {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.account-open-orders h3 {
    display: inline-block;
    margin-right: 15px;
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.order-type {
    font-weight: bold;
    min-width: 120px;
}

.order-type.stop {
    color: #dc3545;
}

.order-type.take-profit {
    color: #28a745;
}

.order-symbol {
    color: #666;
    min-width: 100px;
}

.order-side {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.order-side.sell {
    background-color: #fee;
    color: #dc3545;
}

.order-side.buy {
    background-color: #efe;
    color: #28a745;
}

.order-amount {
    font-family: monospace;
    min-width: 120px;
    text-align: right;
}

.order-status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    text-transform: uppercase;
    min-width: 80px;
    text-align: center;
}

.order-status.open {
    background-color: #fff3cd;
    color: #856404;
}

.order-status.filled {
    background-color: #d4edda;
    color: #155724;
}

.order-status.canceled {
    background-color: #f8d7da;
    color: #721c24;
}
