/* =============================================
   FORM SECTIONS - Estilo padrão de formulários
   Baseado no design de care-tasks/form
   ============================================= */

/* ── Form Section Cards ── */
.form-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.form-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.form-section-title i {
    color: #10B981;
}

/* ── Labels ── */
.form-section .form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: #374151;
    margin-bottom: 0.3rem;
}

/* ── Inputs ── */
.form-section .form-control,
.form-section .form-select {
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-section .form-control:focus,
.form-section .form-select:focus {
    border-color: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .12);
}

/* ── Submit area ── */
.form-actions {
    display: flex;
    justify-content: center !important;
    align-items: center;
    gap: .75rem;
    padding-top: .75rem;
    border-top: 1px solid #e2e8f0;
    margin-top: .5rem;
    flex-wrap: wrap;
}

.form-actions .btn,
.form-actions .btn-primary,
.form-actions .btn-secondary,
.form-actions .btn-salvar,
.form-actions .btn-cancelar {
    flex: 0 0 auto !important;
    width: 170px !important;
    max-width: 100% !important;
    min-height: 38px;
    justify-content: center;
    box-sizing: border-box;
}

.form-actions .btn-primary {
    background: transparent;
    border: 1.5px solid #3B82F6;
    color: #3B82F6;
    border-radius: 8px;
    padding: 0.4rem 1.25rem;
    font-weight: 600;
    font-size: 0.8rem;
}

.form-actions .btn-primary:hover {
    background: #3B82F6;
    color: white;
    transform: translateY(-1px);
}

.form-actions .btn-secondary {
    border-radius: 8px;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

.modal-footer {
    justify-content: center !important;
    gap: .75rem;
}

.modal-footer .btn {
    flex: 0 0 auto !important;
    width: 170px !important;
    max-width: 100% !important;
    min-height: 38px;
    justify-content: center;
    box-sizing: border-box;
}

.modal-action-footer {
    justify-content: center !important;
}

.modal-action-footer .btn {
    flex: 0 0 auto !important;
    width: 170px !important;
    max-width: 100% !important;
    min-height: 38px;
    justify-content: center;
    box-sizing: border-box;
}

/* ── SweetAlert ── */
.swal-custom-popup {
    border-radius: 16px !important;
    padding: 1.5rem !important;
}

.swal-custom-title {
    color: #1F2937 !important;
    font-size: 1.25rem !important;
    font-weight: 600 !important;
}

.swal-confirm-btn,
.swal-cancel-btn {
    border-radius: 8px !important;
    padding: 10px 24px !important;
    font-weight: 500 !important;
}

/* ── Desktop density: keep common forms above the footer on notebook screens ── */
@media (min-width: 769px) {
    .form-card:has(.form-section),
    .form-card:has(.form-actions) {
        min-height: auto !important;
        padding: 0.95rem 1.1rem 1.05rem !important;
    }

    .form-card:has(.form-section) > a.btn.btn-secondary.mb-3 {
        min-height: 34px;
        margin-bottom: 0.65rem !important;
        padding: 0.35rem 0.8rem !important;
    }

    .form-card:has(.form-section) > .d-flex.justify-content-between.align-items-center.mb-3 {
        margin-bottom: 0.65rem !important;
    }

    .form-card:has(.form-section) .content-header {
        margin-bottom: 0.7rem !important;
        padding-bottom: 0.55rem !important;
    }

    .form-card:has(.form-section) .titulo-principal {
        font-size: 1.18rem !important;
        line-height: 1.2;
        margin-bottom: 0 !important;
    }

    .form-card:has(.form-section) .content-header .text-muted,
    .form-card:has(.form-section) .content-header .small {
        margin-top: 0.2rem !important;
        font-size: 0.74rem !important;
        line-height: 1.25;
    }

    .form-card:has(.form-section) .form-section {
        padding: 0.72rem 0.9rem !important;
        margin-bottom: 0.72rem !important;
        border-radius: 10px;
    }

    .form-card:has(.form-section) .form-section-title {
        margin-bottom: 0.55rem !important;
        font-size: 0.72rem !important;
        line-height: 1.2;
        letter-spacing: 0.45px;
    }

    .form-card:has(.form-section) .form-section > p,
    .form-card:has(.form-section) .form-section .text-muted.small {
        margin-bottom: 0.5rem !important;
        font-size: 0.72rem !important;
        line-height: 1.28;
    }

    .form-card:has(.form-section) .row {
        --bs-gutter-x: 0.9rem;
        --bs-gutter-y: 0.55rem;
    }

    .form-card:has(.form-section) .form-label {
        margin-bottom: 0.22rem !important;
        font-size: 0.76rem !important;
        line-height: 1.2;
    }

    .form-card:has(.form-section) .form-control,
    .form-card:has(.form-section) .form-select {
        min-height: 34px;
        padding: 0.38rem 0.65rem !important;
        border-radius: 7px;
        font-size: 0.82rem !important;
        line-height: 1.25;
    }

    .form-card:has(.form-section) textarea.form-control {
        min-height: 120px;
    }

    .form-card:has(.form-section) .input-group-text {
        padding: 0.38rem 0.55rem !important;
    }

    .form-card:has(.form-section) .form-actions {
        gap: 0.65rem;
        padding-top: 0.55rem !important;
        margin-top: 0.25rem !important;
    }

    .form-card:has(.form-section) .form-actions .btn,
    .form-card:has(.form-section) .form-actions .btn-primary,
    .form-card:has(.form-section) .form-actions .btn-secondary,
    .form-card:has(.form-section) .form-actions .btn-salvar,
    .form-card:has(.form-section) .form-actions .btn-cancelar {
        min-height: 34px !important;
        width: 150px !important;
        padding: 0.34rem 1rem !important;
        font-size: 0.78rem !important;
    }

    .form-card:has(.form-section) .border.rounded.p-3 {
        padding: 0.75rem !important;
    }

    .form-card:has(.form-section) .professional-check-item {
        padding-top: 0.45rem !important;
        padding-bottom: 0.45rem !important;
    }

    .form-card:has(.form-section) .patient-plan-grid {
        gap: 0.7rem;
        margin-bottom: 0.85rem;
    }

    .form-card:has(.form-section) .patient-images-grid {
        gap: 0.6rem;
    }

    .form-card:has(.form-section) .patient-image-item img {
        height: 110px;
    }
}

@media (min-width: 769px) and (max-height: 820px) {
    .form-card:has(.form-section),
    .form-card:has(.form-actions) {
        padding-top: 0.8rem !important;
        padding-bottom: 0.9rem !important;
    }

    .form-card:has(.form-section) .form-section {
        padding-top: 0.62rem !important;
        padding-bottom: 0.62rem !important;
        margin-bottom: 0.6rem !important;
    }

    .form-card:has(.form-section) .content-header {
        margin-bottom: 0.6rem !important;
    }

    .form-card:has(.form-section) .form-control,
    .form-card:has(.form-section) .form-select {
        min-height: 32px;
        padding-top: 0.34rem !important;
        padding-bottom: 0.34rem !important;
    }
}

/* ── Responsive ── */
@media (max-width: 576px) {
    .form-card {
        overflow: hidden;
    }

    .form-card > a.btn.btn-secondary.mb-3 {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        padding: 0 !important;
        margin-bottom: 0.85rem !important;
        border: 1px solid #bfdbfe !important;
        border-radius: 12px !important;
        background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%) !important;
        color: #1d4ed8 !important;
        font-size: 0 !important;
        line-height: 1 !important;
        overflow: hidden !important;
        box-shadow: 0 6px 14px rgba(37, 99, 235, 0.12) !important;
    }

    .form-card > a.btn.btn-secondary.mb-3 i {
        margin: 0 !important;
        font-size: 0.95rem !important;
        line-height: 1 !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.45rem !important;
        margin-bottom: 0.85rem !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 > * {
        width: auto !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 .btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 40px !important;
        min-height: 40px !important;
        padding: 0 0.8rem !important;
        border-radius: 12px !important;
        font-size: 0.78rem !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        box-shadow: 0 6px 14px rgba(37, 99, 235, 0.10) !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 .btn-secondary {
        flex: 0 0 40px !important;
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        padding: 0 !important;
        border: 1px solid #bfdbfe !important;
        background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%) !important;
        color: #1d4ed8 !important;
        font-size: 0 !important;
        overflow: hidden !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 .btn-primary {
        flex: 0 1 auto !important;
        width: auto !important;
        min-width: fit-content !important;
        max-width: none !important;
        border: 1px solid #93c5fd !important;
        background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
        color: #2563eb !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 .btn i {
        margin: 0 !important;
        font-size: 0.95rem !important;
        line-height: 1 !important;
    }

    .form-card > .d-flex.justify-content-between.align-items-center.mb-3 .btn-primary i {
        margin-right: 0.28rem !important;
        font-size: 0.82rem !important;
    }

    .content-header {
        margin-bottom: 1rem;
        padding-bottom: 0.85rem;
        border-bottom: 1px solid #e2e8f0;
        text-align: center;
    }

    .content-header .titulo-principal,
    .titulo-principal {
        font-size: 1.2rem !important;
        line-height: 1.25 !important;
        margin: 0 !important;
    }

    .form-section {
        padding: 0.95rem;
        margin-bottom: 0.95rem;
        border-radius: 12px;
    }

    .form-section-title {
        margin-bottom: 0.65rem;
        font-size: 0.76rem;
        line-height: 1.22;
        letter-spacing: 0.45px;
    }

    .form-section .form-label {
        font-size: 0.78rem;
        margin-bottom: 0.25rem;
    }

    .form-section .form-control,
    .form-section .form-select {
        min-height: 42px;
        border-radius: 10px;
        font-size: 0.85rem;
        padding: 0.55rem 0.68rem;
    }

    .form-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        flex-direction: unset !important;
        justify-content: center !important;
        gap: 0.65rem;
        padding-top: 1rem;
        margin-top: 0.25rem;
        border-top: 1px solid #e2e8f0;
    }

    .form-actions .btn,
    .form-actions .btn-salvar,
    .form-actions .btn-cancelar {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        min-height: 44px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 0.72rem 0.65rem !important;
        border-radius: 12px !important;
        font-size: 0.82rem !important;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
    }

    .form-actions .btn-primary,
    .form-actions .btn-salvar {
        background: #2563eb !important;
        border-color: #2563eb !important;
        color: #fff !important;
        box-shadow: 0 10px 20px rgba(37, 99, 235, 0.16);
    }

    .form-actions .btn-secondary,
    .form-actions .btn-cancelar {
        background: #fff !important;
        border: 1.5px solid #cbd5e1 !important;
        color: #475569 !important;
    }

    .form-actions .btn i,
    .form-actions .btn-salvar i,
    .form-actions .btn-cancelar i {
        margin-right: 0.35rem !important;
    }

    .modal-footer,
    .modal-action-footer {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        gap: .5rem !important;
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }

    .modal-footer .btn,
    .modal-action-footer .btn {
        flex: 1 1 0 !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 170px !important;
    }
}
