/* ========================================
   FUNIL DE VENDAS - ESTILOS ISOLADOS
   ======================================== */

/* Container principal do funil */
.funil-vendas-container {
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin: 20px 0;
    min-height: 600px;
}

/* Grid das etapas do funil */
.funil-vendas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* Etapa individual do funil */
.funil-vendas-stage {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.06);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.funil-vendas-stage:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    border-color: #007bff;
}

/* Cabeçalho da etapa */
.funil-vendas-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 16px 20px;
    text-align: center;
    position: relative;
    border-radius: 10px 10px 0 0;
}

.funil-vendas-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Contador de leads */
.funil-vendas-count {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    margin-top: 8px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

/* Cores específicas para cada etapa */
.funil-vendas-stage[data-stage="lead-captado"] .funil-vendas-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.funil-vendas-stage[data-stage="primeiro-contato"] .funil-vendas-header {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

.funil-vendas-stage[data-stage="agendamento-feito"] .funil-vendas-header {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
}

.funil-vendas-stage[data-stage="recontato-pendente"] .funil-vendas-header {
    background: linear-gradient(135deg, #fd7e14 0%, #e55a00 100%);
}

.funil-vendas-stage[data-stage="proposta-enviada"] .funil-vendas-header {
    background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%);
}

.funil-vendas-stage[data-stage="em-negociacao"] .funil-vendas-header {
    background: linear-gradient(135deg, #e83e8c 0%, #c42170 100%);
}

.funil-vendas-stage[data-stage="aprovado"] .funil-vendas-header {
    background: linear-gradient(135deg, #20c997 0%, #198754 100%);
}

.funil-vendas-stage[data-stage="contrato-assinado"] .funil-vendas-header {
    background: linear-gradient(135deg, #198754 0%, #146c43 100%);
}

/* Área de conteúdo dos leads */
.funil-vendas-content {
    flex: 1;
    padding: 20px;
    background: #ffffff;
    overflow-y: auto;
    max-height: 380px;
}

/* Card individual do lead */
.funil-lead-card {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 4px solid #007bff;
}

.funil-lead-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left-color: #0056b3;
}

.funil-lead-card:last-child {
    margin-bottom: 0;
}

/* Nome da empresa no card */
.funil-lead-name {
    font-weight: 600;
    font-size: 15px;
    color: #212529;
    margin-bottom: 8px;
    line-height: 1.3;
}

/* Informações do lead */
.funil-lead-info {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.funil-lead-info i {
    width: 16px;
    margin-right: 8px;
    color: #007bff;
}

/* Badge de potencial */
.funil-lead-potential {
    margin: 12px 0 8px 0;
}

.funil-potential-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.funil-potential-badge.potencial-alto {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.funil-potential-badge.potencial-medio {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.funil-potential-badge.potencial-baixo {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f1aeb5;
}

/* Ações do card */
.funil-lead-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

.funil-btn-icon {
    background: transparent;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6c757d;
    font-size: 12px;
}

.funil-btn-icon:hover {
    background: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
    transform: scale(1.05);
}

.funil-btn-icon.btn-danger:hover {
    background: #f8d7da;
    border-color: #dc3545;
    color: #dc3545;
}

/* Estado vazio */
.funil-no-leads {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
    border: 2px dashed #dee2e6;
}

.funil-no-leads i {
    font-size: 24px;
    margin-bottom: 12px;
    color: #adb5bd;
}

/* Animações */
@keyframes funil-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.funil-lead-card {
    animation: funil-fadeIn 0.3s ease;
}

/* Indicador de carregamento */
.funil-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #6c757d;
}

.funil-loading i {
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsividade */
@media (max-width: 768px) {
    .funil-vendas-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .funil-vendas-container {
        padding: 15px;
    }
    
    .funil-vendas-stage {
        min-height: 350px;
    }
    
    .funil-vendas-content {
        max-height: 280px;
    }
}

@media (max-width: 480px) {
    .funil-vendas-header {
        padding: 12px 15px;
    }
    
    .funil-vendas-header h3 {
        font-size: 14px;
    }
    
    .funil-lead-card {
        padding: 12px;
    }
    
    .funil-lead-actions {
        flex-wrap: wrap;
    }
}

/* Scroll personalizado */
.funil-vendas-content::-webkit-scrollbar {
    width: 6px;
}

.funil-vendas-content::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 3px;
}

.funil-vendas-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.funil-vendas-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Estados especiais */
.funil-vendas-stage.highlight {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.funil-lead-card.selected {
    background: #e7f3ff;
    border-left-color: #007bff;
    border-left-width: 6px;
}

/* Tooltip para informações extras */
.funil-tooltip {
    position: relative;
}

.funil-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0.9;
}

/* ========================================
   MODAL DE DETALHES - MELHORIAS
   ======================================== */

.lead-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

/* Responsividade para tablets */
@media (max-width: 992px) {
    .lead-details-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.lead-actions {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e9ecef;
}

.lead-actions h4 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 18px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.action-buttons select {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    transition: all 0.2s ease;
}

.action-buttons select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
    outline: none;
}

.action-buttons button {
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.lead-observations {
    background: white;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e9ecef;
    margin-top: 20px;
}

.lead-observations h4 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.observations-text {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

.observations-text i {
    color: #007bff;
    margin-right: 10px;
}

.observations-text p {
    margin: 0;
    color: #495057;
    line-height: 1.5;
    font-style: italic;
}

.no-observations {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.no-observations i {
    font-size: 24px;
    margin-bottom: 10px;
    color: #adb5bd;
}

.no-observations p {
    margin: 0;
}

/* ========================================
   HISTÓRICO DE INTERAÇÕES - CONTAINER
   ======================================== */

.lead-history-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.lead-history-container h4 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 18px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-history-container h4::before {
    content: '\f1da';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #007bff;
}

#lead-history-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #dee2e6;
}

.history-item {
    background: white;
    border-left: 4px solid #007bff;
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.history-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-date {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 500;
}

.history-content {
    color: #495057;
    line-height: 1.5;
}

.history-content strong {
    color: #212529;
    font-weight: 600;
}

.add-interaction {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #dee2e6;
}

.add-interaction textarea {
    width: 100%;
    min-height: 160px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 12px;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 12px;
    transition: border-color 0.2s ease;
}

.add-interaction textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
    outline: none;
}

.add-interaction button {
    border-radius: 6px;
    padding: 10px 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Scroll personalizado para histórico */
#lead-history-list::-webkit-scrollbar {
    width: 6px;
}

#lead-history-list::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 3px;
}

#lead-history-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#lead-history-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Estado vazio do histórico */
.no-history {
    text-align: center;
    padding: 30px 20px;
    color: #6c757d;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.no-history i {
    font-size: 24px;
    margin-bottom: 12px;
    color: #adb5bd;
}

/* ========================================
   MODAL BODY - SCROLL
   ======================================== */

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
}

/* Scroll personalizado para modal-body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ajustes para responsividade */
@media (max-width: 768px) {
    .modal-body {
        max-height: 70vh;
        padding: 12px;
    }
    
    .lead-details-grid {
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .lead-actions,
    .lead-history-container {
        padding: 15px;
    }
    
    .lead-action-card {
        margin-bottom: 12px;
    }
    
    #lead-history-list {
        max-height: 200px;
        padding: 10px;
    }
    
    .add-interaction textarea {
        min-height: 120px;
        font-size: 16px; /* Evita zoom no iOS */
    }
}

@media (max-width: 480px) {
    .modal-body {
        max-height: 75vh;
        padding: 10px;
    }
    
    .lead-details-grid {
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .lead-actions,
    .lead-history-container {
        padding: 12px;
        border-radius: 8px;
    }
    
    .lead-actions h4,
    .lead-history-container h4 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    #lead-history-list {
        max-height: 150px;
        padding: 8px;
    }
    
    .history-item {
        padding: 10px;
        margin-bottom: 8px;
    }
    
    .add-interaction {
        padding: 10px;
    }
    
    .add-interaction textarea {
        min-height: 120px;
        padding: 10px;
        font-size: 16px; /* Evita zoom no iOS */
    }
    
    .add-interaction button {
        width: 100%;
        justify-content: center;
    }
}