/* CSS Padrão para Modais - Reutilizável */

:root {
    --modal-primary: #2c3e50;
    --modal-primary-light: #34495e;
    --modal-primary-dark: #1a252f;
    --modal-secondary: #7f8c8d;
    --modal-success: #27ae60;
    --modal-danger: #e74c3c;
    --modal-warning: #f39c12;
    --modal-info: #3498db;
    --modal-bg: #ffffff;
    --modal-border: #e0e0e0;
    --modal-text: #2c3e50;
    --modal-text-light: #7f8c8d;
    --modal-hover: #ecf0f1;
    
    /* Safe Area para iPhone e Android */
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
    --safe-area-left: env(safe-area-inset-left);
    --safe-area-right: env(safe-area-inset-right);
}

/* ================================================================
   ELEMENTOS COMUNS DE MODAIS
   ================================================================ */

/* Botão de fechar modal */
.btn-close-modal {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid #e8e9ed;
    background: #ffffff;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: #f8f9fa;
    color: #dc3545;
}

/* Header com título e subtítulo */
.header-content h3,
.header-content .header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1d29;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-content h3 i {
    color: #667eea;
}

.header-content p,
.header-content .header-subtitle {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

/* Header com botão voltar */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.btn-back {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid #e8e9ed;
    background: #ffffff;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #f5f6fa;
    border-color: #2c3e50;
}

.header-info {
    flex: 1;
}

.header-subtitle {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

/* Footer info */
.footer-info {
    font-size: 0.875rem;
    color: #6c757d;
}

/* ================================================================
   STEPS/TABS MODERNAS (Produto, Detalhes, Funcionário)
   ================================================================ */
.steps-container-modern {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    padding: 12px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.step-pill-modern {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    border: 2px solid #e8e9ed;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.25s;
}

.step-pill-modern:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.step-pill-modern.step-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.step-pill-modern.step-done {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    border-color: #56ab2f;
}

.step-icon-modern {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f5f6fa;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.25s;
}

.step-pill-modern.step-active .step-icon-modern,
.step-pill-modern.step-done .step-icon-modern {
    background: rgba(255,255,255,0.2);
    color: #ffffff;
}

.step-label-modern {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.step-pill-modern.step-active .step-label-modern,
.step-pill-modern.step-done .step-label-modern {
    color: #ffffff;
}

.step-divider-modern {
    width: 24px;
    height: 2px;
    background: #e8e9ed;
    flex-shrink: 0;
}

/* Steps responsive */
@media (max-width: 768px) {
    .steps-container-modern {
        padding: 8px;
        gap: 6px;
    }

    .step-pill-modern {
        padding: 10px 8px;
    }

    .step-label-modern {
        font-size: 0.7rem;
    }

    .step-divider-modern {
        width: 12px;
    }
}

@media (max-width: 480px) {
    .step-label-modern {
        display: none;
    }

    .step-icon-modern {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
}

/* ================================================================
   CONTENT AREA & SECTIONS MODERNAS
   ================================================================ */
.content-area-modern {
    min-height: 300px;
    margin-bottom: 0;
    padding-bottom: 0;
}

.step-content-modern {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header-modern {
    margin-bottom: 16px;
}

.section-header-modern h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1a1d29;
    margin: 0 0 4px 0;
}

.section-header-modern p {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

.section-body-modern {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

@media (max-width: 768px) {
    .section-body-modern {
        padding: 16px;
    }
}

/* ================================================================
   CHIPS (Selected Items)
   ================================================================ */
.summary-chips-modern {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.selected-chip-modern {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f5f6fa;
    border: 1px solid #e8e9ed;
    border-radius: 12px;
    font-size: 0.875rem;
    color: #2c3e50;
}

.selected-chip-primary {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-color: #667eea;
}

.chip-icon-modern {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: #ffffff;
    color: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.chip-text-modern {
    font-weight: 600;
}

.chip-change-modern {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chip-change-modern:hover {
    background: #667eea;
    color: #ffffff;
}

/* ================================================================
   FORM FIELDS MODERNAS
   ================================================================ */
.form-grid-modern {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .form-grid-modern {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.form-field-modern {
    display: flex;
    flex-direction: column;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-label-modern {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-input-modern,
.form-textarea-modern {
    padding: 12px 14px;
    border: 2px solid #e8e9ed;
    border-radius: 10px;
    font-size: 0.9375rem;
    color: #1a1d29;
    background: #ffffff;
    transition: all 0.2s;
}

.form-input-modern:focus,
.form-textarea-modern:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-input-readonly {
    background: #f8f9fa;
    color: #6c757d;
}

.form-input-total {
    background: linear-gradient(135deg, #d4edda 0%, #e8f5e9 100%);
    border-color: #28a745;
    color: #155724;
    font-weight: 700;
    font-size: 1.0625rem;
}

.form-textarea-modern {
    resize: vertical;
    min-height: 80px;
}

/* ================================================================
   CARDS SECUNDÁRIOS
   ================================================================ */
.card-secondary-modern {
    background: #f8f9fa;
    border: 1px solid #e8e9ed;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 16px;
}

.card-secondary-header {
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e8e9ed;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #495057;
}

.card-secondary-body {
    padding: 16px;
}

/* ================================================================
   ALERTAS
   ================================================================ */
.alert-modern {
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 16px;
    font-size: 0.875rem;
}

.alert-warning-modern {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

/* ================================================================
   AJUSTES PARA COMPONENTES INTERNOS
   ================================================================ */
.section-body-modern funcionario,
.section-body-modern produto-venda,
.card-secondary-body funcionario {
    display: block;
}

.section-body-modern .panel,
.card-secondary-body .panel {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    margin: 0 !important;
}

.section-body-modern .panel-heading,
.card-secondary-body .panel-heading {
    display: none !important;
}

.section-body-modern .panel-body,
.card-secondary-body .panel-body {
    padding: 0 !important;
}

/* ================================================================
   MODAL DE BUSCA DE PRODUTOS
   ================================================================ */

/* Filtros */
.filtros-section {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.filtro-principal {
    margin-bottom: 16px;
}

.input-busca-modern {
    display: flex;
    align-items: center;
    border: 2px solid #e8e9ed;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    transition: all 0.2s;
    gap: 0;
}

.input-busca-modern:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.input-icon {
    padding: 0 14px;
    color: #6c757d;
    font-size: 1rem;
}

.form-control-busca {
    flex: 1;
    padding: 14px 0;
    border: none;
    font-size: 1rem;
    outline: none;
    background: transparent;
}

.form-control-busca::placeholder {
    color: #adb5bd;
}

.btn-scanner {
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-scanner:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #764ba2;
}

.filtro-hint {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 8px;
    display: block;
}

/* Pills de Tipo (Produtos/Serviços/Pacotes) */
.tipo-pills {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: #f8f9fa;
    border-radius: 12px;
}

.tipo-pill {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.tipo-pill:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tipo-pill.pill-active {
    background: #ffffff;
    color: #667eea;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Loading */
.loading-state {
    text-align: center;
    padding: 40px 20px;
}

.spinner-busca i {
    font-size: 2.5rem;
    color: #667eea;
}

.loading-state p {
    margin-top: 16px;
    color: #6c757d;
    font-size: 0.9375rem;
}

/* Alerts */
.alert-busca {
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9375rem;
}

.alert-info-busca {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
}

.alert-warning-busca {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

/* Resultados Header */
.resultados-section {
    /* Container dos resultados */
}

.resultados-header {
    margin-bottom: 16px;
}

.resultados-header h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1d29;
    margin: 0 0 4px 0;
}

.resultados-header p {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

/* Grid de Produtos */
.produtos-grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.produto-card-modern {
    background: #ffffff;
    border: 1px solid #e8e9ed;
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.produto-card-modern:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.produto-card-modern.card-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.produto-card-modern.card-disabled:hover {
    border-color: #e8e9ed;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transform: none;
}

.card-header-modern {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 8px;
}

.badge-id-modern {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.card-status-modern {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.badge-tipo-modern {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-produto {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-servico {
    background: #e8f5e9;
    color: #388e3c;
}

.badge-estoque-modern {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.estoque-ok {
    background: #d4edda;
    color: #28a745;
}

.estoque-baixo {
    background: #fff3cd;
    color: #856404;
}

.estoque-zero {
    background: #f8d7da;
    color: #dc3545;
}

.card-title-modern {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1d29;
    margin-bottom: 12px;
    line-height: 1.4;
}

.card-details-modern {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.detail-item-modern {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: #6c757d;
}

.detail-item-modern i {
    color: #667eea;
    font-size: 0.75rem;
}

.card-footer-modern {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid #e8e9ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-section {
    flex: 1;
}

.price-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1d29;
}

.tap-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: #6c757d;
    font-weight: 600;
}

.tap-indicator i {
    color: #667eea;
}

.tap-disabled {
    color: #dc3545;
}

.tap-disabled i {
    color: #dc3545;
}

/* Responsivo - Busca */
@media (max-width: 768px) {
    .filtros-section {
        padding: 16px;
    }
    
    .produtos-grid-modern {
        grid-template-columns: 1fr;
    }
    
    .tipo-pills {
        gap: 6px;
    }
    
    .tipo-pill {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .tipo-pill {
        font-size: 0.75rem;
        padding: 8px 10px;
    }
}

/* ================================================================
   MOBILE/TABLET: Modais fullscreen com safe-area
   
   Basta usar as classes Bootstrap padrão:
   - .modal-header
   - .modal-body
   - .modal-footer
   
   O CSS abaixo aplica safe-area automaticamente em mobile.
   ================================================================ */
@media (max-width: 768px) {
    /* Container do modal - fullscreen */
    .modal {
        padding: 0 !important;
    }
    
    /* Dialog - ocupa tela toda */
    .modal-dialog {
        margin: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }
    
    /* Content - flex column */
    .modal-content {
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Body container do customModal */
    .modal-body-container {
        flex: 1 1 auto !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
    }
    
    /* Header com safe-area no topo */
    .modal-header {
        padding-top: max(44px, calc(16px + env(safe-area-inset-top))) !important;
        padding-left: max(20px, env(safe-area-inset-left)) !important;
        padding-right: max(20px, env(safe-area-inset-right)) !important;
        flex-shrink: 0 !important;
    }
    
    /* Body scrollável com safe-area lateral */
    .modal-body {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important;
        -webkit-overflow-scrolling: touch;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
    
    /* Footer com safe-area no fundo */
    .modal-footer {
        padding-bottom: max(34px, calc(16px + env(safe-area-inset-bottom))) !important;
        padding-left: max(20px, env(safe-area-inset-left)) !important;
        padding-right: max(20px, env(safe-area-inset-right)) !important;
        flex-shrink: 0 !important;
    }
}

/* ================================================================
   DESKTOP: Comportamento normal de modal
   ================================================================ */
@media (min-width: 769px) {
    .modal-dialog {
        margin-top: 1.75rem !important;
        margin-bottom: 1.75rem !important;
        max-height: 90vh !important;
    }
    
    .modal-content {
        max-height: 90vh !important;
    }
}

/* Header do Modal */
.modal-header-padrao {
    background: var(--modal-primary);
    color: #ffffff;
    border-bottom: none;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header-padrao .modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header-padrao .close {
    color: #ffffff;
    opacity: 0.9;
    font-size: 1.5rem;
    font-weight: 300;
    text-shadow: none;
    transition: all 0.2s;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
}

.modal-header-padrao .close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Body do Modal */
.modal-body-container {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

/* Garantir scroll para modais sem classe padrão */
.modal-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
}

.modal-body-padrao {
    padding: 20px !important;
    padding-bottom: 20px !important;
    max-height: none !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: #f8f9fa !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 1 auto !important;
}

.modal-body-padrao > .row:last-child {
    margin-bottom: 0 !important;
}

.modal-body-padrao form .row:last-child {
    margin-bottom: 0 !important;
}

.modal-body-padrao form .row:last-child .col-md-12:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Scroll customizado */
.modal-body-padrao::-webkit-scrollbar {
    width: 6px;
}

.modal-body-padrao::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal-body-padrao::-webkit-scrollbar-thumb {
    background: var(--modal-primary);
    border-radius: 3px;
}

.modal-body-padrao::-webkit-scrollbar-thumb:hover {
    background: var(--modal-primary-dark);
}

/* Seções do Formulário */
.modal-section {
    background: var(--modal-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--modal-border);
    overflow: visible;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section-header {
    background: #f8f9fa;
    border-bottom: 2px solid var(--modal-border);
    padding: 12px 16px;
    margin: -20px -20px 20px -20px;
    border-radius: 8px 8px 0 0;
}

.modal-section-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--modal-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-section-header h5 i {
    color: var(--modal-primary);
}

/* Input Groups */
.modal-section .input-group-text {
    background: #f8f9fa;
    border-color: var(--modal-border);
    color: var(--modal-text);
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 100px;
    max-width: 140px;
    width: auto;
    justify-content: flex-start;
    padding: 8px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-section .input-group-text i {
    margin-right: 6px;
    color: var(--modal-primary);
}

.modal-section .input-group-text.bg-danger {
    background: var(--modal-danger) !important;
    color: #ffffff !important;
    border-color: var(--modal-danger) !important;
}

.modal-section .form-control {
    border-color: var(--modal-border);
    font-size: 0.95rem;
    padding: 8px 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.modal-section .form-control:focus {
    border-color: var(--modal-primary);
    box-shadow: 0 0 0 0.2rem rgba(44, 62, 80, 0.15);
}

.modal-section .form-control.is-invalid {
    border-color: var(--modal-danger);
}

.modal-section .form-control:disabled {
    background: #f8f9fa;
    opacity: 0.7;
}

.modal-section .input-group {
    flex-wrap: nowrap;
    width: 100%;
    display: flex;
}

.modal-section .input-group-prepend {
    flex-shrink: 0;
    display: flex;
}

.modal-section .input-group-append {
    flex-shrink: 0;
    display: flex;
}

.modal-section .invalid-feedback {
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
}

/* Garantir que tudo seja visível */
.modal-section .form-group {
    margin-bottom: 1rem;
}

.modal-section .form-group:last-child {
    margin-bottom: 0;
}

/* Ajustar espaçamento em mobile */
@media (max-width: 576px) {
    .modal-section .form-group {
        margin-bottom: 0.75rem;
    }
    
    .modal-section .form-group.row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .modal-section .form-group.row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Garantir que labels não quebrem */
    .modal-section .input-group-text span {
        display: inline-block;
    }
    
    /* Ajustar altura mínima dos inputs */
    .modal-section .form-control,
    .modal-section select.form-control {
        min-height: 36px;
    }
}

/* Footer do Modal */
.modal-footer-padrao {
    background: #ffffff;
    border-top: 1px solid var(--modal-border);
    padding: 12px 20px;
}

.modal-footer-padrao .btn {
    font-weight: 500;
    padding: 8px 16px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.modal-footer-padrao .btn-primary {
    background: var(--modal-primary);
    border-color: var(--modal-primary);
    color: #ffffff;
}

.modal-footer-padrao .btn-primary:hover:not(:disabled) {
    background: var(--modal-primary-dark);
    border-color: var(--modal-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-footer-padrao .btn-secondary {
    background: var(--modal-secondary);
    border-color: var(--modal-secondary);
    color: #ffffff;
}

.modal-footer-padrao .btn-secondary:hover {
    background: #6c7a7b;
    border-color: #6c7a7b;
}

.modal-footer-padrao .btn-danger {
    background: var(--modal-danger);
    border-color: var(--modal-danger);
    color: #ffffff;
}

.modal-footer-padrao .btn-danger:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.modal-footer-padrao .btn-info {
    background: var(--modal-info);
    border-color: var(--modal-info);
    color: #ffffff;
}

.modal-footer-padrao .btn-info:hover {
    background: #2980b9;
    border-color: #2980b9;
}

.modal-footer-padrao .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Custom Switch */
.custom-switch .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--modal-primary);
    border-color: var(--modal-primary);
}

.custom-switch .custom-control-label {
    color: var(--modal-text);
    font-weight: 500;
}

/* Cards dentro do modal */
.modal-section .card {
    border: 1px solid var(--modal-border);
    box-shadow: none;
}

.modal-section .card-header {
    background: #f8f9fa;
    border-bottom: 1px solid var(--modal-border);
    padding: 12px 16px;
}

.modal-section .card-header.bg-warning {
    background: #fff3cd !important;
    border-bottom-color: #ffc107;
}

.modal-section .card-header.bg-warning h5 {
    color: #856404;
}

/* Responsivo Mobile */
@media (max-width: 768px) {
    .modal-header-padrao {
        padding: 12px 16px;
    }
    
    .modal-header-padrao .modal-title {
        font-size: 1.1rem;
    }
    
    .modal-body-padrao {
        padding: 16px !important;
        max-height: calc(100vh - 180px) !important;
    }
    
    .modal-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .modal-section:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao > .row:last-child .modal-section:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao form .row:last-child .col-md-12:last-child .modal-section:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-section-header {
        padding: 10px 12px;
        margin: -16px -16px 16px -16px;
    }
    
    .modal-section-header h5 {
        font-size: 1rem;
    }
    
    .modal-section .input-group {
        flex-wrap: nowrap;
    }
    
    .modal-section .input-group-text {
        min-width: 90px;
        max-width: 90px;
        width: 90px;
        font-size: 0.75rem;
        padding: 6px 6px;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 0;
    }
    
    .modal-section .input-group-text i {
        font-size: 0.7rem;
        margin-right: 3px;
        flex-shrink: 0;
    }
    
    .modal-section .input-group-text span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .modal-section .form-control {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.9rem;
    }
    
    .modal-section .form-group.row > div {
        margin-bottom: 12px;
    }
    
    .modal-section .form-group.row > div:last-child {
        margin-bottom: 0;
    }
    
    .modal-section .form-control {
        font-size: 0.9rem;
        padding: 6px 10px;
    }
    
    .modal-footer-padrao {
        padding: 10px 16px;
        position: sticky;
        bottom: 0;
        background: #ffffff;
        border-top: 2px solid var(--modal-border);
        z-index: 10;
    }
    
    .modal-footer-padrao .btn {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    /* Stack de botões em mobile */
    .modal-footer-padrao .row.d-md-none .col-6 {
        margin-bottom: 8px;
    }
    
    .modal-footer-padrao .row.d-md-none .col-6:last-child {
        margin-bottom: 0;
    }
    
    /* Ajustar labels longos */
    .modal-section .input-group-text {
        font-size: 0.75rem;
    }
    
    /* Garantir que selects não cortem */
    .modal-section select.form-control {
        min-height: 38px;
    }
}

@media (max-width: 576px) {
    .modal-header-padrao .modal-title {
        font-size: 0.95rem;
        flex-wrap: wrap;
    }
    
    .modal-body-padrao {
        padding: 12px !important;
        max-height: calc(100vh - 160px) !important;
    }
    
    .modal-section {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .modal-section:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao {
        padding-bottom: 0 !important;
    }
    
    .modal-body-padrao form {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    
    .modal-body-padrao > .row:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao form .row:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao form .row:last-child .col-md-12:last-child .modal-section:last-child {
        margin-bottom: 0 !important;
        padding-bottom: 12px !important;
    }
    
    .modal-section-header {
        padding: 8px 10px;
        margin: -12px -12px 12px -12px;
    }
    
    .modal-section-header h5 {
        font-size: 0.9rem;
    }
    
    .modal-section .input-group {
        flex-wrap: nowrap;
        width: 100%;
    }
    
    .modal-section .input-group-prepend {
        flex-shrink: 0;
    }
    
    .modal-section .input-group-text {
        min-width: 80px;
        max-width: 80px;
        width: 80px;
        font-size: 0.7rem;
        padding: 6px 4px;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .modal-section .input-group-text i {
        font-size: 0.65rem;
        margin-right: 2px;
        flex-shrink: 0;
    }
    
    .modal-section .input-group-text span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        max-width: 100%;
    }
    
    .modal-section .form-control {
        font-size: 0.85rem;
        padding: 6px 8px;
        flex: 1 1 auto;
        min-width: 0;
        width: 0;
    }
    
    .modal-section .input-group-append {
        flex-shrink: 0;
    }
    
    .modal-section .form-group {
        margin-bottom: 12px;
    }
    
    .modal-footer-padrao {
        padding: 8px 12px;
    }
    
    .modal-footer-padrao .btn {
        font-size: 0.8rem;
        padding: 6px 8px;
    }
    
    .modal-footer-padrao .btn i {
        font-size: 0.75rem;
    }
    
    /* Ajustar custom switch em mobile */
    .custom-control-label {
        font-size: 0.85rem;
    }
    
    /* Garantir que textarea não corte */
    .modal-section textarea {
        min-height: 80px;
    }
}

/* Override Bootstrap para garantir compatibilidade */
.modal-content {
    border: none !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: 90vh !important;
    height: auto !important;
}

.modal-dialog {
    margin: 20px auto !important;
    max-width: 90% !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: 90vh !important;
}

.modal-content .modal-body-container {
    flex: 1 1 auto !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

.modal-content .modal-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

.modal-content .modal-body-padrao {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
}

@media (max-width: 768px) {
    .modal-dialog {
        margin: 5px !important;
        max-width: calc(100% - 10px) !important;
        max-height: calc(100vh - 10px) !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .modal-content {
        max-height: calc(100vh - 10px) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    
    .modal-body-container {
        flex: 1 1 auto !important;
        overflow: hidden !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .modal-body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: calc(100vh - 180px) !important;
    }
    
    .modal-body-padrao {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 16px !important;
        padding-bottom: 0 !important;
        min-height: 0 !important;
    }
    
    .modal-body-padrao form {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    
    .modal-body-padrao .row {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao .row:last-child {
        margin-bottom: 0 !important;
    }
    
    .modal-body-padrao .col-md-12:last-child .modal-section:last-child {
        margin-bottom: 0 !important;
        padding-bottom: 16px !important;
    }
    
    .modal-body-padrao .modal-section:last-child {
        margin-bottom: 0 !important;
    }
}

@media (max-width: 576px) {
    /* Modal backdrop - tela cheia */
    .modal {
        padding: 0 !important;
    }
    
    /* Container principal - ocupa tela toda */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        display: flex !important;
        align-items: stretch !important;
    }
    
    /* Content - flex column para empilhar header/body/footer */
    .modal-content {
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        width: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
        flex: 1 !important;
    }
    
    /* Headers - fixos no topo */
    .modal-header,
    .modal-header-padrao {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
    }
    
    /* Bodies - flex 1 para preencher espaço disponível com scroll */
    .modal-body,
    .modal-body-padrao,
    .modal-body-container {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        min-height: 0 !important;
    }
    
    .modal-body-padrao {
        padding: 12px !important;
    }
    
    /* Footers - fixos no fundo */
    .modal-footer,
    .modal-footer-padrao {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
    }
    
    .modal-footer-padrao {
        padding: 12px !important;
    }
    
    /* Limpar margens/paddings extras */
    .modal-body-padrao form,
    .modal-body-padrao .row:last-child,
    .modal-body-padrao .col-md-12:last-child,
    .modal-body-padrao .modal-section:last-child {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    
    .modal-body-padrao .modal-section {
        margin-bottom: 12px !important;
    }
}

