:root {
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --background-color: #1a1a1a;
    --surface-color: rgba(30, 30, 30, 0.95);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-amber: #eab308;
    --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: transparent;
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    font-family: var(--font-primary);
    color: var(--text-primary);
}

#background-video {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    z-index: -2;
}

#background-image {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://res.cloudinary.com/dyujm1mtq/image/upload/v1758927315/pexels-alex-andrews-271121-3805983_emskzv.webp');
    background-size: cover;
    background-position: center;
    z-index: -2;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
}

/* Simple Mode Styles */
body.simple-mode #background-video {
    display: none;
}
body.simple-mode #background-image {
    display: block;
}
body.simple-mode #overlay {
    background: rgba(0, 0, 0, 0.1); /* Lighter overlay in simple mode */
}


#matrix-canvas {
    display: none;
}

.container {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Shared Panel/Column Styles --- */
.column, header, .controls {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

h2 {
    margin-bottom: 1rem;
    text-transform: uppercase;
    color: var(--text-primary);
    font-weight: 600;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.8rem;
    margin: 0;
    color: #fff;
    font-weight: 700;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px; /* Spacing between header elements */
}

.status-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    margin-left: 5px;
}

.status-indicator {
    border-radius: 50%;
    width: 15px;
    height: 15px;
}
#status-indicator.disconnected { background-color: #888; }
#status-indicator.connected { background-color: var(--accent-green); }
#status-indicator.error { background-color: var(--accent-red); }

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.settings-menu-container {
    position: relative;
    display: inline-block;
}

#settings-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s ease-in-out;
}

#settings-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.05);
}

.settings-dropdown-content {
    display: none;
    position: absolute;
    background-color: #2a2a2a; /* Darker background for the dropdown */
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.6);
    z-index: 1000;
    right: 0; /* Align to the right of the settings button */
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px 0;
}

.settings-dropdown-content.show {
    display: block;
}

.settings-dropdown-content button,
.settings-dropdown-content label {
    background-color: #444;
    color: #FFF; /* Default text color */
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    width: 100%; /* Make buttons take full width */
    text-align: left;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    box-sizing: border-box; /* Include padding in width */
}

.settings-dropdown-content label {
    cursor: default; /* Not clickable like a button */
}

.settings-dropdown-content button:hover {
    background-color: #555;
}

.settings-dropdown-content hr {
    border: none;
    border-top: 1px solid #555;
    margin: 5px 0;
}

.settings-dropdown-content .toggle-switch {}


/* Global Button Styling (for new buttons that are not in dropdown) */
button:not(#settings-btn):not(.settings-dropdown-content button) {
    background-color: var(--accent-green);
    color: #1a1a1a;
    font-weight: 600;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

button:not(#settings-btn):not(.settings-dropdown-content button):hover {
    background-color: #16a34a; /* Darker green on hover */
}

button {
    /* This is a fall-back for buttons not caught by the more specific rules */
    /* It seems your current file has this, so I'm keeping it to avoid breaking things */
}

button.danger {
    background-color: #8B0000; /* Dark Red */
    border-color: #FF0000; /* Bright Red */
    color: #FFF;
}
button.danger:hover {
    background-color: #FF0000;
    color: #FFF;
}

button:disabled {
    background-color: #333;
    color: #777;
    border-color: #555;
    cursor: not-allowed;
}

button:disabled:hover {
    background-color: #333;
    color: #777;
}

main {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.5rem;
    width: 100%;
}

.column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: 60vh;
}

.table-container {
    overflow-y: auto;
    flex-grow: 1;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tr th {
    position: sticky;
    top: 0;
    background-color: rgba(18, 18, 18, 0.9);
    font-weight: 600;
    color: var(--text-secondary);
}

.log-container {
    font-size: 0.9rem;
    padding: 1rem;
    overflow-y: scroll;
    flex-grow: 1;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    font-family: monospace;
    line-height: 1.4;
    overflow-wrap: break-word;
    word-break: normal;
    user-select: text;
}

.log-entry {
    word-break: break-all; /* This will wrap long log lines */
    padding: 0.25rem 0;
    user-select: text;
}
.log-entry.info { color: #ccc; }
.log-entry.success { color: var(--accent-green); }
.log-entry.warn { color: var(--accent-amber); }
.log-entry.error { color: var(--accent-red); }

.pnl-profit { color: var(--accent-green); font-weight: bold; }
.pnl-loss { color: var(--accent-red); font-weight: bold; }

.stats-and-history-container {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.column.full-width {
    max-height: none; /* Override max-height for bottom sections */
}

.table-header-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

/* --- Toggle Switch --- */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.toggle-switch {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 22px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 22px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s;
}
.toggle-switch::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--text-primary);
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}
.toggle-switch:checked {
    background-color: var(--accent-green);
}
.toggle-switch:checked::before {
    transform: translateX(18px);
}

/* --- Gamified Stats --- */
#stats-container {
    overflow-y: auto;
    flex-grow: 1;
}

.stats-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: flex-start;
}

.stat-item {
    flex: 1 1 200px;
    background-color: rgba(255,255,255,0.05);
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-item-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.stat-item-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.stats-section + .stats-section {
    margin-top: 1.5rem;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    overflow: hidden;
}

tr {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.new-trade {
    animation: fadeInGlow 1s ease-in-out;
}

@keyframes fadeInGlow {
    0% {
        opacity: 0;
        transform: scale(0.95);
        box-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: none;
    }
}

.exiting-trade {
    animation: fadeOutGlow 0.5s ease-in-out forwards;
}

@keyframes fadeOutGlow {
    0% {
        opacity: 1;
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
        box-shadow: none;
    }
}

td.updated {
    animation: bounce 0.4s ease-in-out;
}

@keyframes bounce {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
     }
 }

#wallet-stats-container,
#exit-reason-stats-container {
    margin-top: 2rem;
}

/* New prominent stat for wallet balance */
.prominent-stat {
    flex-basis: calc(50% - 0.5rem);
    background-color: rgba(255,255,255,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-radius: 8px;
}

.prominent-stat .stat-item-label {
    font-size: 1rem;
}

.prominent-stat .stat-item-value {
    font-size: 2.5rem;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; border: 1px solid var(--border-color); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* Media Queries for Responsiveness */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }

    .column {
        max-height: none;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .controls {
        flex-direction: column;
    }

    .stats-and-history-container {
        grid-template-columns: 1fr;
    }
    .table-container {
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    th, td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    button {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .stat-item {
        flex-basis: calc(50% - 0.5rem); /* Two columns on tablet */
    }

    .prominent-stat {
        flex-basis: 100%;
    }

    th, td {
        white-space: normal;
        word-wrap: break-word;
    }

    .stat-item-value {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    th, td {
        white-space: normal;
        word-wrap: break-word;
    }

    .table-container {
        overflow-x: auto;
    }

    .wallet-balance-container {
        flex-wrap: wrap; /* Allow wrapping if needed */
    }

    .stat-item {
        flex-basis: 100%; /* One column on mobile */
    }
}
/* Style for shadow trades to make them visually distinct */
.shadow-trade {
    opacity: 0.6;
    font-style: italic;
}

/* Centering the Load More button */
#load-more-btn-container {
    text-align: center;
}

#load-more-btn {
    display: inline-block; /* Allows text-align center to work on its parent */
    margin: 15px auto; /* Top/bottom margin, auto left/right for centering */
}

/* --- Modal Styles --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1001; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.7); /* Black w/ opacity */
    padding-top: 60px;
}

.modal-content {
    background-color: #2a2a2a;
    margin: 5% auto; /* 5% from the top and centered */
    padding: 20px;
    border: 1px solid var(--border-color);
    width: 80%; /* Could be more responsive */
    max-width: 600px; /* Max width */
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.4), 0 6px 20px 0 rgba(0,0,0,0.3);
}

.modal-content h2 {
    color: var(--text-primary);
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.modal-content p {
    color: #CCC;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.close-btn {
    color: #AAA;
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: #FFF;
    text-decoration: none;
    cursor: pointer;
}

#wallets-textarea {
    width: calc(100% - 20px); /* Adjust for padding */
    padding: 10px;
    margin-bottom: 20px;
    background-color: #333;
    border: 1px solid var(--border-color);
    color: #FFF;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    border-radius: 5px;
    resize: vertical; /* Allow vertical resizing */
}

.modal-footer {
    display: flex;
    justify-content: flex-end; /* Align buttons to the right */
    align-items: center;
    gap: 10px;
}

#modal-status-msg {
    margin-right: auto; /* Push buttons to the right */
    font-style: italic;
    color: #AAA;
}

/* New styles to correctly align the Simple Mode toggle switch */
.settings-dropdown-content label[for="simple-mode-toggle"] {
    cursor: pointer; /* Ensures the whole row is clickable */
}

/* Position the toggle switch that comes directly after the "Simple Mode" label */
.settings-dropdown-content label[for="simple-mode-toggle"] + .toggle-switch {
    position: absolute;
    right: 15px; /* Aligns to the right edge with padding */
    bottom: 18px; /* Positions vertically within the last row */
}
/* --- Loading Overlay --- */
.hidden {
    display: none !important;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4); /* 40% opaque black */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's on top of everything */
}

.loader {
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid var(--accent-green); /* Green */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
/* --- Export Modal Specifics --- */
.date-range-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

input[type="date"] {
    background-color: #333;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: var(--font-primary);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

#last-export-timestamp {
    color: var(--text-secondary);
    font-style: italic;
}