* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#particles-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 20s infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0);
    }
    33% {
        transform: translateY(-100px) translateX(100px);
    }
    66% {
        transform: translateY(100px) translateX(-100px);
    }
}

.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    height: 95vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    margin-right: 320px;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px;
    border-radius: 20px 20px 0 0;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.header-text {
    text-align: center;
}

.header-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.chat-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.chat-header p {
    font-size: 14px;
    opacity: 0.9;
}

.panel-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.panel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.panel-btn:active {
    transform: translateY(0);
}

.new-conversation-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.new-conversation-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.message.bot .avatar {
    background-image: url('../img/Andréia.png');
    margin-right: 10px;
}

.message.user .avatar {
    background-image: url('../img/blank.png');
    margin-left: 10px;
}

.content {
    max-width: 70%;
    position: relative;
}

.content p {
    background: #f5f5f5;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .content p {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.feedback-buttons {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.message:hover .feedback-buttons {
    opacity: 1;
}

.feedback-buttons button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-buttons button:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.feedback-buttons button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.typing-indicator {
    display: flex;
    align-items: center;
    padding: 15px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    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);
    }
    30% {
        transform: translateY(-10px);
    }
}

.chat-input-container {
    display: flex;
    padding: 20px;
    border-top: 1px solid #eee;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #eee;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    border-color: #667eea;
}

#sendButton {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#sendButton:hover {
    transform: scale(1.1);
}

#sendButton:active {
    transform: scale(0.95);
}

#sendButton svg {
    fill: white;
}

.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 10px;
    width: 300px;
    z-index: 10;
    overflow: hidden;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.debug-header h3 {
    font-size: 14px;
    margin: 0;
}

#toggleDebug {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 12px;
}

.debug-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
}

@media (max-width: 768px) {
    .debug-content {
        max-height: calc(35vh - 60px);
    }
}

.debug-content.hidden {
    display: none;
}

.debug-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 12px;
}

.debug-logs {
    font-size: 11px;
    font-family: monospace;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .debug-logs {
        max-height: 120px;
    }
}

.debug-log-entry {
    margin-bottom: 5px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-actions {
    display: flex;
    gap: 10px;
}

.debug-actions button {
    flex: 1;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.debug-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal de reescrita */
.rewrite-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.rewrite-modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
}

.rewrite-modal h3 {
    margin-bottom: 15px;
    color: #333;
}

.rewrite-modal textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 14px;
    resize: vertical;
}

.rewrite-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.rewrite-modal-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.rewrite-modal-actions .save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.rewrite-modal-actions .cancel-btn {
    background: #f0f0f0;
    color: #333;
}

.rewrite-modal-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Responsividade */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        gap: 10px;
    }
    
    .chat-container {
        width: 100%;
        height: 60vh;
        max-height: none;
        border-radius: 10px;
        z-index: 10;
        flex-shrink: 0;
        margin-right: 0;
    }
    
    .chat-header {
        border-radius: 10px 10px 0 0;
    }
    
    .header-content {
        flex-direction: column;
        gap: 8px;
    }
    
    .header-text {
        text-align: center;
    }
    
    .header-buttons {
        gap: 8px;
    }
    
    .panel-btn,
    .new-conversation-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .debug-panel {
        width: 100%;
        height: 35vh;
        position: relative;
        bottom: auto;
        right: auto;
        border-radius: 10px;
        z-index: 10;
        flex-shrink: 0;
    }
    
    .content {
        max-width: 80%;
    }
}