/* Commission configuration specific number input fixes for matrix theme */
/* ===== ADDITIONAL FIXES FOR pulse33 ISSUES ===== */

/* Prevent horizontal scroll on trade table */
#street-side-trade .table-container {
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
}

#street-side-trade .table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    margin: 0 auto;
}

/* Ensure the table fits within viewport */
#street-table {
    table-layout: fixed;
    width: 100%;
    max-width: calc(100vw - 60px); /* Account for container padding */
}

/* Responsive table container */
@media (max-width: 1440px) {
    #street-table {
        max-width: calc(100vw - 60px);
    }
}

/* Filter container fix to prevent overflow */
.filter-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) var(--bg-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Specific fix for particle filter input */
#particle-filter {
    width: 120px !important;
    max-width: 150px !important;
    min-width: auto !important;
    flex-shrink: 1;
}

.filter-container::-webkit-scrollbar {
    height: 6px;
}

.filter-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.filter-container::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

/* Matrix theme specific - allow wrapping to prevent horizontal scroll */
body[data-theme="matrix"] .filter-container {
    flex-wrap: wrap; /* Changed from nowrap to allow wrapping */
    gap: 8px; /* Slightly reduce gap */
}

body[data-theme="matrix"] .filter-container > * {
    flex-shrink: 0;
}

/* Reduce button padding in filter container to save space */
.filter-container button {
    padding: 8px 12px; /* Reduced from 8px 16px */
    font-size: 13px; /* Slightly smaller */
    white-space: nowrap;
}

.filter-container input[type="text"],
.filter-container select {
    padding: 8px 10px; /* Reduced padding */
    font-size: 13px; /* Slightly smaller */
}

/* Ensure column headers don't wrap */
#street-table th,
#allocation-table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px; /* Slightly smaller for headers */
    padding: 8px 4px; /* Reduced padding */
}

/* Specific fixes for problem columns */
#street-table th:nth-child(4) { /* Client */
    font-size: 12px;
    letter-spacing: -0.5px; /* Tighten letter spacing */
}

#street-table th:nth-child(5) { /* Security */
    font-size: 12px;
    letter-spacing: -0.5px;
}

#street-table th:nth-child(17) { /* Time */
    font-size: 12px;
    padding-right: 8px;
}

#allocation-table th:nth-child(5) { /* Side */
    font-size: 12px;
    text-align: center;
}

/* Particle Settings Content specific styles - Prevent overflow */
.particle-settings-content {
    width: 100%;
    overflow: hidden;
}

.particle-settings-content .setting-item {
    margin-bottom: 8px;
}

/* Setting control specific adjustments */
.particle-settings-content .setting-control {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    min-width: 140px; /* Reduced to prevent overflow */
    max-width: 100%;
}

/* Particle section specific slider controls */
#particle-section .slider-control {
    width: 100%;
    overflow: hidden;
}

#particle-section .slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#particle-section .slider-input {
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

#particle-section .slider-value {
    flex-shrink: 0;
    min-width: 45px; /* Reduced width for particle values */
    padding: 4px 6px;
    font-size: 11px;
}

/* Speed indicator fix */
.speed-indicator {
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 11px; /* Reduced font size */
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
    white-space: nowrap; /* Prevent text wrapping */
    display: inline-block; /* Ensure proper box model */
    min-width: 65px; /* Set minimum width */
    text-align: center;
}

/* Trade Control Section specific styles */
.trade-control-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    overflow: hidden;
}

/* Trade control specific slider value */
.trade-control-content .slider-value {
    min-width: 65px; /* Ensure value fits */
    text-align: center;
}

.trade-control-content .slider-row {
    display: flex;
    align-items: center;
    gap: 6px; /* Reduced gap */
    width: 100%;
}

.trade-control-content .slider-input {
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

/* Matrix theme specific fixes for commission configuration inputs */
/* Improved number input styling for matrix theme */
body[data-theme="matrix"] input[type="number"] {
    color: var(--accent-primary) !important;
    caret-color: var(--accent-primary) !important;
}

/* Style the up/down arrows in matrix theme for WebKit browsers */
body[data-theme="matrix"] input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
    cursor: pointer;
    /* Apply filter to make arrows green instead of using pseudo-elements */
    filter: hue-rotate(90deg) brightness(1.5);
}

/* Alternative styling without invalid pseudo-elements */
body[data-theme="matrix"] input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    cursor: pointer;
    filter: hue-rotate(90deg) brightness(1.5);
}

/* Override theme-input styles for commission configuration in matrix theme */
body[data-theme="matrix"] .commission-configuration .theme-input[type="number"] {
    color: var(--accent-primary) !important;
    font-family: 'Courier New', monospace;
}

/* Commission preview calculator inputs in matrix theme */
body[data-theme="matrix"] .commission-preview input[type="number"] {
    color: var(--accent-primary) !important;
    font-family: 'Courier New', monospace;
}

/* Ensure all theme-input number fields follow matrix theme */
body[data-theme="matrix"] .theme-input[type="number"]::-webkit-inner-spin-button,
body[data-theme="matrix"] .theme-input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    cursor: pointer;
}

/* Improved Firefox support for matrix theme number inputs */
body[data-theme="matrix"] input[type="number"] {
    -moz-appearance: textfield;
}

/* For browsers that support appearance none */
@supports (-moz-appearance: none) {
    body[data-theme="matrix"] input[type="number"] {
        -moz-appearance: none;
        appearance: none;
    }
}

/* Allocation table specific fixes */
#allocation-table {
    table-layout: fixed;
    width: 100%;
    max-width: calc(100vw - 60px); /* Account for container padding */
    margin: 0 auto;
}

#allocation .table-container {
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
}

#allocation .table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) var(--bg-secondary);
}

#allocation .table-wrapper::-webkit-scrollbar {
    height: 6px;
}

#allocation .table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

#allocation .table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

/* Ensure allocation table headers fit */
#allocation-table th {
    font-size: 12px;
    padding: 8px 4px;
}

#allocation-table th:nth-child(7) { /* VWAP (CAD) */
    font-size: 11px; /* Even smaller to fit */
    letter-spacing: -0.5px;
}

/* Data cells in tables */
#street-table td,
#allocation-table td {
    font-size: 12px;
    padding: 6px 4px;
}

/* Time column specific fix */
#street-table td:nth-child(17) {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: -0.5px;
}

/* Make select checkboxes smaller */
#street-table input[type="checkbox"],
#select-all-trades {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Compact progress bars */
.progress-bar {
    width: 65px; /* Reduced from 70px */
    height: 5px; /* Reduced from 6px */
}

.progress-text {
    font-size: 9px; /* Reduced from 10px */
    min-width: 28px; /* Reduced from 30px */
}
body[data-theme="matrix"] #base-commission-input,
body[data-theme="matrix"] #csa-percentage-input,
body[data-theme="matrix"] #calc-value-input,
body[data-theme="matrix"] #calc-csa-percentage-input {
    color: var(--accent-primary) !important;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* Ensure help icons in matrix theme are green */
body[data-theme="matrix"] .help-icon {
    color: var(--accent-primary) !important;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
}

body[data-theme="matrix"] .help-icon:hover {
    color: var(--accent-primary) !important;
    background: var(--bg-primary);
    box-shadow: 0 0 5px var(--accent-primary);
}

/* Calculator icon in matrix theme */
body[data-theme="matrix"] .calculator-icon {
    color: var(--accent-primary) !important;
    text-shadow: 0 0 5px var(--accent-primary);
}

/* Ensure save icon is green in matrix theme */
body[data-theme="matrix"] .save-icon {
    color: white !important; /* Keep white since it's on the button */
}

/* Fix commission preview borders in matrix theme */
body[data-theme="matrix"] .commission-preview {
    border-color: var(--accent-primary);
}

body[data-theme="matrix"] .commission-preview::before {
    background: var(--accent-primary);
}

/* Fix calc results in matrix theme */
body[data-theme="matrix"] .calc-results-row {
    border-color: var(--accent-primary);
}

body[data-theme="matrix"] .calc-result {
    border: 1px solid var(--accent-primary);
}

/* Ensure input prefixes and addons are styled correctly in matrix theme */
body[data-theme="matrix"] .input-prefix,
body[data-theme="matrix"] .input-addon {
    color: var(--accent-primary) !important;
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}