#trade { 
    margin: auto; 
    max-width: 680px; 
}

#main {
    margin: 2px;
}

#reset_bs { 
    cursor: pointer;
    z-index: 10;
    width: 30px;
    height: 30px;
    border: 1px solid #dc3545;
    border-radius: 8px;
    margin-right: 0.2rem;
}

#res-type-dst-2 {
    margin-bottom: 0.3em;
}

.rate-input { 
    width: 50px; 
    padding: 1px; 
    text-align: center;
    min-height: 1rem;
    font-size: 14px;
}

.hr {
    border-bottom: 1px solid #c5dbec;
    margin: 2px 0;
}

.hrs {
    border-bottom: 1px solid #c5dbec;
    margin: 2px 0;
    width: 60%;
}

.res-type { 
    margin-left: 7px; 
}

.res-subtype {
    margin: 1px;
    margin-left: 20px;
}

/* Add consistent spacing between radio inputs and their labels */
.res-type input[type="radio"] + label,
.res-subtype input[type="radio"] + label {
    margin-left: 0.2rem;
    cursor: pointer;
}

/* Resource selectors use Bootstrap .form-check-input; align them inline with
   their labels and adjacent controls instead of the widget's default top edge. */
.res-type .form-check-input,
.res-subtype .form-check-input {
    margin-top: 0;
    vertical-align: middle;
    cursor: pointer;
}

.res-mix-balance {
    margin: 0.2em 0;
}

#mix-fix1, #mix-fix2 { 
    width: 150px; 
}

#link, #text, #bbcode {
    margin: 0.5em 0;
    font-size: 0.8em;
    text-align: center;
}

#abbcode { 
    max-width: 800px;
    margin: 0 auto; 
}

.tdr { 
    text-align: right; 
    white-space: nowrap; 
}

#rate-mc { 
    text-align: center; 
}

/* Rates panel - grouped layout: labels+inputs, then sliders, then buttons */

/* Group 1: Rate Labels and Inputs */
.rate-labels-inputs-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rate-label-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rate-label {
    flex: 0 0 auto;
    text-align: right;
    white-space: nowrap;
    min-width: 150px;
}

.rate-input-group {
    display: flex;
    gap: 0.25rem;
}

.rate-input-group input,
.rate-input-group div {
    flex: 0 1 50px;
    min-width: 0;
}

/* Group 2: Rate Sliders */
.rate-sliders-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rate-slider-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rate-slider-row span {
    flex: 0 0 auto;
    font-size: 0.8rem;
}

.rate-slider-row .form-range {
    flex: 1 1 auto;
    min-width: 0;
}

/* Group 3: Rate Buttons */
.rate-buttons-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.rate-buttons-group button {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    font-weight: bold;
}

/* Responsive: horizontal layout on larger screens */
@media (min-width: 768px) {
    /* Create horizontal layout container */
    .rates-panel-content {
        display: flex;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .rate-labels-inputs-group {
        flex: 0 0 auto;
        min-width: 200px;
    }
    
    .rate-sliders-group {
        flex: 1 1 auto;
        min-width: 200px;
    }
    
    .rate-buttons-group {
        flex: 0 0 auto;
        grid-template-columns: repeat(2, 1fr);
        min-width: 180px;
    }
    
    .rate-buttons-group button {
        font-size: 0.75rem;
    }
}

.ui-button-text, .ui-button .ui-button-text { 
    padding: 0.1em; 
}

.rbutton { 
    text-align: center; 
}

.rbutton button { 
    width: 7em; 
}

#big-arrow {
    display: inline-block;
    color: #6ea8fe;
    transform-origin: center;
    font-size: 3rem;
}

/* Keep the arrow column tight: remove column padding and prevent extra flex growth */
.arrow-col {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0;
    margin-right: 0;
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Minimal horizontal margin around the icon itself */
.arrow-col #big-arrow {
    margin: 0;
}

/* Bootstrap grid responsive adjustments */
@media (max-width: 991.98px) {
    .arrow-col {
        width: 100%;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    
    #big-arrow {
        transform: rotate(90deg);
        font-size: 2.5rem !important;
    }
    
    .res-input {
        font-size: 0.9em;
    }
    
    .tdr {
        text-align: left;
        margin-bottom: 0.25rem;
    }
}

/* Large screens: keep tight */
@media (min-width: 992px) {
    .arrow-col {
        width: auto;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
}

/* Resource source and destination panels - equal height and spacing */
#res-src-panel,
#res-dst-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

/* Panel header remains fixed size */
#res-src-panel > p,
#res-dst-panel > p {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

/* Panel content wrapper - grows to fill available space */
#res-src-panel > div,
#res-dst-panel > div {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: visible;
    padding-right: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Ensure the inner divs (res-src, res-dst) have identical styling */
#res-src,
#res-dst {
    min-height: 12em;
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

/* Consistent row spacing in both panels */
#res-src-panel .row,
#res-dst-panel .row {
    margin-bottom: 0.5rem;
    align-items: center;
}

/* Last row doesn't need bottom margin */
#res-src-panel > div > .row:last-child,
#res-dst-panel > div > .row:last-child {
    margin-bottom: 0;
}

/* Input elements styling - ensure consistent heights */
#res-src-panel .form-control.form-control-sm,
#res-dst-panel .form-control.form-control-sm {
    height: 1.5rem;
    padding: 0.25rem 0.5rem;
    display: flex;
    align-items: center;
    min-height: 1rem;
}

/* Cargo rows specifically - ensure identical heights */
#res-src-cargo,
#res-dst-cargo {
    min-height: 1.5rem;
    display: flex;
    align-items: center;
}

/* Focus states */
.trade-editable:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}


/* Disabled state styling */
.ui-state-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Disabled inputs should have muted text */
input:disabled,
input.ui-state-disabled {
    color: #6c757d !important;
}

/* Read-only display divs (not editable, for display purposes only) */
.res-input:not(input):not(textarea) {
    cursor: default;
}

/* Error state for rate inputs */
.ui-state-error {
    border-color: #dc3545 !important;
    background-color: var(--bs-danger-bg-subtle);
}

/* Range slider styling for better visibility */
.form-range {
    height: 0.5rem;
}

.form-range::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
}

.form-range::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
}

#res-dst-m, #res-dst-c, #res-dst-d {
    height: 1.5rem;
}