* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --success-dark: #059669;
    --danger-color: #ef4444;
    --danger-dark: #dc2626;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-attachment: fixed;
    color: var(--gray-900);
    line-height: 1.6;
}

/* ===== LOGIN ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: moveBackground 20s linear infinite;
}

@keyframes moveBackground {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.login-box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 3rem 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease-out;
}

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

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.login-box h1 {
    margin-bottom: 0.5rem;
    color: var(--gray-900);
    font-size: 1.75rem;
    font-weight: 700;
}

.login-subtitle {
    color: var(--gray-600);
    font-size: 0.95rem;
    margin: 0;
}

.form-group {
    margin-bottom: 0.75rem;
}

/* Grid de duas colunas para campos do formulário - aplicado apenas no modal de paciente */
#patientModal .modal-content form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1rem;
    align-content: start;
}

/* Campos que ocupam largura total */
#patientModal .modal-content form .form-group:has(textarea),
#patientModal .modal-content form .form-group:has(#patientObservacoes),
#patientModal .modal-content form .form-group:has(#patientPersonalidade),
#patientModal .modal-content form .form-group:has(select#patientStatus) {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background-color: var(--gray-50);
}

.form-group textarea {
    padding: 0.65rem 0.85rem;
    min-height: 70px;
    resize: vertical;
}

.form-group input::placeholder {
    color: var(--gray-400);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group input[readonly] {
    background-color: var(--gray-100);
    cursor: not-allowed;
}

/* Estilo para select no formulário */
.form-group select {
    width: 100%;
    padding: 0.65rem 2.25rem 0.65rem 0.85rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background-color: var(--gray-50);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group select option {
    padding: 0.5rem;
    background: white;
    color: var(--gray-900);
}

/* Estilos específicos para campo de status no formulário */
#patientStatus {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Cores por status no formulário - PENDENTE */
#patientStatus[value="PENDENTE"],
#patientStatus.status-pending,
#patientStatus:has(option[value="PENDENTE"]:checked) {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2392400e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

#patientStatus[value="PENDENTE"]:focus,
#patientStatus.status-pending:focus {
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), 0 2px 4px rgba(245, 158, 11, 0.3);
}

/* Cores por status no formulário - ENVIADO */
#patientStatus[value="ENVIADO"],
#patientStatus.status-sent {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23065f46' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

#patientStatus[value="ENVIADO"]:focus,
#patientStatus.status-sent:focus {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), 0 2px 4px rgba(16, 185, 129, 0.3);
}

/* Cores por status no formulário - AGUARDANDO ATENDIMENTO HUMANO */
#patientStatus[value="AGUARDANDO ATENDIMENTO HUMANO"],
#patientStatus.status-aguardando-atendimento-humano {
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235b21b6' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #5b21b6;
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

#patientStatus[value="AGUARDANDO ATENDIMENTO HUMANO"]:focus,
#patientStatus.status-aguardando-atendimento-humano:focus {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2), 0 2px 4px rgba(139, 92, 246, 0.3);
}

/* Cores por status no formulário - ATENDIMENTO HUMANO */
#patientStatus[value="ATENDIMENTO HUMANO"],
#patientStatus.status-atendimento-humano {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231e40af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #1e40af;
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

#patientStatus[value="ATENDIMENTO HUMANO"]:focus,
#patientStatus.status-atendimento-humano:focus {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* Cores por status no formulário - ATENDIMENTO IA */
#patientStatus[value="ATENDIMENTO IA"],
#patientStatus.status-atendimento-ia {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2392400e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

#patientStatus[value="ATENDIMENTO IA"]:focus,
#patientStatus.status-atendimento-ia:focus {
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), 0 2px 4px rgba(245, 158, 11, 0.3);
}

/* Cores por status no formulário - ENVIADO LINK DE AGENDAMENTO */
#patientStatus[value="ENVIADO LINK DE AGENDAMENTO"],
#patientStatus.status-enviado-link-de-agendamento {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231e40af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #1e40af;
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

#patientStatus[value="ENVIADO LINK DE AGENDAMENTO"]:focus,
#patientStatus.status-enviado-link-de-agendamento:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Cores por status no formulário - SEM INTERESSE */
#patientStatus[value="SEM INTERESSE"],
#patientStatus.status-sem-interesse {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23991b1b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

#patientStatus[value="SEM INTERESSE"]:focus,
#patientStatus.status-sem-interesse:focus {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2), 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Cores por status no formulário - LIXEIRA */
#patientStatus[value="LIXEIRA"],
#patientStatus.status-lixeira {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23991b1b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

#patientStatus[value="LIXEIRA"]:focus,
#patientStatus.status-lixeira:focus {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2), 0 2px 4px rgba(239, 68, 68, 0.4);
}

.error-message {
    color: var(--danger-color);
    margin-top: 0.5rem;
    font-size: 0.9rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* ===== BOTÕES ===== */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before,
.btn-secondary::before,
.btn-success::before,
.btn-danger::before,
.btn-edit::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before,
.btn-secondary:hover::before,
.btn-success:hover::before,
.btn-danger:hover::before,
.btn-edit:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.875rem 1.75rem;
    box-shadow: var(--shadow-md);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--gray-600) 0%, var(--gray-700) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

a.btn-secondary {
    text-decoration: none;
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-dark) 100%);
    color: white;
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
    box-shadow: var(--shadow);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-edit {
    background: linear-gradient(135deg, var(--info-color) 0%, #2563eb 100%);
    color: white;
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    box-shadow: var(--shadow);
}

.btn-edit:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-history {
    background: none;
    border: 1.5px solid #8b5cf6;
    color: #8b5cf6;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-history:hover {
    background: #8b5cf6;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.btn-history span {
    display: inline-block;
    line-height: 1;
}

.btn-history-icon {
    background: none;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #8b5cf6;
}

.btn-history-icon:hover {
    background: rgba(139, 92, 246, 0.1);
    transform: scale(1.1);
}

.btn-icon {
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.btn-primary:hover .btn-icon {
    transform: translateX(3px);
}

/* ===== DASHBOARD ===== */
.dashboard-container {
    min-height: 100vh;
    padding: 2rem 2.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding: 1.5rem 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-header h1 {
    color: var(--gray-900);
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.header-subtitle {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0;
    margin-top: 0.25rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#logoutBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-webhook-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
    color: white;
}

.btn-webhook-toggle.production {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
}

.btn-webhook-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-webhook-toggle:hover::before {
    width: 300px;
    height: 300px;
}

.btn-webhook-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== ESTATÍSTICAS ===== */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    border-top: 4px solid var(--primary-color);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card:nth-child(2) {
    border-top-color: var(--warning-color);
}

.stat-card:nth-child(3) {
    border-top-color: var(--success-color);
}

.stat-card:nth-child(4) {
    border-top-color: var(--gray-500);
}

.stat-card:nth-child(5) {
    border-top-color: #8b5cf6;
}

.stat-card:nth-child(6) {
    border-top-color: #2563eb;
}

.stat-card:nth-child(7) {
    border-top-color: #f59e0b;
}

.stat-card:nth-child(8) {
    border-top-color: #3b82f6;
}

.stat-card:nth-child(9) {
    border-top-color: #ef4444;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.stat-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.stat-card:hover .stat-value {
    transform: scale(1.1);
}

.stat-pending {
    color: var(--warning-color);
}

.stat-sent {
    color: var(--success-color);
}

.stat-removed {
    color: var(--gray-500);
}

.stat-agendamento {
    color: #8b5cf6;
}

.stat-atendimento-humano {
    color: #2563eb;
}

.stat-em-atendimento {
    color: #f59e0b;
}

.stat-enviado-link {
    color: #3b82f6;
}

.stat-sem-interesse {
    color: #ef4444;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* ===== AÇÕES ===== */
.actions-section {
    margin-bottom: 2.5rem;
}

.primary-actions {
    margin-bottom: 1.25rem;
}

.primary-actions .btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.05rem;
    max-width: 400px;
}

.secondary-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.secondary-actions button {
    flex: 1;
    min-width: 180px;
    max-width: 250px;
}

/* ===== CONTROLES DE VISUALIZAÇÃO ===== */
.view-controls {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.view-controls-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--gray-100);
    padding: 0.375rem;
    border-radius: 12px;
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.9rem;
    min-width: 100px;
    justify-content: center;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--gray-900);
}

.view-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.view-controls-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 300px;
    justify-content: flex-end;
}

.search-filter {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 300px;
    max-width: 800px;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background-color: var(--gray-50);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-select {
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 0.95rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-select[type="date"] {
    cursor: pointer;
    font-family: inherit;
}

.filter-select[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.filter-select[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Grupo de filtros de data */
.date-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-filter-group .filter-select {
    min-width: 140px;
}

/* Filtros rápidos de ano */
.quick-year-filters {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    flex-wrap: wrap;
}

.quick-year-btn {
    padding: 0.625rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background-color: white;
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
    text-align: center;
    white-space: nowrap;
}

.quick-year-btn:hover {
    background-color: var(--gray-50);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.quick-year-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.quick-year-btn.active:hover {
    background-color: var(--primary-color-dark, #667eea);
    transform: translateY(-1px);
}

/* Responsividade para tablets */
@media (max-width: 1024px) {
    .date-filter-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .date-filter-group .filter-select {
        flex: 1;
        min-width: 140px;
    }

    .quick-year-filters {
        width: 100%;
        justify-content: flex-start;
    }

    .quick-year-btn {
        flex: 0 1 auto;
        min-width: 50px;
    }
}

/* ===== CARDS DE PACIENTES ===== */
.cards-section {
    margin-bottom: 2rem;
}

.patients-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.875rem;
}

.patient-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1.5px solid var(--gray-200);
    position: relative;
}

.patient-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.patient-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-checkbox-wrapper {
    display: flex;
    align-items: center;
}

.card-body {
    padding: 0.875rem 1rem;
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}

.card-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    flex: 1;
}

.card-id {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 600;
    background: var(--gray-100);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.8125rem;
}

.info-item.full-width {
    flex-direction: column;
    gap: 0.5rem;
}

.info-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.info-label {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.75rem;
    min-width: 85px;
    flex-shrink: 0;
}

.info-item.full-width .info-label {
    min-width: auto;
}

.info-item.info-personalidade {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.personalidade-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    width: 100%;
}

.personalidade-header:hover {
    background-color: var(--gray-50);
}

.personalidade-header .info-icon,
.personalidade-header .info-label {
    margin: 0;
}

.btn-toggle-personalidade {
    background: none;
    border: none;
    padding: 0;
    margin-left: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: all 0.2s ease;
}

.btn-toggle-personalidade:hover {
    color: var(--gray-700);
}

.toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.personalidade-content {
    padding: 0;
    background: var(--gray-50);
    border-radius: 6px;
    margin-top: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
    max-height: 0;
    opacity: 0;
}

.personalidade-content .info-value {
    display: block;
    color: var(--gray-900);
    font-size: 0.8125rem;
    line-height: 1.5;
    word-break: break-word;
}


.info-value {
    color: var(--gray-900);
    font-size: 0.8125rem;
    flex: 1;
    word-break: break-word;
}

.info-item.full-width .info-value {
    background: var(--gray-50);
    padding: 0.625rem;
    border-radius: 6px;
    line-height: 1.4;
    font-size: 0.8125rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.card-actions button {
    flex: 1;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    min-height: auto;
}

.card-actions .btn-history {
    flex: 0 0 auto;
    padding: 0.45rem 0.6rem;
    min-width: 38px;
    max-width: 38px;
    width: 38px;
    height: auto;
    gap: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
}

.card-actions .btn-history span {
    font-size: 1rem;
    display: inline-block;
    line-height: 1;
    margin: 0;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-500);
    font-size: 1rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
}

/* ===== PAGINAÇÃO ===== */
.pagination {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-btn {
    padding: 0.5rem 0.875rem;
    border: 2px solid var(--gray-200);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    transition: all 0.2s ease;
    min-width: 40px;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--gray-50);
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 0.5rem 0.25rem;
    color: var(--gray-500);
    font-weight: 600;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ===== INFO DE RESULTADOS ===== */
.results-info {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.results-info #resultsCount {
    font-weight: 700;
    color: var(--primary-color);
}

.selected-info {
    color: var(--gray-600);
}

.selected-info #selectedNumber {
    font-weight: 700;
    color: var(--success-color);
}

/* ===== TABELA ===== */
.table-section {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.patients-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.patients-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.patients-table th {
    padding: 0.625rem 0.5rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.patients-table th.col-checkbox {
    text-align: center;
    width: 30px;
}

.patients-table th input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.patients-table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
    font-size: 0.8rem;
}

/* Visualização Compacta */
.patients-table.compact-table .col-checkbox {
    width: 30px;
    text-align: center;
}

.patients-table.compact-table .col-id {
    width: 50px;
    white-space: nowrap;
}

.patients-table.compact-table .col-name {
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.patients-table.compact-table .col-phone {
    white-space: nowrap;
    width: 130px;
}

.patients-table.compact-table .col-convenio {
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patients-table.compact-table .col-ultima-consulta {
    white-space: nowrap;
    width: 120px;
    font-size: 0.75rem;
}

.patients-table.compact-table .col-status {
    width: 100px;
    white-space: nowrap;
}

.patients-table.compact-table .col-actions {
    width: 80px;
    white-space: nowrap;
}

.patients-table.compact-table .hidden-col {
    display: none;
}

/* Visualização Completa */
.patients-table.full-table .col-name {
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patients-table.full-table .col-phone {
    white-space: nowrap;
}

.patients-table.full-table .col-convenio {
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
    justify-content: center;
}

.btn-icon-only {
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
}

.btn-icon-only:hover {
    background: var(--gray-100);
    transform: scale(1.1);
}

.btn-edit-icon:hover {
    background: rgba(59, 130, 246, 0.1);
}

.btn-history-icon:hover {
    background: rgba(139, 92, 246, 0.1);
}

.btn-danger-icon:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-success-icon:hover {
    background: rgba(16, 185, 129, 0.1);
}

.patients-table tbody tr {
    transition: all 0.2s ease;
}

.patients-table tbody tr:hover {
    background-color: var(--gray-50);
}

.patient-row.selected {
    background-color: rgba(102, 126, 234, 0.05);
}

.patient-details {
    font-size: 0.75rem;
    color: var(--gray-600);
    line-height: 1.6;
}

.patient-details div {
    margin-bottom: 0.5rem;
}

.patient-details-modal {
    padding: 1.5rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.details-grid div {
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 8px;
}

.details-grid .full-width {
    grid-column: 1 / -1;
}

.details-grid strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.patients-table tbody tr:last-child td {
    border-bottom: none;
}

.loading-message {
    text-align: center;
    color: var(--gray-600);
    padding: 3rem !important;
    font-style: italic;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== OVERLAY DE CARREGAMENTO PARA WEBHOOK ===== */
.webhook-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: all;
}

.webhook-loading-overlay.show {
    opacity: 1;
}

.webhook-loading-content {
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    min-width: 280px;
    text-align: center;
}

.webhook-loading-content .loading-spinner {
    width: 50px;
    height: 50px;
    border-width: 5px;
}

.webhook-loading-message {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-700);
    margin: 0;
}

.patient-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.table-actions .btn-edit,
.table-actions .btn-danger {
    margin: 0;
    white-space: nowrap;
}

/* ===== STATUS BADGE ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-pending {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.status-sent {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.status-lixeira {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ===== ESTILOS DE STATUS PARA CARDS E TABELAS ===== */

/* PENDENTE - Amarelo suave */
.patient-card.status-pending,
.patient-card[data-status="PENDENTE"] {
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
    border-left: 3px solid #fbbf24;
}

.patient-card.status-pending .card-header,
.patient-card[data-status="PENDENTE"] .card-header {
    background: linear-gradient(135deg, #fef3c7 0%, #fef9e7 100%);
}

.patient-card.status-pending:hover,
.patient-card[data-status="PENDENTE"]:hover {
    border-left-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.patient-row.status-pending,
.patient-row[data-status="PENDENTE"],
tr.status-pending,
tr[data-status="PENDENTE"] {
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
    border-left: 3px solid #fbbf24;
}

.patient-row.status-pending:hover,
.patient-row[data-status="PENDENTE"]:hover,
tr.status-pending:hover,
tr[data-status="PENDENTE"]:hover {
    background: linear-gradient(135deg, #fef3c7 0%, #ffffff 100%);
}

/* ENVIADO - Verde suave */
.patient-card.status-enviado,
.patient-card[data-status="ENVIADO"] {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-left: 3px solid #86efac;
}

.patient-card.status-enviado .card-header,
.patient-card[data-status="ENVIADO"] .card-header {
    background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
}

.patient-card.status-enviado:hover,
.patient-card[data-status="ENVIADO"]:hover {
    border-left-color: #4ade80;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
}

.patient-row.status-enviado,
.patient-row[data-status="ENVIADO"],
tr.status-enviado,
tr[data-status="ENVIADO"] {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-left: 3px solid #86efac;
}

.patient-row.status-enviado:hover,
.patient-row[data-status="ENVIADO"]:hover,
tr.status-enviado:hover,
tr[data-status="ENVIADO"]:hover {
    background: linear-gradient(135deg, #d1fae5 0%, #ffffff 100%);
}

/* AGUARDANDO ATENDIMENTO HUMANO - Roxo suave */
.patient-card.status-aguardando-atendimento-humano,
.patient-card[data-status="AGUARDANDO ATENDIMENTO HUMANO"] {
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%);
    border-left: 3px solid #c4b5fd;
}

.patient-card.status-aguardando-atendimento-humano .card-header,
.patient-card[data-status="AGUARDANDO ATENDIMENTO HUMANO"] .card-header {
    background: linear-gradient(135deg, #e9d5ff 0%, #f3e8ff 100%);
}

.patient-card.status-aguardando-atendimento-humano:hover,
.patient-card[data-status="AGUARDANDO ATENDIMENTO HUMANO"]:hover {
    border-left-color: #a78bfa;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15);
}

.patient-row.status-aguardando-atendimento-humano,
.patient-row[data-status="AGUARDANDO ATENDIMENTO HUMANO"],
tr.status-aguardando-atendimento-humano,
tr[data-status="AGUARDANDO ATENDIMENTO HUMANO"] {
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%);
    border-left: 3px solid #c4b5fd;
}

.patient-row.status-aguardando-atendimento-humano:hover,
.patient-row[data-status="AGUARDANDO ATENDIMENTO HUMANO"]:hover,
tr.status-aguardando-atendimento-humano:hover,
tr[data-status="AGUARDANDO ATENDIMENTO HUMANO"]:hover {
    background: linear-gradient(135deg, #e9d5ff 0%, #ffffff 100%);
}

/* ATENDIMENTO HUMANO - Azul intenso */
.patient-card.status-atendimento-humano,
.patient-card[data-status="ATENDIMENTO HUMANO"] {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 3px solid #60a5fa;
}

.patient-card.status-atendimento-humano .card-header,
.patient-card[data-status="ATENDIMENTO HUMANO"] .card-header {
    background: linear-gradient(135deg, #bfdbfe 0%, #dbeafe 100%);
}

.patient-card.status-atendimento-humano:hover,
.patient-card[data-status="ATENDIMENTO HUMANO"]:hover {
    border-left-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.patient-row.status-atendimento-humano,
.patient-row[data-status="ATENDIMENTO HUMANO"],
tr.status-atendimento-humano,
tr[data-status="ATENDIMENTO HUMANO"] {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 3px solid #60a5fa;
}

.patient-row.status-atendimento-humano:hover,
.patient-row[data-status="ATENDIMENTO HUMANO"]:hover,
tr.status-atendimento-humano:hover,
tr[data-status="ATENDIMENTO HUMANO"]:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #ffffff 100%);
}

/* ATENDIMENTO IA - Laranja suave */
.patient-card.status-atendimento-ia,
.patient-card[data-status="ATENDIMENTO IA"] {
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
    border-left: 3px solid #fdba74;
}

.patient-card.status-atendimento-ia .card-header,
.patient-card[data-status="ATENDIMENTO IA"] .card-header {
    background: linear-gradient(135deg, #fed7aa 0%, #ffedd5 100%);
}

.patient-card.status-atendimento-ia:hover,
.patient-card[data-status="ATENDIMENTO IA"]:hover {
    border-left-color: #fb923c;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
}

.patient-row.status-atendimento-ia,
.patient-row[data-status="ATENDIMENTO IA"],
tr.status-atendimento-ia,
tr[data-status="ATENDIMENTO IA"] {
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
    border-left: 3px solid #fdba74;
}

.patient-row.status-atendimento-ia:hover,
.patient-row[data-status="ATENDIMENTO IA"]:hover,
tr.status-atendimento-ia:hover,
tr[data-status="ATENDIMENTO IA"]:hover {
    background: linear-gradient(135deg, #fed7aa 0%, #ffffff 100%);
}

/* ENVIADO LINK DE AGENDAMENTO - Azul suave */
.patient-card.status-enviado-link-de-agendamento,
.patient-card[data-status="ENVIADO LINK DE AGENDAMENTO"] {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 3px solid #93c5fd;
}

.patient-card.status-enviado-link-de-agendamento .card-header,
.patient-card[data-status="ENVIADO LINK DE AGENDAMENTO"] .card-header {
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
}

.patient-card.status-enviado-link-de-agendamento:hover,
.patient-card[data-status="ENVIADO LINK DE AGENDAMENTO"]:hover {
    border-left-color: #60a5fa;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.patient-row.status-enviado-link-de-agendamento,
.patient-row[data-status="ENVIADO LINK DE AGENDAMENTO"],
tr.status-enviado-link-de-agendamento,
tr[data-status="ENVIADO LINK DE AGENDAMENTO"] {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 3px solid #93c5fd;
}

.patient-row.status-enviado-link-de-agendamento:hover,
.patient-row[data-status="ENVIADO LINK DE AGENDAMENTO"]:hover,
tr.status-enviado-link-de-agendamento:hover,
tr[data-status="ENVIADO LINK DE AGENDAMENTO"]:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #ffffff 100%);
}

/* SEM INTERESSE - Vermelho suave (mais suave que lixeira) */
.patient-card.status-sem-interesse,
.patient-card[data-status="SEM INTERESSE"] {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-left: 3px solid #fca5a5;
}

.patient-card.status-sem-interesse .card-header,
.patient-card[data-status="SEM INTERESSE"] .card-header {
    background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%);
}

.patient-card.status-sem-interesse:hover,
.patient-card[data-status="SEM INTERESSE"]:hover {
    border-left-color: #f87171;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.patient-row.status-sem-interesse,
.patient-row[data-status="SEM INTERESSE"],
tr.status-sem-interesse,
tr[data-status="SEM INTERESSE"] {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-left: 3px solid #fca5a5;
}

.patient-row.status-sem-interesse:hover,
.patient-row[data-status="SEM INTERESSE"]:hover,
tr.status-sem-interesse:hover,
tr[data-status="SEM INTERESSE"]:hover {
    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%);
}

/* LIXEIRA - Vermelho suave (mais intenso que sem interesse) */
.patient-card.status-lixeira,
.patient-card[data-status="LIXEIRA"] {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-left: 3px solid #ef4444;
}

.patient-card.status-lixeira .card-header,
.patient-card[data-status="LIXEIRA"] .card-header {
    background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%);
}

.patient-card.status-lixeira:hover,
.patient-card[data-status="LIXEIRA"]:hover {
    border-left-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.patient-row.status-lixeira,
.patient-row[data-status="LIXEIRA"],
tr.status-lixeira,
tr[data-status="LIXEIRA"] {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-left: 3px solid #ef4444;
}

.patient-row.status-lixeira:hover,
.patient-row[data-status="LIXEIRA"]:hover,
tr.status-lixeira:hover,
tr[data-status="LIXEIRA"]:hover {
    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%);
}

/* ===== ESTILOS DE STATUS PARA CARDS DE ANÁLISE ===== */

/* PENDENTE - Amarelo suave */
.patient-card-analysis.status-pending,
.patient-card-analysis[data-status="PENDENTE"] {
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
    border-left: 3px solid #fbbf24;
}

.patient-card-analysis.status-pending:hover,
.patient-card-analysis[data-status="PENDENTE"]:hover {
    border-left-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

/* ENVIADO - Verde suave */
.patient-card-analysis.status-enviado,
.patient-card-analysis[data-status="ENVIADO"] {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-left: 3px solid #86efac;
}

.patient-card-analysis.status-enviado:hover,
.patient-card-analysis[data-status="ENVIADO"]:hover {
    border-left-color: #4ade80;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
}

/* AGUARDANDO ATENDIMENTO HUMANO - Roxo suave */
.patient-card-analysis.status-aguardando-atendimento-humano,
.patient-card-analysis[data-status="AGUARDANDO ATENDIMENTO HUMANO"] {
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%);
    border-left: 3px solid #c4b5fd;
}

.patient-card-analysis.status-aguardando-atendimento-humano:hover,
.patient-card-analysis[data-status="AGUARDANDO ATENDIMENTO HUMANO"]:hover {
    border-left-color: #a78bfa;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15);
}

/* ATENDIMENTO HUMANO - Azul intenso */
.patient-card-analysis.status-atendimento-humano,
.patient-card-analysis[data-status="ATENDIMENTO HUMANO"] {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 3px solid #60a5fa;
}

.patient-card-analysis.status-atendimento-humano:hover,
.patient-card-analysis[data-status="ATENDIMENTO HUMANO"]:hover {
    border-left-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

/* ATENDIMENTO IA - Laranja suave */
.patient-card-analysis.status-atendimento-ia,
.patient-card-analysis[data-status="ATENDIMENTO IA"] {
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
    border-left: 3px solid #fdba74;
}

.patient-card-analysis.status-atendimento-ia:hover,
.patient-card-analysis[data-status="ATENDIMENTO IA"]:hover {
    border-left-color: #fb923c;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
}

/* ENVIADO LINK DE AGENDAMENTO - Azul suave */
.patient-card-analysis.status-enviado-link-de-agendamento,
.patient-card-analysis[data-status="ENVIADO LINK DE AGENDAMENTO"] {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 3px solid #93c5fd;
}

.patient-card-analysis.status-enviado-link-de-agendamento:hover,
.patient-card-analysis[data-status="ENVIADO LINK DE AGENDAMENTO"]:hover {
    border-left-color: #60a5fa;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

/* SEM INTERESSE - Vermelho suave */
.patient-card-analysis.status-sem-interesse,
.patient-card-analysis[data-status="SEM INTERESSE"] {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-left: 3px solid #fca5a5;
}

.patient-card-analysis.status-sem-interesse:hover,
.patient-card-analysis[data-status="SEM INTERESSE"]:hover {
    border-left-color: #f87171;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

/* LIXEIRA - Vermelho suave */
.patient-card-analysis.status-lixeira,
.patient-card-analysis[data-status="LIXEIRA"] {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-left: 3px solid #ef4444;
}

.patient-card-analysis.status-lixeira:hover,
.patient-card-analysis[data-status="LIXEIRA"]:hover {
    border-left-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Compatibilidade com status-removed (caso ainda exista) */
.status-removed {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.status-agendamento {
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
    color: #5b21b6;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

.status-aguardando-atendimento-humano {
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
    color: #5b21b6;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

.status-em-atendimento {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    color: #92400e;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.status-atendimento-ia {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    color: #92400e;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.status-enviado-link {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.status-enviado-link-de-agendamento {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.status-sem-interesse {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

/* ===== DROPDOWN DE STATUS ===== */
.status-dropdown,
.status-dropdown-card {
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border: 2px solid transparent;
    cursor: pointer;
    background: var(--gray-50);
    color: var(--gray-700);
    transition: all 0.3s ease;
    min-width: 140px;
    max-width: 220px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.status-dropdown:hover,
.status-dropdown-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.status-dropdown:focus,
.status-dropdown-card:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.status-dropdown option,
.status-dropdown-card option {
    padding: 0.5rem;
    background: white;
    color: var(--gray-900);
    text-transform: none;
    font-weight: normal;
}

/* Cores por status - PENDENTE */
.status-dropdown[value="PENDENTE"],
.status-dropdown-card[value="PENDENTE"],
.status-dropdown.status-pending,
.status-dropdown-card.status-pending {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2392400e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.status-dropdown[value="PENDENTE"]:hover,
.status-dropdown-card[value="PENDENTE"]:hover,
.status-dropdown.status-pending:hover,
.status-dropdown-card.status-pending:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

/* Cores por status - ENVIADO */
.status-dropdown[value="ENVIADO"],
.status-dropdown-card[value="ENVIADO"],
.status-dropdown.status-sent,
.status-dropdown-card.status-sent {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23065f46' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.status-dropdown[value="ENVIADO"]:hover,
.status-dropdown-card[value="ENVIADO"]:hover,
.status-dropdown.status-sent:hover,
.status-dropdown-card.status-sent:hover {
    background: linear-gradient(135deg, #a7f3d0 0%, #6ee7b7 100%);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* Cores por status - AGUARDANDO ATENDIMENTO HUMANO */
.status-dropdown[value="AGUARDANDO ATENDIMENTO HUMANO"],
.status-dropdown-card[value="AGUARDANDO ATENDIMENTO HUMANO"],
.status-dropdown.status-aguardando-atendimento-humano,
.status-dropdown-card.status-aguardando-atendimento-humano {
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235b21b6' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #5b21b6;
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

.status-dropdown[value="AGUARDANDO ATENDIMENTO HUMANO"]:hover,
.status-dropdown-card[value="AGUARDANDO ATENDIMENTO HUMANO"]:hover,
.status-dropdown.status-aguardando-atendimento-humano:hover,
.status-dropdown-card.status-aguardando-atendimento-humano:hover {
    background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
    box-shadow: 0 4px 8px rgba(139, 92, 246, 0.3);
}

/* Cores por status - ATENDIMENTO HUMANO */
.status-dropdown[value="ATENDIMENTO HUMANO"],
.status-dropdown-card[value="ATENDIMENTO HUMANO"],
.status-dropdown.status-atendimento-humano,
.status-dropdown-card.status-atendimento-humano {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231e40af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #1e40af;
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.status-dropdown[value="ATENDIMENTO HUMANO"]:hover,
.status-dropdown-card[value="ATENDIMENTO HUMANO"]:hover,
.status-dropdown.status-atendimento-humano:hover,
.status-dropdown-card.status-atendimento-humano:hover {
    background: linear-gradient(135deg, #93c5fd 0%, #60a5fa 100%);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* Cores por status - ATENDIMENTO IA */
.status-dropdown[value="ATENDIMENTO IA"],
.status-dropdown-card[value="ATENDIMENTO IA"],
.status-dropdown.status-atendimento-ia,
.status-dropdown-card.status-atendimento-ia {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2392400e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.status-dropdown[value="ATENDIMENTO IA"]:hover,
.status-dropdown-card[value="ATENDIMENTO IA"]:hover,
.status-dropdown.status-atendimento-ia:hover,
.status-dropdown-card.status-atendimento-ia:hover {
    background: linear-gradient(135deg, #fdba74 0%, #fb923c 100%);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

/* Cores por status - ENVIADO LINK DE AGENDAMENTO */
.status-dropdown[value="ENVIADO LINK DE AGENDAMENTO"],
.status-dropdown-card[value="ENVIADO LINK DE AGENDAMENTO"],
.status-dropdown.status-enviado-link-de-agendamento,
.status-dropdown-card.status-enviado-link-de-agendamento {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231e40af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #1e40af;
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.status-dropdown[value="ENVIADO LINK DE AGENDAMENTO"]:hover,
.status-dropdown-card[value="ENVIADO LINK DE AGENDAMENTO"]:hover,
.status-dropdown.status-enviado-link-de-agendamento:hover,
.status-dropdown-card.status-enviado-link-de-agendamento:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

/* Cores por status - SEM INTERESSE */
.status-dropdown[value="SEM INTERESSE"],
.status-dropdown-card[value="SEM INTERESSE"],
.status-dropdown.status-sem-interesse,
.status-dropdown-card.status-sem-interesse {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23991b1b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.status-dropdown[value="SEM INTERESSE"]:hover,
.status-dropdown-card[value="SEM INTERESSE"]:hover,
.status-dropdown.status-sem-interesse:hover,
.status-dropdown-card.status-sem-interesse:hover {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* Cores por status - LIXEIRA */
.status-dropdown[value="LIXEIRA"],
.status-dropdown-card[value="LIXEIRA"],
.status-dropdown.status-lixeira,
.status-dropdown-card.status-lixeira {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23991b1b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.status-dropdown[value="LIXEIRA"]:hover,
.status-dropdown-card[value="LIXEIRA"]:hover,
.status-dropdown.status-lixeira:hover,
.status-dropdown-card.status-lixeira:hover {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
}

/* Estilos específicos para dropdown na tabela */
.col-status .status-dropdown {
    width: 100%;
    max-width: 220px;
}

/* Estilos específicos para dropdown nos cards */
.card-header .status-dropdown-card {
    margin-left: auto;
    flex-shrink: 0;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    overflow: auto;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    margin: auto;
    padding: 0;
    border-radius: 20px;
    width: 100%;
    max-width: 900px;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: slideDown 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid var(--gray-100);
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    flex-shrink: 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-header-actions button {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
}

.modal-header h2 {
    margin: 0;
    color: var(--gray-900);
    font-size: 1.35rem;
    font-weight: 700;
}

.modal-close {
    background: var(--gray-100);
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    transform: rotate(90deg);
}

.modal form {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--gray-100);
    flex-shrink: 0;
    grid-column: 1 / -1;
}

.modal-actions button {
    width: auto;
    min-width: 110px;
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
}

/* ===== MODAL DE HISTÓRICO ===== */
.modal-history {
    max-width: 800px;
}

.history-container {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.history-patient-info {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 2px solid var(--gray-100);
}

.history-patient-info h3 {
    margin: 0 0 0.5rem 0;
    color: var(--gray-900);
    font-size: 1.25rem;
    font-weight: 700;
}

.history-patient-info p {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.95rem;
}

.history-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 50vh;
    overflow-y: auto;
    padding: 1rem 0;
}

.history-message {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    background: white;
    transition: all 0.2s ease;
}

.history-message:hover {
    box-shadow: var(--shadow);
    transform: translateX(2px);
}

.message-user {
    background: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
    border-color: #93c5fd;
    margin-left: 2rem;
}

.message-bot {
    background: linear-gradient(135deg, #f3e8ff 0%, #ede9fe 100%);
    border-color: #c4b5fd;
    margin-right: 2rem;
}

.message-system {
    background: var(--gray-50);
    border-color: var(--gray-200);
    margin: 0 1rem;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.message-sender {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.message-content {
    color: var(--gray-800);
    line-height: 1.6;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.75rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 0;
}

.empty-history {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-500);
}

.empty-history span {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.empty-history p {
    margin: 0;
    font-size: 1rem;
}

.history-error {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--danger-color);
}

.history-error span {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.history-error p {
    margin: 0.5rem 0;
    font-size: 1rem;
}

.history-error .error-details {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: 1rem;
}

.history-error button {
    margin-top: 1.5rem;
}

/* ===== MODAL DE DUPLICATAS ===== */
.modal-duplicates {
    max-width: 900px;
}

.duplicates-content {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.duplicates-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-600);
}

.duplicates-icon {
    font-size: 5rem;
    display: block;
    margin-bottom: 1.5rem;
}

.duplicates-empty h3 {
    margin: 0 0 0.75rem 0;
    color: var(--success-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.duplicates-empty p {
    margin: 0;
    font-size: 1rem;
    color: var(--gray-600);
}

.duplicates-summary {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.duplicates-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.duplicates-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    border-radius: 12px;
    border: 2px solid var(--gray-200);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.duplicates-section-title span:first-child {
    font-size: 1.5rem;
}

.duplicates-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.duplicate-group {
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    background: white;
    overflow: hidden;
    transition: all 0.3s ease;
}

.duplicate-group:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--warning-color);
}

.duplicate-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-bottom: 2px solid var(--gray-200);
}

.duplicate-key {
    font-weight: 700;
    color: #92400e;
    font-size: 1rem;
}

.duplicate-count {
    padding: 0.375rem 0.875rem;
    background: rgba(146, 64, 14, 0.2);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #92400e;
}

.duplicate-patients {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
}

.duplicate-patient-item {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.2s ease;
}

.duplicate-patient-item:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateX(4px);
}

.duplicate-patient-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.duplicate-patient-info strong {
    color: var(--gray-900);
    font-size: 0.95rem;
}

.duplicate-patient-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.duplicate-patient-details span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}


/* Badge de duplicata em cards e tabelas */
.duplicate-badge {
    display: inline-block;
    background: var(--warning-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    margin-right: 0.5rem;
    white-space: nowrap;
}

.duplicate-badge-inline {
    display: inline-block;
    margin-right: 0.5rem;
    font-size: 1rem;
    vertical-align: middle;
}

.patient-card.has-duplicate {
    border-color: var(--warning-color);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
    background: linear-gradient(135deg, #fffbeb 0%, white 100%);
}

.patient-card.has-duplicate .card-header {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

tr.has-duplicate {
    background: linear-gradient(135deg, #fffbeb 0%, white 100%);
}

tr.has-duplicate:hover {
    background: linear-gradient(135deg, #fef3c7 0%, white 100%);
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 1024px) {
    .dashboard-container {
        padding: 1.5rem;
    }

    .patients-table {
        min-width: 1000px;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 1rem;
    }

    .dashboard-header {
        padding: 1rem 1.5rem;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }

    .header-icon {
        font-size: 2rem;
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .stat-value {
        font-size: 2.25rem;
    }

    .actions-section {
        flex-direction: column;
    }

    .actions-section button {
        width: 100%;
        justify-content: center;
    }

    .view-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .view-toggle {
        width: 100%;
        justify-content: center;
    }

    .search-filter {
        flex-direction: column;
        min-width: auto;
    }

    .search-input,
    .filter-select {
        width: 100%;
        min-width: auto;
    }

    .date-filter-group {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .date-filter-group .filter-select {
        width: 100%;
        min-width: auto;
    }

    .quick-year-filters {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .quick-year-btn {
        flex: 1;
        min-width: 0;
        padding: 0.625rem 0.5rem;
        font-size: 0.8rem;
    }

    .patients-cards {
        grid-template-columns: 1fr;
    }

    .table-section {
        border-radius: 12px;
    }

    .patients-table {
        font-size: 0.875rem;
        min-width: 900px;
    }

    .patients-table th,
    .patients-table td {
        padding: 0.875rem 0.75rem;
    }

    .patients-table td:nth-child(2) {
        max-width: 200px;
    }

    .table-actions {
        flex-direction: column;
        gap: 0.375rem;
    }

    .table-actions .btn-edit,
    .table-actions .btn-danger {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
    }

    .modal-content {
        border-radius: 16px;
        max-height: 95vh;
    }

    .modal-header {
        padding: 1.5rem;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .modal form {
        padding: 1.5rem;
    }

    /* Grid volta para uma coluna em telas menores */
    #patientModal .modal-content form {
        grid-template-columns: 1fr;
    }

    .history-container {
        padding: 1.5rem;
    }

    .history-messages {
        max-height: 40vh;
    }

    .message-user {
        margin-left: 0.5rem;
    }

    .message-bot {
        margin-right: 0.5rem;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions button {
        width: 100%;
    }

    .login-box {
        padding: 2rem 1.5rem;
    }

    .login-box h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .dashboard-container {
        padding: 0.75rem;
    }

    .dashboard-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .header-left {
        width: 100%;
    }

    .header-right {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }

    #webhookToggleBtn {
        width: 100%;
        justify-content: center;
    }

    #logoutBtn {
        width: 100%;
        justify-content: center;
    }

    .stats-section {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .view-controls {
        padding: 1rem;
    }

    .view-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .date-filter-group {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .date-filter-group .filter-select {
        width: 100%;
        min-width: auto;
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }

    .quick-year-filters {
        width: 100%;
        justify-content: space-between;
        gap: 0.25rem;
        flex-wrap: wrap;
    }

    .quick-year-btn {
        flex: 1 1 calc(25% - 0.25rem);
        min-width: 0;
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }

    .patient-card {
        border-radius: 12px;
    }

    .card-header,
    .card-body,
    .card-actions {
        padding: 1rem;
    }

    .card-title h3 {
        font-size: 1.125rem;
    }

    .info-label {
        min-width: 100px;
        font-size: 0.8rem;
    }

    .info-value {
        font-size: 0.875rem;
    }

    .table-section {
        border-radius: 8px;
    }

    .patients-table {
        font-size: 0.8rem;
        min-width: 800px;
    }

    .patients-table th,
    .patients-table td {
        padding: 0.75rem 0.5rem;
    }

    .btn-edit,
    .btn-danger {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }

    .modal-content {
        border-radius: 12px;
        margin: 0.5rem;
        width: calc(100% - 1rem);
    }

    .modal-header {
        padding: 1.25rem;
    }

    .modal form {
        padding: 1.25rem;
    }

    /* Grid volta para uma coluna em telas muito pequenas */
    #patientModal .modal-content form {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .history-container {
        padding: 1rem;
        max-height: 60vh;
    }

    .history-patient-info {
        padding: 1rem;
    }

    .history-patient-info h3 {
        font-size: 1.1rem;
    }

    .history-messages {
        max-height: 35vh;
        gap: 0.75rem;
    }

    .history-message {
        padding: 0.75rem 1rem;
    }

    .message-user,
    .message-bot,
    .message-system {
        margin-left: 0;
        margin-right: 0;
    }

    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .login-box {
        padding: 1.5rem 1.25rem;
    }

    .login-icon {
        font-size: 3rem;
    }

    .quick-year-btn {
        font-size: 0.7rem;
        padding: 0.45rem 0.35rem;
    }

    .date-filter-group .filter-select {
        font-size: 0.8rem;
        padding: 0.7rem 0.9rem;
    }
}

@media (max-width: 360px) {
    .patients-table {
        min-width: 700px;
    }

    .patients-table th,
    .patients-table td {
        padding: 0.625rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* ===== SISTEMA DE NOTIFICAÇÕES ===== */

.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    width: 100%;
    pointer-events: none;
}

.notification {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-xl);
    padding: 0;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    pointer-events: auto;
    overflow: hidden;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
}

.notification-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--gray-800);
    line-height: 1.5;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
    line-height: 1;
}

.notification-close:hover {
    color: var(--gray-900);
}

/* Tipos de notificação */
.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-success .notification-icon {
    color: var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--danger-color);
}

.notification-error .notification-icon {
    color: var(--danger-color);
}

.notification-warning {
    border-left: 4px solid var(--warning-color);
}

.notification-warning .notification-icon {
    color: var(--warning-color);
}

.notification-info {
    border-left: 4px solid var(--info-color);
}

.notification-info .notification-icon {
    color: var(--info-color);
}

/* Responsividade */
@media (max-width: 768px) {
    .notifications-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .notification {
        transform: translateY(-100px);
    }

    .notification.show {
        transform: translateY(0);
    }

    .notification-content {
        padding: 0.875rem 1rem;
    }

    .notification-message {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .notifications-container {
        top: 5px;
        right: 5px;
        left: 5px;
    }

    .notification-content {
        padding: 0.75rem 0.875rem;
        gap: 0.5rem;
    }

    .notification-icon {
        font-size: 1.1rem;
    }

    .notification-message {
        font-size: 0.8rem;
    }

    .notification-close {
        font-size: 1.25rem;
        width: 20px;
        height: 20px;
    }
}

/* ===== MODAIS CUSTOMIZADOS (ALERT E CONFIRM) ===== */

.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.custom-modal.show {
    opacity: 1;
    visibility: visible;
}

.custom-modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.custom-modal.show .custom-modal-content {
    transform: scale(1) translateY(0);
}

.custom-modal-header {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.custom-modal-body {
    padding: 1.75rem;
    flex: 1;
    overflow-y: auto;
}

.custom-modal-body p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--gray-800);
    white-space: pre-line;
}

.custom-modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    background: var(--gray-50);
}

.custom-modal-footer button {
    min-width: 100px;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.custom-modal-footer .btn-primary {
    background: var(--primary-color);
    color: white;
}

.custom-modal-footer .btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.custom-modal-footer .btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.custom-modal-footer .btn-secondary:hover {
    background: var(--gray-300);
    transform: translateY(-1px);
}

/* Responsividade para modais */
@media (max-width: 768px) {
    .custom-modal-content {
        width: 95%;
        max-width: none;
        border-radius: 12px;
    }

    .custom-modal-header {
        padding: 1.25rem 1.5rem;
    }

    .custom-modal-header h3 {
        font-size: 1.1rem;
    }

    .custom-modal-body {
        padding: 1.5rem;
    }

    .custom-modal-body p {
        font-size: 0.95rem;
    }

    .custom-modal-footer {
        padding: 1rem 1.5rem;
        flex-direction: column-reverse;
    }

    .custom-modal-footer button {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .custom-modal-content {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .custom-modal-header {
        padding: 1rem 1.25rem;
    }

    .custom-modal-body {
        padding: 1.25rem;
    }

    .custom-modal-footer {
        padding: 1rem;
    }
}


