/* Dashboard Bootstrap modals that opt in with .sgt-modal.
   Other .modal dialogs keep their own styles. */

.sgt-modal.modal {
    --sgt-navy: #0b1220;
    --sgt-navy-2: #141c2e;
    --sgt-gold: #e8b93a;
    --sgt-gold-2: #f5d06b;
    --sgt-line: #e6ebf2;
    --sgt-ink: #0b1220;
    --sgt-muted: #4b5568;
}

.sgt-modal .modal-dialog {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    align-self: center;
    width: min(520px, calc(100% - 32px));
    max-width: 520px;
    height: auto;
    min-height: 0;
    margin: 0 auto;
    max-height: calc(100vh - 32px);
    overflow: hidden;
}

.sgt-modal .modal-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    border: 0;
    border-radius: 18px;
    background: #fff;
    color: var(--sgt-ink);
    box-shadow: 0 24px 60px rgba(11, 18, 32, 0.28);
}

/* Header, scrolling body, and footer share one column. The footer is a
   sibling of the body, so a tall sheet scrolls the body instead of sliding
   the footer over the last field. */
.sgt-modal .sgt-modal-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 32px);
    overflow: hidden;
}

.sgt-modal .modal-header {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    position: relative;
    flex: 0 0 auto;
    padding: 14px 8px 14px 16px;
    padding-inline: 16px 8px;
    border: 0;
    border-radius: 0;
    background: linear-gradient(160deg, var(--sgt-navy) 0%, var(--sgt-navy-2) 100%);
    color: #fff;
}

.sgt-modal .sgt-modal-handle {
    display: none;
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    transform: translateX(-50%);
}

.sgt-modal .sgt-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    margin-top: 4px;
    color: var(--sgt-gold);
    font-size: 1.15rem;
}

.sgt-modal .modal-header .modal-title {
    flex: 1 1 auto;
    align-self: flex-start;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding-top: 8px;
    overflow: hidden;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.sgt-modal .modal-header .sgt-modal-close,
.sgt-modal .modal-header .btn-close {
    box-sizing: border-box;
    align-self: flex-start;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    margin-inline-start: auto;
    padding: 0;
    border-radius: 12px;
    opacity: 1;
    background-color: transparent;
    background-position: center;
    background-size: 16px;
    position: relative;
    z-index: 2;
}

.sgt-modal .sgt-modal-close:hover,
.sgt-modal .sgt-modal-close:focus-visible {
    background-color: rgba(255, 255, 255, 0.1);
}

.sgt-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 16px 24px;
    background: #fff;
    color: var(--sgt-ink);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sgt-modal .modal-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
    flex-shrink: 0;
    position: static;
    z-index: 2;
    margin: 0;
    padding: 12px 16px;
    border: 0;
    border-top: 1px solid var(--sgt-line);
    border-radius: 0;
    background: #fff;
}

.sgt-modal .modal-footer .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    border-radius: 12px;
}

.sgt-modal .sgt-btn-primary {
    border: 0;
    background: linear-gradient(135deg, var(--sgt-gold) 0%, var(--sgt-gold-2) 100%);
    color: var(--sgt-navy);
}

.sgt-modal .sgt-btn-primary:hover,
.sgt-modal .sgt-btn-primary:focus {
    color: var(--sgt-navy);
    filter: brightness(1.04);
}

.sgt-modal .sgt-btn-primary:disabled {
    opacity: 0.65;
    color: var(--sgt-navy);
}

.sgt-modal .sgt-btn-secondary {
    border: 1.5px solid #c9d1de;
    background: transparent;
    color: var(--sgt-navy);
}

.sgt-modal .sgt-btn-secondary:hover,
.sgt-modal .sgt-btn-secondary:focus {
    border-color: #c9d1de;
    background: #f4f7fb;
    color: var(--sgt-navy);
}

.sgt-modal .sgt-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.45;
}

.sgt-modal .sgt-note > i {
    flex: 0 0 auto;
    margin-top: 2px;
}

.sgt-modal .sgt-note-warning {
    border: 1px solid #f0d48a;
    background: #fff6e0;
    color: #6b4a00;
}

.sgt-modal .sgt-note-warning > i {
    color: #b58105;
}

.sgt-modal .sgt-note-info {
    border: 1px solid #d5e0f0;
    background: #eef3fb;
    color: var(--sgt-navy);
}

.sgt-modal .sgt-note-info > i {
    color: #1d4e89;
}

.sgt-modal .sgt-note-danger {
    border: 1px solid #f5c2c2;
    background: #fdecec;
    color: #7f1d1d;
}

.sgt-modal .sgt-note-danger > i {
    color: #c24141;
}

.sgt-modal .sgt-note-row {
    align-items: center;
    justify-content: space-between;
}

.sgt-modal .form-label {
    margin-bottom: 6px;
    color: var(--sgt-ink);
    font-weight: 600;
}

.sgt-modal .form-text,
.sgt-modal .form-text.text-muted {
    color: var(--sgt-muted);
    font-size: 0.875rem;
}

.sgt-modal .sgt-amount-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
}

.sgt-modal .form-control,
.sgt-modal .form-select {
    min-height: 48px;
    padding: 10px 14px;
    border: 1.5px solid #d5dbe6;
    border-radius: 12px;
    background: #fff;
    color: var(--sgt-ink);
    font-size: 1rem;
    line-height: 1.3;
}

.sgt-modal .form-control:focus,
.sgt-modal .form-select:focus {
    border-color: var(--sgt-gold);
    box-shadow: 0 0 0 3px rgba(232, 185, 58, 0.35);
    outline: none;
}

.sgt-modal .sgt-amount {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding-inline: 14px;
    border: 1.5px solid #d5dbe6;
    border-radius: 12px;
    background: #fff;
}

.sgt-modal .sgt-amount:focus-within {
    border-color: var(--sgt-gold);
    box-shadow: 0 0 0 3px rgba(232, 185, 58, 0.35);
}

.sgt-modal .sgt-amount-prefix {
    flex: 0 0 auto;
    color: var(--sgt-navy);
    font-weight: 700;
}

.sgt-modal .sgt-amount .form-control {
    min-height: 46px;
    padding-inline: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.sgt-modal .sgt-amount .form-control:focus {
    border: 0;
    box-shadow: none;
    outline: none;
}

.sgt-modal .sgt-pin-input {
    letter-spacing: 0.35em;
    font-size: 1.25rem;
    text-align: center;
}

.sgt-modal .sgt-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0;
    padding: 12px;
    border-radius: 12px;
    background: #f4f7fb;
    color: var(--sgt-ink);
    cursor: pointer;
}

.sgt-modal .sgt-check input {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    min-width: 22px;
    margin: 2px 0 0;
    accent-color: var(--sgt-navy);
}

.sgt-modal .sgt-check span {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.45;
}

.sgt-modal .btn:focus-visible,
.sgt-modal .sgt-modal-close:focus-visible,
.sgt-modal .sgt-check input:focus-visible,
.sgt-modal a:focus-visible {
    outline: 3px solid var(--sgt-gold);
    outline-offset: 2px;
}

@media (min-width: 600px) {
    .sgt-modal.modal.show {
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .sgt-modal.fade .modal-dialog {
        transform: translateY(16px);
        transition: transform 0.28s ease;
    }

    .sgt-modal.show .modal-dialog {
        transform: none;
    }
}

@media (max-width: 599.98px) {
    .sgt-modal.modal {
        overflow: hidden;
    }

    .sgt-modal .modal-dialog {
        position: fixed;
        inset-inline: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 92vh;
        max-height: 92dvh;
        margin: 0;
    }

    .sgt-modal.fade .modal-dialog {
        transform: translateY(100%);
        transition: transform 0.28s ease;
    }

    .sgt-modal.show .modal-dialog {
        transform: translateY(0);
    }

    .sgt-modal .modal-content,
    .sgt-modal .sgt-modal-form {
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: 20px 20px 0 0;
    }

    .sgt-modal .modal-header {
        padding-top: 20px;
    }

    .sgt-modal .sgt-modal-handle {
        display: block;
    }

    .sgt-modal .modal-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

.sgt-modal .sgt-copy-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sgt-modal .sgt-copy-row .form-control {
    min-width: 0;
    flex: 1 1 auto;
}

.sgt-modal .sgt-copy-row .btn {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
}

.sgt-modal .modal-body img,
.sgt-modal .modal-body video {
    max-width: 100%;
    height: auto;
}

#successCardOverlay .success-card-header,
#switchSuccessOverlay .success-card-header,
#upgradeSuccessOverlay .upgrade-success-header {
    background: linear-gradient(160deg, #0b1220 0%, #141c2e 100%) !important;
    color: #fff !important;
}

#successCardOverlay .success-card-header h3,
#switchSuccessOverlay .success-card-header h3,
#upgradeSuccessOverlay .upgrade-success-header,
#upgradeSuccessOverlay .upgrade-success-header h3 {
    color: #fff !important;
}

#successCardOverlay .success-icon,
#switchSuccessOverlay .success-icon,
#upgradeSuccessOverlay .upgrade-success-header .icon {
    color: #e8b93a !important;
    background: rgba(232, 185, 58, 0.16) !important;
}

#successCardOverlay .success-btn,
#switchSuccessOverlay .success-btn,
#upgradeSuccessOverlay .btn-refresh {
    min-height: 48px;
    background: linear-gradient(135deg, #e8b93a 0%, #f5d06b 100%) !important;
    color: #0b1220 !important;
    border: 0 !important;
    border-radius: 12px !important;
    font-weight: 700;
}

#successCardOverlay .success-card,
#switchSuccessOverlay .success-card,
#upgradeSuccessOverlay .upgrade-success-card {
    max-width: 520px;
    border: 0 !important;
    border-radius: 18px !important;
    box-shadow: 0 24px 60px rgba(11, 18, 32, 0.28) !important;
}

@media (max-width: 599.98px) {
    #successCardOverlay.show,
    #switchSuccessOverlay.show,
    #upgradeSuccessOverlay.show {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    #successCardOverlay .success-card,
    #switchSuccessOverlay .success-card,
    #upgradeSuccessOverlay .upgrade-success-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
        overflow: auto !important;
        border-radius: 20px 20px 0 0 !important;
    }
}
