/* Search dialogs only; settings use the shared My Domains modal and theme. */
:is(#smartgenModal, #bundle-modal) {
    --dsm-surface: var(--ds-solid, #222b3b);
    --dsm-text: var(--ds-text, #fff);
    --dsm-muted: var(--ds-muted, #b9c1cf);
    --dsm-border: var(--ds-border, #465164);
    --dsm-input: var(--ds-input, #192132);
    --dsm-link: #bfdbfe;
    --dsm-accent: var(--ds-accent, #2563eb);
    --dsm-focus: var(--ds-focus, #93c5fd);
    color: var(--dsm-text);
}
body:not(.dark-theme) :is(#smartgenModal, #bundle-modal) {
    --dsm-surface: var(--ds-solid, #fff);
    --dsm-text: var(--ds-text, #202b40);
    --dsm-muted: var(--ds-muted, #536176);
    --dsm-border: var(--ds-border, #ccd4e0);
    --dsm-input: var(--ds-input, #f8fafc);
    --dsm-link: #2563eb;
    --dsm-focus: #2563eb;
}
:is(#smartgenModal, #bundle-modal) .modal-dialog {
    width: calc(100% - 32px);
    max-width: 800px;
    margin: 24px auto !important;
    height: auto;
}
:is(#smartgenModal, #bundle-modal) .modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    border: 1px solid var(--dsm-border);
    border-radius: 16px;
    background: var(--dsm-surface) !important;
    color: var(--dsm-text) !important;
}
:is(#smartgenModal, #bundle-modal) .modal-header,
:is(#smartgenModal, #bundle-modal) .modal-footer {
    flex: 0 0 auto;
    gap: 12px;
    background: var(--dsm-surface);
    padding: 18px 24px !important;
}
:is(#smartgenModal, #bundle-modal) .modal-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    margin: 0;
    font-size: 21px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--dsm-text) !important;
    overflow-wrap: anywhere;
}
:is(#smartgenModal, #bundle-modal) .modal-header .close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: -8px -10px -8px 0;
    color: var(--dsm-text) !important;
    opacity: .85;
}
:is(#smartgenModal, #bundle-modal) .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 24px !important;
    background: var(--dsm-surface);
    color: var(--dsm-text);
    scrollbar-width: thin;
    scrollbar-color: var(--dsm-border) transparent;
}
:is(#smartgenModal, #bundle-modal) .modal-footer {
    display: flex;
    flex-wrap: wrap;
}
:is(#smartgenModal, #bundle-modal) .modal-footer > * {
    min-width: 0;
    margin: 0;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
}
:is(#smartgenModal, #bundle-modal) :is(.form-group, .bootstrap-select) {
    min-width: 0;
    max-width: 100%;
}
:is(#smartgenModal, #bundle-modal) :is(label, small, .small, .help-block, .bundle-modal-hint) {
    font-size: 14px;
    line-height: 1.5;
}
:is(#smartgenModal, #bundle-modal) :is(label, .domain-settings__intro) { color: var(--dsm-muted) !important; }
:is(#smartgenModal, #bundle-modal) .modal-body a:not(.btn) { color: var(--dsm-link) !important; text-underline-offset: 3px; }
:is(#smartgenModal, #bundle-modal) :is(.form-control, .bootstrap-select > .dropdown-toggle) {
    color: var(--dsm-text) !important;
    background: var(--dsm-input) !important;
    border: 1px solid var(--dsm-border) !important;
}
:is(#smartgenModal, #bundle-modal) .form-control::placeholder { color: var(--dsm-muted) !important; opacity: 1; }
:is(#smartgenModal, #bundle-modal) .modal-footer :is(.btn-secondary, .btn-light) { color: var(--dsm-text) !important; background: var(--dsm-input) !important; }
#smartgenModal [hidden] { display: none !important; }
#smartgenModal .smartgen-heading { min-width: 0; }
#smartgenModal .smartgen-title-icon { flex-shrink: 0; font-size: 24px; color: var(--dsm-link); }
#smartgenModal #smartgen-description { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--dsm-muted); }
#smartgenModal .smartgen-fields { display: grid; grid-template-columns: 100px 170px minmax(0, 1fr); gap: 16px; }
#smartgenModal .smartgen-field { min-width: 0; }
#smartgenModal .smartgen-topic { grid-column: 1 / -1; }
#smartgenModal .smartgen-field > label { display: block; margin: 0 0 7px; font-size: 14px; }
#smartgenModal .smartgen-field > .bmd-form-group { display: block; min-width: 0; margin: 0; padding: 0; }
/* Keep native controls: selectpicker's form-control wrapper adds a second field and clips its menu. */
#smartgenModal .smartgen-control {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 46px;
    padding: 10px 12px !important;
    border: 1px solid var(--dsm-border) !important;
    border-radius: 8px;
    background: var(--dsm-input) !important;
    color: var(--dsm-text) !important;
    font: inherit;
    font-size: 14px !important;
    line-height: 1.4;
    box-shadow: none !important;
    transform: none !important;
    transition: border-color .15s ease !important;
    color-scheme: dark;
}
body:not(.dark-theme) #smartgenModal .smartgen-control { color-scheme: light; }
#smartgenModal select.smartgen-control { appearance: auto; }
#smartgenModal .smartgen-control::placeholder { color: var(--dsm-muted) !important; opacity: 1 !important; font-style: normal !important; }
#smartgenModal .smartgen-control:focus { border-color: var(--dsm-focus) !important; }
#smartgenModal .smartgen-control[aria-invalid="true"] { border-color: #e67583 !important; }
#smartgenModal .smartgen-options { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 12px; }
#smartgenModal .smartgen-checkbox { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; margin: 0; font-size: 14px; cursor: pointer; }
#smartgenModal input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 18px; margin: 0 !important; accent-color: var(--dsm-accent); }
#smartgenModal .smartgen-hint { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--dsm-border); color: var(--dsm-muted); }
#smartgenModal .smartgen-hint .material-icons { flex: 0 0 20px; font-size: 20px; }
#smartgenModal .smartgen-hint p { margin: 0; font-size: 14px; line-height: 1.6; }
#smartgenModal .smartgen-message { margin: 12px 0; color: var(--dsm-muted); font-size: 14px; line-height: 1.6; }
#smartgenModal .smartgen-error { padding: 10px 12px; border: 1px solid rgba(230,117,131,.45); border-radius: 4px; background: rgba(230,117,131,.09); color: var(--dsm-text); }
#smartgenModal #sg-results-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--dsm-border); }
#smartgenModal .smartgen-results-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
#smartgenModal #sg-results-title { margin: 0; font-size: 18px; line-height: 1.4; color: var(--dsm-text); }
#smartgenModal #sg-results-count { color: var(--dsm-muted); font-size: 13px; }
#smartgenModal .smartgen-results-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; margin: 16px 0; }
#smartgenModal .smartgen-results-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; }
#smartgenModal .smartgen-results-actions button { min-height: 44px; padding: 8px 0; white-space: normal; }
#smartgenModal .smartgen-results-mode { flex: 0 1 230px; }
#smartgenModal #sg-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#smartgenModal .smartgen-result { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 48px; margin: 0; padding: 0 12px; border: 1px solid var(--dsm-border); border-radius: 8px; cursor: pointer; }
#smartgenModal .smartgen-result label { flex: 1; min-width: 0; margin: 0; padding: 13px 0; font-size: 14px; line-height: 1.5; color: var(--dsm-text) !important; overflow-wrap: anywhere; cursor: pointer; }
#smartgenModal .smartgen-result:hover { background: rgba(37,99,235,.07); }
#smartgenModal .smartgen-result.sg-selected { border-color: var(--dsm-focus); background: rgba(37,99,235,.12); }
#smartgenModal #sg-more { margin-top: 16px; width: 100%; }
#smartgenModal .ds-button .material-icons { flex-shrink: 0; font-size: 20px; }
#smartgenModal .modal-footer { align-items: center; }
#smartgenModal #sg-selected-count { margin-right: auto; min-height: 0; font-size: 13px; color: var(--dsm-muted); }
#smartgenModal :disabled { opacity: .5; cursor: default; }
#bundle-modal .bundle-modal-header .modal-title span { overflow: visible; white-space: normal; }
#bundle-modal .bundle-check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--dsm-border); }
#bundle-modal .bundle-check-domain { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
#bundle-modal :is(.bundle-check-chip, .bundle-check-meta, .bundle-card-savings, .bundle-card-retail, .badge) { font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
#bundle-modal .bundle-modal-price-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin: 16px 0 8px; }
#bundle-modal .bundle-modal-total { font-size: 24px; }
#bundle-modal :is(.bundle-modal-alert, .bundle-modal-hint) { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 16px; color: var(--dsm-muted); }
#bundle-modal [hidden] { display: none !important; }
#bundle-modal :is(#bundle-modal-submit, #bundle-status-dismiss) { background: linear-gradient(135deg, #047857, #065f46) !important; border-color: #047857 !important; color: #fff !important; }
#bundle-modal :is(#bundle-modal-submit, #bundle-status-dismiss):hover:not(:disabled) { background: linear-gradient(135deg, #065f46, #047857) !important; }
#bundle-modal #bundle-status-card { margin: 0; padding: 0; border: 0; background: transparent; color: var(--dsm-text); }
#bundle-modal #bundle-status-title { margin: 0 0 16px; color: var(--dsm-muted); overflow-wrap: anywhere; }
#bundle-modal .bundle-order-progress { height: 6px; overflow: hidden; margin-bottom: 20px; background: var(--dsm-border); border-radius: 3px; }
#bundle-modal #bundle-status-progress-bar {
    height: 100%;
    background: var(--dsm-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .2s ease;
}
#bundle-modal .bundle-order-items table { width: 100%; table-layout: fixed; border-collapse: collapse; color: var(--dsm-text); }
#bundle-modal .bundle-order-items td { padding: 14px 0; border-bottom: 1px solid var(--dsm-border); vertical-align: top; overflow-wrap: anywhere; }
#bundle-modal .bundle-order-items td:first-child { width: 62%; padding-right: 16px; }
#bundle-modal .bundle-order-items td:last-child { text-align: right; }
#bundle-modal .bundle-order-items tr:last-child td { border-bottom: 0; }
#bundle-modal .bundle-order-items .text-danger { color: #fda4af !important; }
body:not(.dark-theme) #bundle-modal .bundle-order-items .text-danger { color: #b91c1c !important; }
#bundle-modal .bundle-status-label { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; max-width: 100%; }
#bundle-modal .bundle-status-label .material-icons { flex-shrink: 0; font-size: 18px; }
#bundle-modal .bundle-status-summary { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 14px; border: 1px solid var(--dsm-border); border-radius: 10px; background: var(--dsm-input); color: var(--dsm-text); }
#bundle-modal .bundle-status-summary > .material-icons { flex-shrink: 0; font-size: 22px; }
#bundle-modal .bundle-status-summary > div { min-width: 0; overflow-wrap: anywhere; }
#bundle-modal .bundle-status-summary strong { display: block; }
#bundle-modal .bundle-status-summary small { display: block; margin-top: 6px; color: var(--dsm-muted); }
#bundle-modal .bundle-status-summary-success > .material-icons, #bundle-modal .bundle-status-completed { color: #62d6b5; }
#bundle-modal .bundle-status-summary-warning > .material-icons { color: #fbbf24; }
#bundle-modal .bundle-status-summary-danger > .material-icons, #bundle-modal .bundle-status-failed { color: #fda4af; }
body:not(.dark-theme) #bundle-modal .bundle-status-summary-success > .material-icons, body:not(.dark-theme) #bundle-modal .bundle-status-completed { color: #087958; }
body:not(.dark-theme) #bundle-modal .bundle-status-summary-warning > .material-icons { color: #8b4900; }
body:not(.dark-theme) #bundle-modal .bundle-status-summary-danger > .material-icons, body:not(.dark-theme) #bundle-modal .bundle-status-failed { color: #b91c1c; }

/* Animate content, not Bootstrap's transition state, so the legacy modal shim can still close immediately. */
:is(#smartgenModal, #bundle-modal).show .modal-content { animation: ds-bootstrap-enter 220ms cubic-bezier(.2,0,0,1); }
@keyframes ds-bootstrap-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
    :is(#smartgenModal, #bundle-modal) .modal-dialog { width: calc(100% - 16px); margin: 8px auto !important; }
    :is(#smartgenModal, #bundle-modal) .modal-content { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); border-radius: 12px; }
    :is(#smartgenModal, #bundle-modal) .modal-header { padding: 16px !important; }
    :is(#smartgenModal, #bundle-modal) .modal-title { font-size: 20px; }
    :is(#smartgenModal, #bundle-modal) .modal-body { padding: 16px !important; }
    :is(#smartgenModal, #bundle-modal) .modal-footer { gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) !important; }
    :is(#smartgenModal, #bundle-modal) .modal-footer > * { flex: 1 1 100px; font-size: 14px; }
    :is(#smartgenModal, #bundle-modal) :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select, .bootstrap-select > .dropdown-toggle) { font-size: 16px !important; min-height: 44px; }
    #smartgenModal .smartgen-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 14px 12px; }
    #smartgenModal .smartgen-profile { grid-column: 1 / -1; }
    #smartgenModal .smartgen-control { font-size: 16px !important; }
    #smartgenModal .smartgen-results-mode { flex-basis: 100%; }
    #smartgenModal #sg-results { grid-template-columns: minmax(0, 1fr); }
    #smartgenModal #sg-selected-count { flex-basis: 100%; }
    #smartgenModal .modal-footer .ds-button { flex: 1 1 160px; padding: 10px; }
}
@media (max-width: 440px) {
    #smartgenModal .modal-footer .ds-button { flex-basis: 100%; }
}

/* The registration agreement is appended to body by SweetAlert, outside the search root. */
body.domain-search-page .domain-rules-agreement-popup {
    --ds-solid: #222b3b;
    --ds-text: #fff;
    --ds-muted: #b9c1cf;
    --ds-border: #465164;
    --ds-input: #192132;
    --ds-focus: #93c5fd;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 24px !important;
    overflow: hidden;
    background: var(--ds-solid) !important;
    color: var(--ds-text) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: 16px;
}
body.domain-search-page:not(.dark-theme) .domain-rules-agreement-popup {
    --ds-solid: #fff;
    --ds-text: #202b40;
    --ds-muted: #536176;
    --ds-border: #ccd4e0;
    --ds-input: #f8fafc;
    --ds-focus: #2563eb;
}
body.domain-search-page .domain-rules-agreement-popup .swal2-header { flex-shrink: 0; align-items: stretch; }
body.domain-search-page .domain-rules-agreement-popup .swal2-title { margin: 0 0 16px !important; padding: 0 !important; color: var(--ds-text) !important; text-align: left; font-size: 22px !important; line-height: 1.3; }
body.domain-search-page .domain-rules-agreement-popup :is(.swal2-content, .swal2-html-container) { min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 0 4px; color: var(--ds-text) !important; }
body.domain-search-page .domain-rules-agreement-popup .swal2-actions { flex-shrink: 0; gap: 10px; margin-top: 18px !important; }
body.domain-search-page .domain-rules-agreement-popup :is(.swal2-confirm, .swal2-cancel) { min-height: 44px; min-width: 140px; margin: 0; border: 1px solid var(--ds-border); border-radius: 9px !important; font-size: 14px !important; font-weight: 600 !important; }
body.domain-search-page .domain-rules-agreement-popup .swal2-confirm {
    background: linear-gradient(135deg, #047857, #065f46) !important;
    border-color: #047857 !important;
    color: #fff !important;
    transition: none !important;
}
body.domain-search-page .domain-rules-agreement-popup .swal2-confirm:disabled { opacity: .5; cursor: not-allowed; }
body.domain-search-page .domain-rules-agreement-popup .swal2-cancel { background: var(--ds-input) !important; color: var(--ds-text) !important; }
body.domain-search-page .domain-rules-agreement-popup :focus-visible { outline: 2px solid var(--ds-focus) !important; outline-offset: 2px; }
body.domain-search-page .domain-rules-agreement { text-align: left; color: var(--ds-text); font-size: 14px; line-height: 1.5; }
body.domain-search-page .domain-rules-agreement__intro { margin: 0 0 16px; color: var(--ds-muted); }
body.domain-search-page .domain-rules-agreement__grid { display: grid; gap: 16px; margin-bottom: 20px; }
body.domain-search-page .domain-rules-agreement__rule { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 16px; min-width: 0; }
body.domain-search-page .domain-rules-agreement__rule-title { font-weight: 600; }
body.domain-search-page .domain-rules-agreement__rule-text { color: var(--ds-muted); overflow-wrap: anywhere; }
body.domain-search-page .domain-rules-agreement__footer { display: grid; gap: 8px; margin-bottom: 16px; color: var(--ds-muted); }
body.domain-search-page .domain-rules-agreement__footer p { margin: 0; }
body.domain-search-page .domain-rules-agreement__link { justify-self: start; display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; margin: 0; background: var(--ds-input) !important; color: var(--ds-text) !important; border: 1px solid var(--ds-border); text-transform: none; font-size: 14px; border-radius: 9px; }
body.domain-search-page .domain-rules-agreement__check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; margin: 0; padding: 12px 0; color: var(--ds-text); font-size: 14px; line-height: 1.5; cursor: pointer; }
body.domain-search-page .domain-rules-agreement__check input { flex: 0 0 20px; margin: 2px 0 0 !important; border-color: var(--ds-muted) !important; background: var(--ds-input) !important; }
body.domain-search-page .domain-rules-agreement__check input:checked { background: #2563eb !important; border-color: #2563eb !important; }
@media (max-width: 640px) {
    body.domain-search-page .domain-rules-agreement-popup { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 16px !important; }
    body.domain-search-page .domain-rules-agreement__rule { grid-template-columns: minmax(0,1fr); gap: 4px; }
    body.domain-search-page .domain-rules-agreement-popup .swal2-title { font-size: 20px !important; }
    body.domain-search-page .domain-rules-agreement-popup :is(.swal2-confirm, .swal2-cancel) { flex: 1 1 120px; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    :is(#smartgenModal, #bundle-modal).show .modal-content { animation: none; }
    #smartgenModal :is(.smartgen-control, .ds-button, .ds-text-button, .smartgen-result) { transition: none !important; }
}
