/* Overrides de modal cargados DESPUÉS de Tailwind/scoped CSS.
   Garantiza centrado y botones del footer aunque haya display:block residual. */

.tw-modal,
.modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1050 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 1rem !important;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.55);
}

.tw-modal-dialog,
.modal-dialog {
    width: 100%;
    max-width: min(32rem, calc(100vw - 2rem));
    margin: 0 auto;
    box-sizing: border-box;
}

.tw-modal-content,
.modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: 1rem;
    background: var(--app-surface, #fff);
    border: 1px solid var(--app-border, #dfe6f3);
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.25);
    box-sizing: border-box;
}

.tw-modal-header,
.modal-header,
.tw-modal-footer,
.modal-footer,
.tw-modal-body,
.modal-body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.tw-modal-header,
.modal-header,
.tw-modal-footer,
.modal-footer {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.tw-modal-header,
.modal-header {
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--app-border, #dfe6f3);
}

.tw-modal-footer,
.modal-footer {
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--app-border, #dfe6f3);
}

.tw-modal-body,
.modal-body {
    padding: 1rem;
    overflow-x: hidden;
}

.tw-modal-body > *,
.modal-body > *,
[class*="-modal-body"] > *,
[class*="-modal-instructions"] {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

:is(.tw-modal-footer, .modal-footer, [class*="-modal-foot"], [class*="-modal-footer"])
    :is(.tw-btn-primary, [class*="-btn-primary"], [class*="-btn-start"]) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 auto;
    min-height: 2.5rem !important;
    min-width: min(8.5rem, 100%);
    max-width: 100%;
    padding: 0.55rem 1.15rem !important;
    border-radius: 10px !important;
    border: 1px solid transparent !important;
    background: #0d47a1 !important;
    color: #fff !important;
    font-weight: 600 !important;
    white-space: nowrap;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
}

:is(.tw-modal-footer, .modal-footer, [class*="-modal-foot"], [class*="-modal-footer"])
    :is(.tw-btn-outline-secondary, .tw-btn-secondary, [class*="-btn-cancel"], [class*="-btn-secondary"]) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 auto;
    min-height: 2.5rem !important;
    min-width: min(8.5rem, 100%);
    max-width: 100%;
    padding: 0.55rem 1.15rem !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
}

html[data-theme="dark"] .tw-modal-content,
html[data-theme="dark"] .modal-content {
    background: var(--app-surface, #1e293b);
    border-color: var(--app-border, #334155);
    color: var(--app-text, #e8edf4);
}

html[data-theme="dark"] :is(.tw-modal-footer, .modal-footer, [class*="-modal-foot"], [class*="-modal-footer"])
    :is(.tw-btn-primary, [class*="-btn-primary"], [class*="-btn-start"]) {
    background: #2563eb !important;
}

/* Loading / spinner: sin tarjeta */
.login-loading-modal .tw-modal-content,
.tw-modal-content:has(.tw-spinner),
.tw-modal-content:has(.tw-spinner-lg) {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
