/* Trade Monitor - Modern Dark Theme CSS */

:root {
    --bg-primary: #020617;
    --bg-secondary: rgba(15, 23, 42, 0.6);
    --bg-card: rgba(30, 41, 59, 0.5);
    --bg-card-hover: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --success: #10b981;
    --success-light: #34d399;
    --danger: #ef4444;
    --danger-light: #f87171;
    --warning: #f59e0b;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-blur: blur(12px);
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        linear-gradient(to bottom, rgba(2, 6, 23, 0.8), rgba(2, 6, 23, 0.95)),
        url('/img/trading-bg.png');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 98%;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2.5rem;
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.back-link {
    display: inline-block;
    color: var(--accent-secondary);
    text-decoration: none;
    margin-bottom: 1rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-primary);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-light);
    border: 1px solid var(--success);
}

.status-badge.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-light);
    border: 1px solid var(--danger);
}

/* Account Grid */
.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.account-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 20px;
    padding: 1.75rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}



.account-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.account-id {
    font-size: 1.5rem;
    font-weight: 700;
}

.account-broker {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.account-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.metric-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1rem;
    font-weight: 600;
}

.profit-positive {
    color: var(--success-light);
}

.profit-negative {
    color: var(--danger-light);
}

.view-details-btn {
    display: block;
    text-align: center;
    padding: 0.75rem;
    background: var(--gradient-primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.view-details-btn:hover {
    opacity: 0.9;
}

/* No Accounts State */
.no-accounts {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.no-accounts-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.no-accounts h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.no-accounts p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.setup-instructions {
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.setup-instructions h3 {
    margin-bottom: 1rem;
    color: var(--accent-secondary);
}

.setup-instructions ol {
    padding-left: 1.5rem;
}

.setup-instructions li {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.setup-instructions code {
    background: var(--bg-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    color: var(--accent-secondary);
}

/* Account Summary */
.account-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.summary-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Trades Section */
.trades-section {
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.trades-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.no-trades {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.trades-table {
    width: auto;
    border-collapse: collapse;
}

.trades-table th,
.trades-table td {
    padding: 0.5rem 0.5rem;
    /* Reduced from 1rem */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.trades-table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    /* Slightly smaller */
    letter-spacing: 0.5px;
}

.trades-table tbody tr:hover {
    background: var(--bg-card);
}

.trade-type {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.trade-type.buy {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-light);
}

.trade-type.sell {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-light);
}

/* History Summary */
.history-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.history-summary span {
    color: var(--text-secondary);
}

.history-summary strong {
    color: var(--text-primary);
}

/* Magic Charts */
.magic-charts #magic-charts-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.chart-title {
    color: var(--accent-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chart-container {
    position: relative;
    height: 220px;
}

/* Chart Fullscreen Modal */
.chart-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.chart-modal.visible {
    display: flex;
}

.chart-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 2rem;
    width: 95vw;
    height: 90vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.chart-modal-close:hover {
    background: var(--danger);
}

.chart-modal-title {
    color: var(--accent-secondary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-right: 3rem;
}

.chart-modal-canvas-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
}


/* Pagination */
.paginated-table-wrapper {
    position: relative;
}

.pagination-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.page-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.page-btn:hover:not(.disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.page-btn.disabled {
    opacity: 0.3;
    cursor: default;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 180px;
    text-align: center;
}

/* Admin Table */
.admin-table-container {
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.admin-table {
    width: auto;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.5rem 0.5rem;
    /* Reduced from 1rem */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.admin-table tbody tr:hover {
    background: var(--bg-card);
}

.account-link {
    color: var(--accent-secondary);
    text-decoration: none;
    font-weight: 600;
}

.account-link:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.admin-nav {
    text-align: center;
    margin: 2rem 0;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--accent-secondary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .stats-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .account-grid {
        grid-template-columns: 1fr;
    }

    .account-metrics {
        grid-template-columns: 1fr;
    }

    .trades-table {
        font-size: 0.85rem;
    }

    .trades-table th,
    .trades-table td {
        padding: 0.5rem;
    }

    .magic-charts #magic-charts-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    .magic-charts #magic-charts-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Account Edit Features */
.account-name {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    font-weight: 500;
}

.account-type-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.account-type-badge.demo {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.account-type-badge.real {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-primary);
}

.edit-icon {
    margin-left: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.edit-icon:hover {
    opacity: 1;
}


/* Interactive Stats */
.stat.interactive {
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.stat.interactive:hover {
    transform: translateY(-2px);
    background: var(--bg-card);
    border-radius: 8px;
    /* Optional: if stat doesn't have border-radius */
}

/* Mini Badges for Table */
.badge-mini {
    display: inline-block;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 4px;
    line-height: 1;
    vertical-align: text-top;
}

.badge-mini.demo {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.badge-mini.real {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-primary);
}

/* Layout Editing Styles */
/* Dashboard Sections */
.dashboard-section {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.section-title.editable:hover {
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: underline;
}

.add-section-btn {
    background-color: transparent;
    border: 2px dashed var(--accent-secondary);
    color: var(--accent-secondary);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.add-section-btn:hover {
    background-color: rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.icon-btn.delete-section-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.icon-btn.delete-section-btn:hover {
    opacity: 1;
}

/* Remove old divider if still present in CSS but not HTML */
.section-divider {
    display: none;
}

.drop-zone {
    min-height: 100px;
    background: rgba(255, 255, 255, 0.01);
    border-radius: 12px;
    transition: background 0.2s;
}

.drop-zone.drag-over {
    background: rgba(99, 102, 241, 0.05);
    border: 2px dashed var(--accent-primary);
}

.account-card.draggable {
    cursor: grab;
    user-select: none;
    /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.account-card.draggable * {
    pointer-events: none;
    /* Ensure drag event bubbles to card */
}

.account-card.draggable .edit-icon {
    pointer-events: auto;
    /* Allow clicking the edit icon */
    cursor: pointer;
}

.account-card.draggable:active {
    cursor: grabbing;
}

.account-card.over {
    border: 2px dashed var(--accent-primary) !important;
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Edit Mode Visuals */
body.edit-mode-active {
    background-color: #2a2a40;
    /* Slightly lighter/different bg to indicate mode */
    border: 4px solid var(--accent-primary);
    /* Border around the whole page to be very obvious */
}

body.edit-mode-active .account-grid {
    background-color: rgba(99, 102, 241, 0.05);
    /* Highlight grid areas */
    border-radius: 8px;
}

.account-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.edit-layout-btn,
.save-layout-btn {
    margin-left: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.edit-layout-btn:hover,
.save-layout-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.save-layout-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    font-weight: bold;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: var(--shadow);
    animation: slideDown 0.3s;
}

.close-modal {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-primary);
}

.save-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.save-btn:hover {
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Warning Pulse Animation for Unsynced Real Accounts */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        border-color: rgba(239, 68, 68, 1);
        background-color: rgba(239, 68, 68, 0.1);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
        border-color: rgba(239, 68, 68, 0.5);
        background-color: rgba(239, 68, 68, 0.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        border-color: rgba(239, 68, 68, 1);
        background-color: rgba(239, 68, 68, 0.1);
    }
}

.warning-pulse {
    animation: pulse-red 1.5s infinite;
    border: 2px solid var(--danger) !important;
}

.warning-icon {
    color: var(--danger);
    font-size: 1.2rem;
    vertical-align: middle;
    margin-left: 5px;
}

.check-icon {
    color: var(--success);
    font-size: 1.2rem;
    vertical-align: middle;
    margin-left: 5px;
}

/* Global Warning Banner */
.global-warning-banner {
    background-color: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--danger);
    color: #ffcccc;
    padding: 1rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    animation: pulse-border 2s infinite;
}

.global-warning-icon {
    font-size: 2rem;
}

@keyframes pulse-border {
    0% {
        border-color: rgba(239, 68, 68, 0.5);
    }

    50% {
        border-color: rgba(239, 68, 68, 1);
    }

    100% {
        border-color: rgba(239, 68, 68, 0.5);
    }
}

/* Compact View Styles */
.compact-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.compact-table th,
.compact-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.compact-table th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.compact-table tr:last-child td {
    border-bottom: none;
}

.compact-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.compact-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.online {
    background-color: var(--success);
    box-shadow: 0 0 5px var(--success);
}

.status-dot.offline {
    background-color: var(--danger);
}

.view-toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-toggle-btn:hover {
    border-color: var(--accent-secondary);
    color: var(--text-primary);
}