/* Reset e configurações básicas */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #ffffff;
    color: #333333;
    overflow-x: hidden;
}

/* Variáveis CSS para cores */
:root {
    --primary-color: #1b0c69;
    --primary-dark: #0f0842;
    --primary-light: #2d1a8a;
}

/* Telas */
.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Tela de Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 28px;
    font-weight: 500;
    color: #333;
    text-align: center;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 16px;
    color: #666;
    text-align: center;
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.mdc-text-field {
    width: 100%;
}

.login-button {
    width: 100%;
    height: 48px;
    background-color: var(--primary-color) !important;
    color: white !important;
    border-radius: 8px;
    font-weight: 500;
}

.error-message {
    color: #f44336;
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
}

/* Tela de Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: white;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-title {
    font-size: 24px;
    font-weight: 400;
    color: #333;
    margin: 0;
}

.install-btn {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.logout-btn {
    background-color: #f0f0f0;
    color: #666;
}

.logout-btn:hover {
    background-color: #e0e0e0;
    color: #f44336;
}

/* Container de Mensagens */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-in;
}

.message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background-color: #f5f5f5;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.audio {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-player {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-player.assistant {
    background: rgba(0, 0, 0, 0.1);
}

/* Animação de digitação */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-message {
    position: relative;
}

.typing-message::after {
    content: '|';
    animation: blink 1s infinite;
    color: var(--primary-color);
    font-weight: bold;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Container de Input */
.input-container {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px;
    border: 1px solid #e0e0e0;
}

.input-field {
    flex: 1;
}

.message-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 16px;
    color: #333;
}

.message-input::placeholder {
    color: #999;
}

.mdc-icon-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.attach-btn {
    background-color: #f0f0f0;
    color: #666;
}

.attach-btn:hover {
    background-color: #e0e0e0;
}

.voice-btn {
    background-color: #f0f0f0;
    color: #666;
}

.voice-btn:hover {
    background-color: #e0e0e0;
}

.voice-btn.recording {
    background-color: #f44336;
    color: white;
    animation: pulse 1s infinite;
}

.send-btn {
    background-color: var(--primary-color);
    color: white;
}

.send-btn:hover {
    background-color: var(--primary-dark);
}

.send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner p {
    margin-top: 16px;
    color: #666;
    font-size: 16px;
}

.mdc-circular-progress {
    width: 48px;
    height: 48px;
}

/* Modal de Permissões */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 16px;
    color: #333;
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.5;
}

#permissionList {
    text-align: left;
    margin-bottom: 20px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsividade */
@media (max-width: 768px) {
    .chat-header {
        padding: 16px;
    }
    
    .chat-title {
        font-size: 20px;
    }
    
    .messages-container {
        padding: 16px;
    }
    
    .input-container {
        padding: 16px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .login-card {
        padding: 24px;
        margin: 16px;
    }
}

@media (max-width: 480px) {
    .chat-title {
        font-size: 18px;
    }
    
    .message {
        max-width: 90%;
        font-size: 14px;
    }
    
    .message-input {
        font-size: 14px;
    }
}

/* PWA específico */
@media (display-mode: standalone) {
    .chat-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    .chat-header {
        padding-top: env(safe-area-inset-top, 20px);
    }
    
    .input-container {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* Material Design Components Overrides */
.mdc-text-field--outlined .mdc-notched-outline__leading,
.mdc-text-field--outlined .mdc-notched-outline__notch,
.mdc-text-field--outlined .mdc-notched-outline__trailing {
    border-color: #e0e0e0;
}

.mdc-text-field--outlined.mdc-text-field--focused .mdc-notched-outline__leading,
.mdc-text-field--outlined.mdc-text-field--focused .mdc-notched-outline__notch,
.mdc-text-field--outlined.mdc-text-field--focused .mdc-notched-outline__trailing {
    border-color: var(--primary-color);
    border-width: 2px;
}

.mdc-floating-label--float-above {
    color: var(--primary-color);
}

.mdc-button__ripple {
    background-color: rgba(27, 12, 105, 0.12);
}
