/* chat.css - Design Clean e Profissional seguindo o padrão do sistema */

.chat-page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);   /* preenche a tela sem rolar a página */
    background-image: url("../image/background.webp");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    width: 100%;
    padding: 16px 16px 18px;
    box-sizing: border-box;
}

.chat-header {
    text-align: center;
    margin: 0 0 12px;
    width: 100%;
    max-width: 900px;
    flex-shrink: 0;
}

.chat-title {
    font-size: 1.5rem;
    color: #173366;
    margin: 0;
    font-weight: 700;
}

.chat-subtitle {
    font-size: 1rem;
    color: #6c757d;
    margin: 0;
    font-weight: 400;
}

.chat-container {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(11, 28, 66, 0.10);
    overflow: hidden;
    flex: 1;
    min-height: 0;        /* permite o scroll interno da lista de mensagens */
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    position: relative;
}

.chat-status-header {
    background: white;
    color: #173366;
    padding: 15px 20px;
    text-align: center;
    position: relative;
    border-bottom: none;
}

.chat-status-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.chat-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    animation: slideIn 0.4s ease-out;
}

.message.bot {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message.bot .message-bubble {
    background: #173366;
    color: white;
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: #d9d9d9;
    color: black;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 4px;
    opacity: 0.7;
}

.message.bot .message-time {
    text-align: left;
}

.message.user .message-time {
    text-align: right;
}

/* Estilos para botões do chat criados dinamicamente */
.buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
}

.chat-button {
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    width: 100%;
    box-sizing: border-box;
}

.chat-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.chat-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.chat-button.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0.85;
}

.chat-button.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.4);
}

/* Estilos para interface de upload */
.upload-interface {
    width: 100%;
    margin-top: 10px;
}

.upload-container {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
}

.upload-area:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
}

.upload-area .material-icons {
    font-size: 48px;
    color: rgba(255, 255, 255, 0.8);
    display: block;
    margin-bottom: 10px;
}

.upload-area p {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 500;
    color: white;
}

.upload-area small {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.file-list {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.file-item .material-icons {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.8);
}

.file-name {
    flex: 1;
    font-size: 0.9rem;
    color: white;
    font-weight: 500;
}

.file-size {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.remove-file {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.remove-file:hover {
    background: rgba(255, 59, 59, 0.8);
}

.upload-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.upload-buttons .chat-button {
    flex: 0 0 auto;
    max-width: 120px;
}

/* Estilos para cards de protocolo */
.protocol-card {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    backdrop-filter: blur(5px);
}

.protocol-card h3 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.protocol-info {
    line-height: 1.8;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.protocol-info strong {
    color: white;
    font-weight: 600;
}

.protocol-note {
    margin-top: 15px;
    padding: 12px;
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.7;
    font-style: italic;
    color: #6c757d;
    padding: 10px 15px;
    background: #e9ecef;
    border-radius: 18px;
    max-width: fit-content;
    animation: slideIn 0.4s ease-out;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

.input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    font-size: 0.95rem;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1.4;
}

.message-input:focus {
    border-color: #5BC659;
}

.message-input::placeholder {
    color: #6c757d;
}

.send-button {
    padding: 12px 24px;
    background: #173366;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 80px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.send-button:hover:not(:disabled) {
    background: #0f2347;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.send-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.send-button .material-icons {
    font-size: 18px;
}

/* Estados especiais */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

.welcome-message .material-icons {
    font-size: 48px;
    color: #173366;
    margin-bottom: 15px;
    display: block;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.error-message .material-icons {
    font-size: 18px;
}

/* Scrollbar personalizada */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb {
    background: #173366;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #0f2347;
}

/* Animações */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsividade */
@media (max-width: 768px) {
    .chat-page-container {
        padding: 20px 15px;
    }

    .chat-title {
        font-size: 1.8rem;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 0.9rem;
    }

    .input-container {
        padding: 15px;
    }

    .input-group {
        gap: 8px;
    }

    .message-input {
        font-size: 0.9rem;
        min-height: 40px;
    }

    .send-button {
        font-size: 0.9rem;
        padding: 10px 20px;
        height: 40px;
        min-width: 70px;
    }

    .buttons-container {
        gap: 8px;
    }

    .chat-button {
        padding: 10px 16px;
        font-size: 0.85rem;
        min-height: 40px;
    }

    .protocol-card {
        padding: 16px;
    }

    .upload-area {
        padding: 20px 15px;
    }

    .upload-area .material-icons {
        font-size: 36px;
    }

    .upload-buttons {
        flex-direction: column;
    }

    .upload-buttons .chat-button {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .chat-title {
        font-size: 1.6rem;
    }

    .messages {
        padding: 15px;
    }

    .message-bubble {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .input-container {
        padding: 12px;
    }

    .send-button {
        padding: 8px 16px;
        min-width: 60px;
    }

    .chat-button {
        padding: 8px 14px;
        font-size: 0.8rem;
        min-height: 36px;
    }

    .protocol-card {
        padding: 14px;
        font-size: 0.85rem;
    }

    .upload-area {
        padding: 15px 10px;
    }
}



/* Loading state */
.loading .send-button {
    pointer-events: none;
}

.loading .send-button::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.audio-button {
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 8px;
}

.audio-button:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.audio-button.recording {
    background: #ff4444;
    border-color: #cc0000;
    color: white;
    animation: pulse 1s infinite;
}

.audio-button.processing {
    background: #ffaa00;
    border-color: #ff8800;
    color: white;
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.audio-status {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    display: none;
}


/* Estilos para o autocomplete de endereços */
.address-interface {
    margin: 10px 0;
 min-width: 350px;
    padding: 0;
}

.address-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e1e8ed;
}

.address-input-group {
    position: relative;
    margin-bottom: 15px;
}

.address-input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.address-input:focus {
    border-color: #1da1f2;
    box-shadow: 0 0 0 3px rgba(29, 161, 242, 0.1);
}

.address-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #657786;
    font-size: 20px;
}

.address-suggestions {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    display: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: #f8f9fa;
}

.suggestion-item.selected {
    background-color: #e8f5fe;
    border-left: 3px solid #1da1f2;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-main {
    font-weight: 500;
    color: #14171a;
    margin-bottom: 2px;
}

.suggestion-secondary {
    font-size: 12px;
    color: #657786;
}

.loading-suggestions, .no-suggestions, .error-suggestions {
    padding: 16px;
    text-align: center;
    color: #657786;
    font-style: italic;
}

.error-suggestions {
    color: #e0245e;
}

.address-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.address-buttons .chat-button {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 14px;
}

.address-buttons .chat-button:not(.secondary) {
    background: #1da1f2;
    color: white;
}

.address-buttons .chat-button:not(.secondary):hover:not(:disabled) {
    background: #1a91da;
}

.address-buttons .chat-button:not(.secondary):disabled {
    background: #aab8c2;
    cursor: not-allowed;
}

.address-buttons .chat-button.secondary {
    background: #f7f9fa;
    color: #657786;
    border: 1px solid #e1e8ed;
}

.address-buttons .chat-button.secondary:hover {
    background: #e8f5fe;
    color: #1da1f2;
    border-color: #1da1f2;
}

/* Responsividade */
@media (max-width: 768px) {
    .address-container {
        padding: 15px;
    }

    .address-buttons {
        flex-direction: column;
    }

    .address-buttons .chat-button {
        width: 100%;
        margin-bottom: 5px;
    }

    .address-suggestions {
        max-height: 150px;
    }
}