/* Backdrop escuro estilo modal */
.app-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65); /* bem dark */
    z-index: 9999; /* sempre acima do layout do site */
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.18s ease-out;
}

/* Quando estiver visível */
.app-modal-backdrop.app-modal-open {
    display: flex;
    opacity: 1;
}

/* Card principal do modal */
.app-modal {
    width: 100%;
    max-width: 460px;
    max-height: 92svh;
    /* menos arredondado, mais parecido com os cards do painel */
    border-radius: 0.5rem;
    background-color: var(--bs-body-bg, #ffffff);
    box-shadow: 0 1.5rem 3rem rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.35);
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    transition: transform 0.18s ease-out, opacity 0.18s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Quando o modal entra em cena */
.app-modal.app-modal-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Cabeçalho */
.app-modal-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    gap: 0.75rem;
}

.app-modal-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: rgba(148, 163, 184, 0.12);
}

.app-modal-icon-wrap i {
    font-size: 1.2rem;
}

.app-modal-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    display: flex;
    align-items: center;
}

/* Base de botões do modal (independente de Bootstrap/site.css) */
.app-modal .btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 12px;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .14s ease;
}

.app-modal .btn:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.app-modal .btn-primary {
    color: #fff;
    background: linear-gradient(110deg, #0057ff, #00a3ff);
    border-color: #0057ff;
}

.app-modal .btn-primary:hover {
    filter: brightness(1.03);
}

.app-modal .btn-light {
    color: #0f1e31;
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.app-modal .btn-light:hover {
    background: #e8eef5;
}

.app-modal .btn-success {
    color: #fff;
    background: #16a34a;
    border-color: #16a34a;
}

.app-modal .btn-info {
    color: #fff;
    background: #0284c7;
    border-color: #0284c7;
}

.app-modal .btn-sm {
    padding: 7px 10px;
    font-size: 12px;
}

.app-modal .btn:focus-visible,
.app-modal .btn-close:focus-visible {
    outline: 2px solid rgba(0, 87, 255, .35);
    outline-offset: 1px;
}

/* Botão de fechar */
.app-modal .btn-close,
.app-modal-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: rgba(148, 163, 184, .18);
    cursor: pointer;
    position: relative;
    padding: 0;
}

.app-modal .btn-close::before,
.app-modal .btn-close::after,
.app-modal-close::before,
.app-modal-close::after {
    content: "";
    position: absolute;
    top: 13px;
    left: 7px;
    width: 14px;
    height: 2px;
    background: #334155;
}

.app-modal .btn-close::before,
.app-modal-close::before { transform: rotate(45deg); }
.app-modal .btn-close::after,
.app-modal-close::after { transform: rotate(-45deg); }

.app-modal .btn-close:hover,
.app-modal-close:hover {
    background: rgba(148, 163, 184, .28);
}

/* Corpo */
.app-modal-body {
    /* 🔹 margem interna para não ficar colado nas bordas */
    padding: 0.85rem 1rem 0.75rem;
    max-height: 70svh;   /* corpo nunca passa de 70% da altura da tela */
    overflow-y: auto;    /* se passar disso, scroll no corpo */
}

.app-modal-message {
    font-size: 0.92rem;
    color: var(--bs-secondary-color, #475569);
    /* 🔹 espaço entre a mensagem e o bloco de cópia/link */
    margin-bottom: 0.5rem;
}

/* Rodapé com botões */
.app-modal-footer {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Tipos: cores do “badge” do ícone */
.app-modal-type-success .app-modal-icon-wrap {
    background-color: rgba(16, 185, 129, 0.12);
}
.app-modal-type-success .app-modal-icon-wrap i {
    color: #10b981;
}

.app-modal-type-error .app-modal-icon-wrap {
    background-color: rgba(239, 68, 68, 0.12);
}
.app-modal-type-error .app-modal-icon-wrap i {
    color: #ef4444;
}

.app-modal-type-warning .app-modal-icon-wrap {
    background-color: rgba(245, 158, 11, 0.12);
}
.app-modal-type-warning .app-modal-icon-wrap i {
    color: #f59e0b;
}

.app-modal-type-info .app-modal-icon-wrap {
    background-color: rgba(59, 130, 246, 0.12);
}
.app-modal-type-info .app-modal-icon-wrap i {
    color: #3b82f6;
}

/* BLOCO ESPECIAL COPY-LINK (Padrão SweetCopyLink) */

.app-modal-copy-block {
    margin-top: 0.75rem;
    border-radius: 0.5rem;              /* antes era 0.75rem */
    border: 1px dashed rgba(148, 163, 184, 0.6);
    padding: 0.6rem 0.75rem;
    background-color: rgba(15, 23, 42, 0.02);
}

.app-modal-copy-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bs-secondary-color, #64748b);
    margin-bottom: 0.25rem;
}

.app-modal-copy-text {
    font-size: 0.86rem;
    word-break: break-word;
    white-space: pre-wrap;          /* respeita \n e espaços */

    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    padding: 0.4rem 0.55rem;
    border-radius: 0.35rem;
    background-color: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.5);

    /* 🔹 LIMITA ALTURA E ATIVA SCROLL INTERNO */
    max-height: 260px;
    overflow-y: auto;
}

.app-modal-copy-actions {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.app-modal-copy-feedback {
    margin-top: 0.35rem;
    font-size: 0.8rem;
}

/* Deixa os botões de copiar/whatsapp mais compactos */
.app-modal-copy-actions .btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    flex: 0 0 auto !important;
    white-space: nowrap;
    min-height: 28px;
    padding: 0.08rem 0.5rem !important;
    font-family: var(--bs-body-font-family, "IBM Plex Sans", sans-serif) !important;
    font-size: 0.84rem !important;
    font-weight: 400 !important;
    line-height: 1.5;
}

.app-modal-copy-actions .btn .icon-sm {
    width: 14px !important;
    height: 14px !important;
}

.app-modal-copy-actions .btn i,
.app-modal-copy-actions .btn i[data-feather],
.app-modal-copy-actions .btn svg,
.app-modal-copy-actions .btn svg.feather {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    stroke-width: 2 !important;
    vertical-align: middle !important;
}

/* Responsivo: em mobile, o modal “enche” mais a tela */
@media (max-width: 575.98px) {
    .app-modal-backdrop {
        align-items: flex-start;
        padding: 0.75rem;
    }

    .app-modal {
        margin-top: 3.5rem; /* abaixo do header */
        max-width: 100%;
        max-height: calc(100svh - 1.5rem);
        border-radius: 0.85rem;
    }

    .app-modal-footer {
        flex-wrap: wrap;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .app-modal-footer .btn {
        flex: 1 1 100%;
    }
}
