.adv-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    padding: 20px;
    box-sizing: border-box;
}
.adv-popup-content {
    background-color: #2a2d2f;
    width: 100%;
    max-width: 750px;
    border: 1px solid #444;
    border-radius: 10px;
    max-height: 90vh;
    overflow-y: auto;
    font-family: 'Poppins', sans-serif;
    color: #e0e0e0;
}
.adv-popup-content .adv-form-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #555;
}
.adv-popup-content .adv-form-heading {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #ffffff;
}
.adv-popup-content .adv-listing-type-toggle {
    display: flex;
    border: 1px solid #444;
    border-radius: 6px;
    overflow: hidden;
}
.adv-popup-content .adv-listing-type-toggle .adv-toggle-btn {
    background-color: #2a2d2f;
    color: #a0a0a0;
    padding: 8px 15px;
    border: none;
    cursor: pointer;
    font-size: .85em;
    font-weight: 500;
    transition: background-color .2s ease, color .2s ease;
    outline: none;
}
.adv-popup-content .adv-listing-type-toggle .adv-toggle-btn[data-type=sell] {
    border-right: 1px solid #444;
}
.adv-popup-content .adv-listing-type-toggle .adv-toggle-btn[data-type=sell].active {
    background-color: #c84038;
    color: #ffffff;
}
.adv-popup-content .adv-listing-type-toggle .adv-toggle-btn[data-type=buy].active {
    background-color: #38a86a;
    color: #ffffff;
}
.adv-popup-content form {
    padding: 25px;
}
.adv-popup-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Changed to a 2-column grid */
    gap: 25px;
    margin-bottom: 25px;
}
.adv-popup-form-field-full-width {
    grid-column: 1 / -1;
}

/*
* === REFACTORED LABEL & FIELD STYLES START ===
*/

/* This new rule creates consistent vertical space between labels and inputs */
.adv-popup-form-field-full-width,
.adv-popup-content .adv-form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* The base style for all form labels in the popup. It no longer has a margin. */
.adv-popup-content label {
    display: block;
    font-size: .78em;
    font-weight: 600;
    text-transform: uppercase;
    color: #b0b7c1;
    letter-spacing: .06em;
    line-height: 1.4; /* Set an explicit line-height */
}

/* Styling for the "(Optional)" text inside a label */
.adv-popup-content .adv-label-optional {
    font-weight: 500;
    text-transform: none;
    color: #999;
    margin-left: 5px;
}

/*
* === REFACTORED LABEL & FIELD STYLES END ===
*/

/*
* === AWAKENED TRAITS SECTION STYLES START ===
*/
#adv-popup-awakened-traits-wrapper {
    display: flex; /* Use flexbox to manage children */
    flex-direction: column; /* Stack children vertically */
    gap: 20px; /* This creates the vertical space between each trait row */
    border-top: 1px solid #444;
    padding-top: 25px;
    margin-top: 10px;
}

/* Styles each trait group, which now acts as a row */
.adv-popup-content .adv-trait-group {
    display: flex;
    flex-direction: row;
    gap: 15px;
    align-items: flex-start;
    width: 100%; /* Take full width of the flex-column parent */
    flex-basis: auto; /* Reset flex-basis from public styles */
}

/* Assign flex-basis to the fields within a trait group inside the popup */
.adv-popup-content .adv-trait-group .adv-form-field:nth-child(1) {
    flex: 2; /* The trait selection dropdown takes up more space */
}
.adv-popup-content .adv-trait-group .adv-form-field:nth-child(2) {
    flex: 1; /* The value input takes up less space */
}

/*
* === AWAKENED TRAITS SECTION STYLES END ===
*/


.adv-popup-content .adv-form-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #4a4f56;
    background-color: #1a1a1a;
    color: #e0e0e0;
    border-radius: 6px;
    font-size: .95em;
    height: 46px;
    box-sizing: border-box;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.adv-popup-content .adv-form-input:focus {
    border-color: #5865f2;
    box-shadow: 0 0 0 3px rgba(88, 101, 242, .25);
    outline: none;
}
.adv-popup-content input[type=number]::-webkit-outer-spin-button,
.adv-popup-content input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.adv-popup-content input[type=number] {
    -moz-appearance: textfield;
}
.adv-popup-content .adv-form-submit-area {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}
.adv-popup-content .adv-form-button {
    padding: 10px 25px;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    background-color: #5865f2;
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background-color .15s ease-out;
}
.adv-popup-content .adv-form-button:hover {
    background-color: #4a58dd;
}
.adv-popup-content .adv-form-button:disabled {
    background-color: #4a4d4f;
    cursor: not-allowed;
}
.adv-popup-close {
    position: absolute;
    top: 15px;
    right: 25px;
    cursor: pointer;
    font-size: 28px;
    color: #aaa;
    line-height: 1;
    transition: color .2s ease;
    z-index: 10;
}
.adv-popup-close:hover {
    color: #fff;
}

/* Feedback styles for readonly inputs */
.adv-popup-content .adv-form-input[readonly].is-valid {
    background-color: #303336; /* Lighter grey to indicate valid, pre-filled data */
    border-color: #4a4f56;
}

.adv-popup-content .adv-form-input[readonly].is-invalid {
    background-color: rgba(231, 76, 60, 0.1); /* Reddish tint for error */
    border-color: #e74c3c; /* Bright red border */
    color: #f5a7a1; /* Light red text for "N/A" */
}

/* Styling for the in-game name notice */
#adv-popup-ingame-name-notice {
    display: block;
    font-size: 0.8em;
    margin-top: 5px;
    color: #888; /* Default color */
}

#adv-popup-ingame-name-notice.error-text {
    color: #e74c3c; 
    font-weight: 500;
}

/* --- Pop-up Price & Receive Offers Combined Field --- */
.adv-price-offer-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}
/* Style for the new toggle button */
.adv-form-button-toggle {
    height: 46px; /* Match input height */
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    
    /* Default "Ghost" State */
    background-color: transparent;
    border: 2px solid #5865F2;
    color: #5865F2;
}

.adv-form-button-toggle:hover {
    background-color: rgba(88, 101, 242, 0.1);
}

/* Active "Deactivate" state (filled in) */
.adv-form-button-toggle.is-active {
    background-color: #5865F2;
    border-color: #5865F2;
    color: #ffffff;
}

.adv-form-button-toggle.is-active:hover {
    background-color: #4a58dd;
}

/* Style for the disabled price input */
#adv-popup-listing-price:disabled {
    background-color: #303336 !important;
    cursor: not-allowed;
    opacity: 0.6;
}