/* ============================================ */
/* ESTILOS BASE DO CHAT */
/* ============================================ */

* {
    box-sizing: border-box;
}

#chat-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#chat-toggle-btn {
    padding: 12px 20px;
    border-radius: 25px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

#chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#chat-container {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
}

#chat-container.active {
    display: flex;
}

.chat-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
}

.chat-header .header-info {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

/* ============================================ */
/* FORMULARIO */
/* ============================================ */

#patient-form {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
}

.btn-start-chat {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-start-chat:hover {
    transform: translateY(-2px);
}

.btn-start-chat:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* ============================================ */
/* MENSAGENS */
/* ============================================ */

#chat-messages {
    display: none;
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
}

#chat-messages.active {
    display: block;
}

.message {
    margin-bottom: 12px;
    max-width: 80%;
    clear: both;
    padding: 10px 14px;
    border-radius: 15px;
    word-wrap: break-word;
    position: relative;
    font-size: 14px;
    line-height: 1.4;
}

.message.patient {
    float: right;
    background: #007bff;
    color: white;
    border-radius: 15px 15px 0 15px;
}

.message.doctor {
    float: left;
    background: white;
    border-radius: 15px 15px 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.message .sender-name {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 3px;
    opacity: 0.8;
}

.message .timestamp {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message.system {
    float: none;
    max-width: 100%;
    text-align: center;
    background: none;
    box-shadow: none;
    font-size: 12px;
    color: #999;
    padding: 5px;
}

/* ============================================ */
/* INDICADOR DE DIGITANDO */
/* ============================================ */

#typing-indicator {
    display: none;
    padding: 5px 15px;
    font-size: 12px;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
}

#typing-indicator.active {
    display: block;
}

.typing-dots span {
    animation: typing 1.4s infinite;
    font-size: 20px;
    line-height: 10px;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* ============================================ */
/* AREA DE INPUT (2 LINHAS) */
/* ============================================ */

#chat-input-area {
    display: none;
    padding: 8px 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-direction: column;
    gap: 6px;
}

#chat-input-area.active {
    display: flex;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.file-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    padding: 0 5px;
    width: 100%;
}

.file-info-text {
    font-size: 10px;
    color: #888;
}

#message-input {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    height: 36px;
    min-width: 0;
}

#send-btn {
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#send-btn:hover {
    opacity: 0.8;
}

#emoji-btn {
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    font-size: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#emoji-btn:hover {
    background: #e0e0e0;
}

#attach-btn {
    background: #f0f0f0;
    color: #666;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 12px;
    flex-shrink: 0;
}

#attach-btn:hover {
    background: #e0e0e0;
}

#end-chat-btn {
    background: #dc3545;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 15px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s;
}

#end-chat-btn:hover {
    background: #b02a37;
}

/* ============================================ */
/* SELETOR DE EMOJIS */
/* ============================================ */

#emoji-picker {
    display: none;
    padding: 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#emoji-picker.active {
    display: flex;
}

.emoji-item {
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.15s, transform 0.15s;
    border: 1px solid #eee;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.emoji-item:hover {
    background: #e8f0fe;
    border-color: #007bff;
    transform: scale(1.15);
}

.emoji-item img {
    width: 28px;
    height: 28px;
    display: block;
}
/* ============================================ */
/* PREVIEW DE ARQUIVO */
/* ============================================ */

#attachment-preview {
    display: none;
    padding: 5px 10px;
    background: #e9ecef;
    border-radius: 5px;
    font-size: 12px;
}

#attachment-preview.active {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#attachment-preview .remove-attach {
    cursor: pointer;
    color: #dc3545;
    font-weight: bold;
}

/* ============================================ */
/* MENSAGENS DE ERRO/SUCESSO */
/* ============================================ */

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    display: none;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    display: none;
}

/* ============================================ */
/* MINIMIZAR CHAT */
/* ============================================ */

#minimize-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    margin-right: 10px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#minimize-btn:hover {
    background: rgba(255,255,255,0.2);
}

#chat-container.minimized #chat-messages,
#chat-container.minimized #chat-input-area,
#chat-container.minimized #typing-indicator,
#chat-container.minimized #attachment-preview,
#chat-container.minimized #patient-form,
#chat-container.minimized #emoji-picker {
    display: none !important;
}

#chat-container.minimized {
    height: auto !important;
}

/* ============================================ */
/* INDICADOR DE CONEXAO */
/* ============================================ */

#connection-status {
    display: none;
    padding: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}

#connection-status.disconnected {
    display: block;
    background: #fff3cd;
    color: #856404;
}

#connection-status.reconnecting {
    display: block;
    background: #cce5ff;
    color: #004085;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================ */
/* MODAL DE CONFIRMACAO */
/* ============================================ */

#confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

#confirm-modal.active {
    display: flex;
}

#confirm-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    width: 300px;
}

#confirm-content h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
}

#confirm-content p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-cancel {
    padding: 8px 20px;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.btn-confirm {
    padding: 8px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.btn-confirm:hover {
    background: #c82333;
}

/* ============================================ */
/* MODAL DE AVALIACAO */
/* ============================================ */

#rating-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

#rating-modal.active {
    display: flex;
}

#rating-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 300px;
}

#rating-content h3 {
    margin: 0 0 15px 0;
    color: #333;
}

.stars {
    font-size: 40px;
    cursor: pointer;
    margin: 15px 0;
}

.stars span {
    color: #ddd;
    transition: color 0.2s;
}

.stars span:hover,
.stars span.active {
    color: #ffc107;
}

#rating-comment {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 10px 0;
    resize: none;
    font-family: inherit;
}

#submit-rating {
    padding: 10px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

#submit-rating:hover {
    background: #218838;
}

/* Checkbox de Privacidade */
.privacy-group {
    margin-top: 5px;
}

.privacy-label {
    display: flex !important;
    align-items: center;
    gap: 5px;
    font-size: 12px !important;
    font-weight: normal !important;
    cursor: pointer;
    flex-wrap: wrap;
}

.privacy-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    accent-color: #007bff;
}

.privacy-link {
    color: #007bff;
    text-decoration: underline;
    font-weight: 500;
}

.privacy-link:hover {
    color: #0056b3;
}