/* Estilos Globais */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #e2e8f0;
    --background-color: #f8fafc;
    --text-color: #0f172a;
    --light-text: #64748b;
    --border-color: #e2e8f0;
    --user-message-bg: #f1f5f9;
    --assistant-message-bg: #eff6ff;
    --sidebar-width: 280px;
    --header-height: 60px;
    --footer-height: 60px;
    --border-radius: 8px;
    --transition-speed: 0.3s;
    --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.5;
}

/* Layout Principal */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.main-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Barra Lateral */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color var(--transition-speed);
}

.new-chat-btn:hover {
    background-color: var(--primary-hover);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.chat-item:hover {
    background-color: var(--secondary-color);
}

.chat-item.active {
    background-color: var(--secondary-color);
}

.chat-info {
    flex: 1;
    overflow: hidden;
}

.chat-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 0.8rem;
    color: var(--light-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.chat-item:hover .chat-actions {
    opacity: 1;
}

.delete-chat-btn {
    background: none;
    border: none;
    color: var(--light-text);
    cursor: pointer;
    font-size: 0.9rem;
    transition: color var(--transition-speed);
}

.delete-chat-btn:hover {
    color: #ef4444;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Container de Chat */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
}

.chat-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.chat-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.mobile-menu-toggle {
    display: none;
    margin-right: 15px;
    cursor: pointer;
    font-size: 1.2rem;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 500px;
}

.welcome-message h2 {
    margin-bottom: 10px;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.welcome-message p {
    color: var(--light-text);
    font-size: 1rem;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: var(--primary-color);
    color: white;
}

.message.assistant .message-avatar {
    background-color: #10b981;
    color: white;
}

.message-content {
    background-color: var(--user-message-bg);
    border-radius: var(--border-radius);
    padding: 12px;
    position: relative;
    box-shadow: var(--box-shadow);
}

.message.assistant .message-content {
    background-color: var(--assistant-message-bg);
}

.message-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.message-image {
    max-width: 200px;
    border-radius: 4px;
    overflow: hidden;
}

.message-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.message-time {
    font-size: 0.75rem;
    color: var(--light-text);
    margin-top: 6px;
    text-align: right;
}

.chat-input-container {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    padding: 10px;
    box-shadow: var(--box-shadow);
}

.message-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-input-actions {
    display: flex;
    gap: 8px;
}

.upload-btn, .send-btn {
    background: none;
    border: none;
    color: var(--light-text);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color var(--transition-speed);
    padding: 6px;
    border-radius: 50%;
}

.upload-btn:hover, .send-btn:hover {
    color: var(--primary-color);
    background-color: var(--secondary-color);
}

.send-btn {
    color: var(--primary-color);
}

.image-upload {
    display: none;
}

.preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.image-preview {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 4px;
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
}

/* Modais */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--light-text);
}

.modal-body {
    padding: 15px;
}

.modal-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.cancel-btn, .delete-btn {
    padding: 8px 16px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.cancel-btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

.delete-btn {
    background-color: #ef4444;
    color: white;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loader {
    border: 4px solid var(--secondary-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estilos para Código em Mensagens */
pre {
    background-color: #f3f4f6;
    color: #1f2937;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
}

code {
    font-family: 'Courier New', monospace;
    background-color: #f3f4f6;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

/* Estilos para Markdown */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-content h1 {
    font-size: 1.5em;
}

.markdown-content h2 {
    font-size: 1.3em;
}

.markdown-content h3 {
    font-size: 1.2em;
}

.markdown-content p {
    margin-bottom: 1em;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.markdown-content blockquote {
    padding: 0.5em 1em;
    margin: 0 0 1em;
    border-left: 4px solid #e5e7eb;
    color: #6b7280;
}

.markdown-content a {
    color: #3b82f6;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.markdown-content table {
    width: 100%;
    margin-bottom: 1em;
    border-collapse: collapse;
}

.markdown-content table th,
.markdown-content table td {
    padding: 8px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.markdown-content table th {
    background-color: #f9fafb;
    font-weight: 600;
}

.markdown-content img {
    max-width: 100%;
    border-radius: 4px;
    margin: 1em 0;
}

.markdown-content hr {
    margin: 1.5em 0;
    border: 0;
    border-top: 1px solid #e5e7eb;
}