/* ============================================
   DANIEL CHAT - CSS CORRIGIDO
   ============================================ */

.daniel-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Inter', sans-serif;
}

/* Botão do Daniel */
.daniel-button {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s;
    position: relative;
}

.daniel-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(37,99,235,0.4);
}

.daniel-button i {
    font-size: 32px;
    color: white;
}

.daniel-button::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 15px;
    height: 15px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(0.95); opacity: 1; }
}

/* Janela do Chat */
.daniel-window {
    position: fixed;
    bottom: 95px;
    right: 20px;
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 35px rgba(0,0,0,0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.daniel-window.open {
    display: flex;
}

/* Cabeçalho */
.daniel-header {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: white;
    padding: 15px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.daniel-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.daniel-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.daniel-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.daniel-header p {
    margin: 3px 0 0;
    font-size: 0.7rem;
    opacity: 0.8;
}

.close-daniel {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s;
}

.close-daniel:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

/* Status Online */
.daniel-status {
    padding: 8px 15px;
    background: #f8fafc;
    font-size: 0.7rem;
    color: #10b981;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
}

.daniel-status i {
    font-size: 0.6rem;
}

/* Área de Mensagens - CORRIGIDA */
.daniel-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    max-height: 100%;
}

/* Scroll personalizado */
.daniel-messages::-webkit-scrollbar {
    width: 6px;
}

.daniel-messages::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.daniel-messages::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 10px;
}

.daniel-messages::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Mensagens */
.message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    justify-content: flex-end;
}

.message.daniel {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 0.85rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-content {
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 5px;
}

.message.daniel .message-content {
    background: white;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 0.6rem;
    margin-top: 5px;
    text-align: right;
    color: #94a3b8;
}

/* Indicador de Digitação */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 18px;
    background: white;
    border-radius: 20px;
    width: fit-content;
    border: 1px solid #e2e8f0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Input de Mensagem */
.daniel-input {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
}

.daniel-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 30px;
    font-size: 0.85rem;
    outline: none;
    font-family: 'Inter', sans-serif;
}

.daniel-input input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.daniel-input button#sendDaniel {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.daniel-input button#sendDaniel:hover {
    background: #1e40af;
    transform: scale(1.02);
}

/* Sugestões */
.daniel-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 15px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.suggestion-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    border-radius: 25px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
}

.suggestion-btn:hover {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
    transform: translateY(-2px);
}


/* ============================================
   ELEMENTOS DE ÁUDIO E VOZ
   ============================================ */

.daniel-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.voice-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.voice-toggle-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.voice-btn {
    background: #f1f5f9;
    color: #64748b;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.voice-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: scale(1.05);
}

/* Estado de Gravação Ativa */
.recording-container {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: #fdf2f2;
    border: 1px solid #fecaca;
    padding: 8px 16px;
    border-radius: 30px;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.daniel-input.recording-active input,
.daniel-input.recording-active #sendDaniel,
.daniel-input.recording-active #recordVoiceDaniel {
    display: none;
}

.daniel-input.recording-active .recording-container {
    display: flex;
}

.record-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #dc2626;
    font-weight: 500;
}

.record-dot {
    width: 10px;
    height: 10px;
    background: #dc2626;
    border-radius: 50%;
    animation: pulseRed 1s infinite;
}

@keyframes pulseRed {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.4; }
    100% { transform: scale(1); opacity: 1; }
}

.record-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.record-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.record-action-btn.cancel {
    color: #94a3b8;
}

.record-action-btn.cancel:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.record-action-btn.send {
    color: #2563eb;
}

.record-action-btn.send:hover {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.1);
}

/* Player de Áudio Customizado na Mensagem */
.voice-message-player {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    padding: 4px 0;
}

.vmp-play-btn {
    background: white;
    color: #2563eb;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
    flex-shrink: 0;
}

.message.daniel .vmp-play-btn {
    background: #2563eb;
    color: white;
}

.vmp-play-btn:hover {
    transform: scale(1.08);
}

.vmp-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vmp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    cursor: pointer;
}

.message.daniel .vmp-slider {
    background: #e2e8f0;
}

.vmp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}

.message.daniel .vmp-slider::-webkit-slider-thumb {
    background: #2563eb;
}

.vmp-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    opacity: 0.8;
}

.message.user .vmp-info {
    color: rgba(255, 255, 255, 0.9);
}

.message.daniel .vmp-info {
    color: #64748b;
}

.voice-transcription {
    font-size: 0.75rem;
    font-style: italic;
    opacity: 0.9;
    border-top: 1px dashed rgba(255, 255, 255, 0.3);
    margin-top: 6px;
    padding-top: 6px;
    word-break: break-word;
}

.message.daniel .voice-transcription {
    border-top-color: #e2e8f0;
    color: #475569;
}

/* Dark Mode Overrides de Áudio */
body.dark-mode .voice-btn {
    background: #1e293b;
    color: #94a3b8;
}

body.dark-mode .voice-btn:hover {
    background: #334155;
    color: #f1f5f9;
}

body.dark-mode .recording-container {
    background: #7f1d1d;
    border-color: #b91c1c;
}

body.dark-mode .record-status {
    color: #fca5a5;
}

body.dark-mode .record-dot {
    background: #ef4444;
}

body.dark-mode .record-action-btn.cancel {
    color: #94a3b8;
}

body.dark-mode .record-action-btn.cancel:hover {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.15);
}

body.dark-mode .record-action-btn.send {
    color: #3b82f6;
}

body.dark-mode .record-action-btn.send:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
}

body.dark-mode .message.daniel .vmp-play-btn {
    background: #2563eb;
    color: #f1f5f9;
}

body.dark-mode .message.daniel .vmp-slider {
    background: #475569;
}

body.dark-mode .message.daniel .vmp-slider::-webkit-slider-thumb {
    background: #2563eb;
}

body.dark-mode .message.daniel .vmp-info {
    color: #94a3b8;
}

body.dark-mode .message.daniel .voice-transcription {
    border-top-color: #334155;
    color: #94a3b8;
}

/* Dark Mode */
body.dark-mode .daniel-window {
    background: #1e293b;
}

body.dark-mode .daniel-status {
    background: #0f172a;
    border-bottom-color: #334155;
    color: #10b981;
}

body.dark-mode .daniel-messages {
    background: #0f172a;
}

body.dark-mode .message.daniel .message-content {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .daniel-input {
    background: #1e293b;
    border-top-color: #334155;
}

body.dark-mode .daniel-input input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .daniel-input input::placeholder {
    color: #94a3b8;
}

body.dark-mode .daniel-suggestions {
    background: #0f172a;
    border-top-color: #334155;
}

body.dark-mode .suggestion-btn {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .suggestion-btn:hover {
    background: #2563eb;
    color: white;
}

body.dark-mode .typing-indicator {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .typing-indicator span {
    background: #64748b;
}

/* ============================================
   RESPONSIVO
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    .daniel-window {
        width: 380px;
        height: 550px;
        max-height: 75vh;
        bottom: 85px;
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* Telemóvel Grande */
@media (max-width: 480px) {
    .daniel-window {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        height: 70vh;
        max-height: 70vh;
        bottom: 85px;
    }
    
    .daniel-button {
        width: 55px;
        height: 55px;
    }
    
    .daniel-button i {
        font-size: 28px;
    }
    
    .message-content {
        max-width: 90%;
        font-size: 0.8rem;
    }
    
    .daniel-suggestions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 10px 15px;
    }
    
    .suggestion-btn {
        white-space: nowrap;
    }
}

/* Telemóvel Pequeno */
@media (max-width: 380px) {
    .daniel-window {
        height: 65vh;
    }
    
    .daniel-header {
        padding: 12px 15px;
    }
    
    .daniel-avatar {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .daniel-header h3 {
        font-size: 0.9rem;
    }
    
    .daniel-header p {
        font-size: 0.6rem;
    }
    
    .daniel-messages {
        padding: 12px;
    }
    
    .daniel-input {
        padding: 10px;
    }
    
    .daniel-input input {
        padding: 10px 14px;
        font-size: 0.8rem;
    }
    
    .daniel-input button {
        padding: 0 15px;
    }
}

/* Desktop Grande (Telas > 1400px) */
@media (min-width: 1400px) {
    .daniel-window {
        width: 450px;
        height: 650px;
        bottom: 25px;
        right: 25px;
    }
    
    .message-content {
        max-width: 80%;
        font-size: 0.9rem;
    }
    
    .daniel-button {
        width: 75px;
        height: 75px;
        bottom: 10px;
        right: 10px;
    }
    
    .daniel-button i {
        font-size: 36px;
    }
}