/* ============================================
   Modal de Contato — Estilo Livros Multimidia
   ============================================ */

/* Fonte Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

/* Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    /* Permite scroll do overlay se o modal for maior que a tela */
    overflow-y: auto;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* Card */
.modal-card {
    background: #fff;
    border-radius: 8px;
    max-width: 500px;
    position: relative;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh; /* dynamic viewport height — respeita barra de endereço mobile */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: 'Poppins', sans-serif;
    /* Garante que não encolha abaixo do conteúdo mínimo */
    flex-shrink: 0;
    margin: auto; /* centraliza verticalmente quando overlay tem scroll */
}

/* Header — fixo no topo do modal */
.modal-card-head {
    background: #f0f2f5;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e1e1e1;
    flex-shrink: 0;
}

.modal-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #353d9f;
    margin: 0;
}

/* Form — precisa participar do flex para o body scrollar */
#formContatoFundeb {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Ocupa todo espaço disponível entre header e footer */
    flex: 1 1 auto;
    min-height: 0; /* Crucial para flex overflow funcionar */
}

/* Body — área que faz scroll */
.modal-card-body {
    padding: 1.25rem;
    overflow-y: auto;
    color: #333;
    font-family: 'Poppins', sans-serif;
    flex: 1 1 auto;
    min-height: 0;
    /* Scroll suave no mobile */
    -webkit-overflow-scrolling: touch;
}

.modal-card-body .subtitulo {
    color: #333;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e1e1e1;
}

/* Footer — fixo na base do modal, SEMPRE visível */
.modal-card-foot {
    background: #f0f2f5;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e1e1e1;
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Formulário */
.form-group {
    margin-bottom: 0.75rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.2rem;
    color: #333;
    font-size: 0.9rem;
}

.form-label .required {
    color: #da133b;
    margin-left: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-size: 0.95rem;
    font-family: 'Poppins', sans-serif;
    border: 1px solid #e1e1e1;
    border-radius: 4px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    color: #333;
    background: #fff;
    /* Evita zoom automático no iOS */
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: #5163f7;
}

.form-control::placeholder {
    color: #aaa;
}

.form-control.is-danger {
    border-color: #da133b;
}

.form-row {
    display: flex;
    gap: 0.5rem;
}

.form-row .form-group {
    flex: 1;
}

.form-row select.form-control {
    flex: 0 0 auto;
    width: auto;
    min-width: 160px;
}

/* Mensagem de erro */
.help.is-danger {
    color: #da133b;
    font-size: 0.75rem;
    margin-top: 0.15rem;
    display: none;
}

.help.is-danger.is-visible {
    display: block;
}

/* Checkbox */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.form-check input[type="checkbox"] {
    margin-top: 0.25rem;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.form-check label {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.3;
}

.form-check a {
    color: #5163f7;
    text-decoration: none;
}

.form-check a:hover {
    text-decoration: underline;
}

/* Botão Enviar */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-success {
    background-color: #178524;
    color: #fff;
}

.btn-success:hover {
    background-color: #136b1d;
}

.btn-success:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alertas */
.alert {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    display: none;
}

.alert-success {
    background-color: rgba(23, 133, 36, 0.1);
    border: 1px solid #178524;
    color: #178524;
    display: block;
}

.alert-error {
    background-color: rgba(218, 19, 59, 0.1);
    border: 1px solid #da133b;
    color: #da133b;
    display: block;
}

/* ============================================
   RESPONSIVO — Telas pequenas (≤ 768px)
   ============================================ */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-start; /* alinha no topo em telas menores */
    }

    .modal-card {
        max-height: 95vh;
        max-height: 95dvh;
        width: 100%;
        max-width: 100%;
        border-radius: 6px;
    }

    .modal-card-head {
        padding: 0.6rem 1rem;
    }

    .modal-card-title {
        font-size: 1.05rem;
    }

    .modal-card-body {
        padding: 1rem;
    }

    .modal-card-body .subtitulo {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
        padding-bottom: 0.5rem;
    }

    .form-group {
        margin-bottom: 0.6rem;
    }

    .form-label {
        font-size: 0.85rem;
        margin-bottom: 0.15rem;
    }

    .form-control {
        padding: 0.4rem 0.55rem;
        font-size: 0.9rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row select.form-control {
        width: 100%;
        min-width: unset;
    }

    .form-check {
        margin-top: 0.5rem;
    }

    .form-check label {
        font-size: 0.75rem;
    }

    .modal-card-foot {
        padding: 0.6rem 1rem;
    }

    .btn {
        font-size: 0.9rem;
        padding: 0.45rem 0.85rem;
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   RESPONSIVO — Telas muito pequenas (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
    }

    .modal-card {
        max-height: 100vh;
        max-height: 100dvh;
        width: 100%;
        border-radius: 0;
    }

    .modal-card-head {
        padding: 0.5rem 0.75rem;
    }

    .modal-card-title {
        font-size: 1rem;
    }

    .modal-card-body {
        padding: 0.75rem;
    }

    .modal-card-body .subtitulo {
        font-size: 0.8rem;
    }

    .form-group {
        margin-bottom: 0.5rem;
    }

    .form-label {
        font-size: 0.8rem;
    }

    .form-control {
        padding: 0.35rem 0.5rem;
        font-size: 0.85rem;
    }

    .form-check label {
        font-size: 0.72rem;
    }

    .modal-card-foot {
        padding: 0.5rem 0.75rem;
    }

    .btn {
        font-size: 0.85rem;
    }
}

/* ============================================
   RESPONSIVO — Telas com pouca altura (landscape phone)
   ============================================ */
@media (max-height: 600px) {
    .modal-overlay {
        align-items: flex-start;
        padding: 0.25rem;
    }

    .modal-card {
        max-height: 98vh;
        max-height: 98dvh;
    }

    .modal-card-head {
        padding: 0.4rem 0.75rem;
    }

    .modal-card-title {
        font-size: 0.95rem;
    }

    .modal-card-body {
        padding: 0.5rem 0.75rem;
    }

    .modal-card-body .subtitulo {
        font-size: 0.78rem;
        padding-bottom: 0.3rem;
        margin-bottom: 0.3rem;
    }

    .form-group {
        margin-bottom: 0.35rem;
    }

    .form-label {
        font-size: 0.78rem;
        margin-bottom: 0.1rem;
    }

    .form-control {
        padding: 0.3rem 0.5rem;
        font-size: 0.82rem;
    }

    .form-check {
        margin-top: 0.3rem;
    }

    .form-check label {
        font-size: 0.7rem;
    }

    .modal-card-foot {
        padding: 0.4rem 0.75rem;
    }

    .btn {
        font-size: 0.82rem;
        padding: 0.35rem 0.75rem;
    }
}
