:root {
    /* Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececf1;
    --text-primary: #0d0d0d;
    --text-secondary: #676767;
    --text-tertiary: #8e8ea0;
    --border-color: #d9d9e3;
    --accent-primary: #00A8E8;
    --accent-hover: #0090CC;
    --user-msg-bg: #f4f4f4;
    --bot-msg-bg: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --sidebar-width: 280px;
}

[data-theme="dark"] {
    --bg-primary: #212121;
    --bg-secondary: #2f2f2f;
    --bg-tertiary: #3f3f3f;
    --text-primary: #ececec;
    --text-secondary: #c5c5d2;
    --text-tertiary: #8e8ea0;
    --border-color: #4d4d4f;
    --accent-primary: #00A8E8;
    --accent-hover: #00C4FF;
    --user-msg-bg: #2f2f2f;
    --bot-msg-bg: #2f2f2f;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-md);
}

.header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-indicator {
    background: var(--accent-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

/* Main Layout */
.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.upload-section {
    margin-bottom: 20px;
}

.upload-box {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.upload-box:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: scale(1.02);
}

.upload-box.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    opacity: 0.1;
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.7;
}

.upload-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.files-list {
    margin-top: 16px;
}

.files-list-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.file-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.file-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.file-icon {
    font-size: 18px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.file-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.file-remove:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Messages */
.message {
    display: flex;
    gap: 10px;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.message.bot .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message.user .avatar {
    background: var(--accent-primary);
}

.message-content {
    max-width: 75%;
    background: var(--bot-msg-bg);
    border-radius: 18px;
    padding: 12px 16px;
    line-height: 1.5;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.message.user .message-content {
    background: var(--user-msg-bg);
    border: none;
}

.message-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Mensagens com HTML rico (preview de dados) */
.message-content.rich-html {
    max-width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

/* Data Display */
.data-table {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.data-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.data-row:last-child {
    border-bottom: none;
}

.data-row:hover {
    background: var(--bg-tertiary);
}

.data-label {
    padding: 12px 16px;
    font-weight: 600;
    width: 180px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
}

.data-value {
    padding: 12px 16px;
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

.instrument-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    border-left: 4px solid var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.instrument-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.instrument-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 15px;
}

.quick-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.quick-item {
    font-size: 13px;
}

.quick-label {
    color: var(--text-tertiary);
    font-weight: 500;
}

.quick-value {
    color: var(--text-primary);
    margin-left: 6px;
    font-weight: 500;
}

.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.tag-card {
    background: linear-gradient(135deg, #00A8E8 0%, #0090CC 100%);
    color: white;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.tag-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.summary-badge {
    display: inline-block;
    background: var(--accent-primary);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

/* Input Area */
/* Input Area - Compact Mode */
.chat-input-area {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px 16px;
    /* Reduced padding */
    box-shadow: var(--shadow-md);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    /* Reduced gap */
    align-items: center;
    /* Center aligned for neater look */
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border-color);
    /* Thinner border */
    border-radius: 20px;
    padding: 10px 14px;
    /* More compact */
    font-size: 13px;
    /* Smaller font */
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: none;
    max-height: 100px;
    min-height: 38px;
    /* Smaller height */
}

.attach-btn {
    display: flex;
    width: 32px;
    /* Smaller button */
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 4px;
}

.send-btn {
    width: 36px;
    /* Smaller send button */
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent-primary);
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.action-bar {
    display: flex;
    flex-direction: row;
    gap: 6px;
    margin-top: 8px;
    /* Closer to input */
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.action-btn {
    flex: 1;
    padding: 6px 4px;
    /* Very compact */
    font-size: 11px;
    /* Small font */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-primary);
}



.action-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Loading Animation */
.loading-dots {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* JSON Editor Styles */
.json-editor-container {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 8px 0;
    border: 1px solid var(--border-color);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    max-height: 600px;
    overflow-y: auto;
}

.json-line {
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.json-line:hover {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.json-key {
    color: #0066cc;
    font-weight: 600;
}

[data-theme="dark"] .json-key {
    color: #66b3ff;
}

.json-string {
    color: #22863a;
}

[data-theme="dark"] .json-string {
    color: #7ee787;
}

.json-number {
    color: #005cc5;
}

[data-theme="dark"] .json-number {
    color: #79c0ff;
}

.json-boolean {
    color: #0000ff;
    font-weight: 600;
}

[data-theme="dark"] .json-boolean {
    color: #569cd6;
}

.json-null {
    color: #808080;
    font-style: italic;
}

[data-theme="dark"] .json-null {
    color: #999999;
}

.json-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 5px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 11px;
    min-width: 120px;
    transition: all 0.2s ease;
}

.json-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.1);
}

.json-object {
    margin-left: 10px;
}

.collapse-btn {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s ease;
}

.collapse-btn:hover {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 61px;
        height: calc(100vh - 61px);
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .chat-messages {
        padding: 20px 16px;
    }

    .message-content {
        max-width: 85%;
    }

    .action-bar {
        flex-direction: column;
    }

    .data-label {
        width: 140px;
        font-size: 12px;
    }
}

/* File Progress Bar Styles */
.file-progress {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.file-progress-bar {
    height: 100%;
    background: var(--accent-primary);
    width: 0%;
    transition: width 0.5s ease-out, background 0.3s ease;
}

/* Animação lenta fake para status 'processing' */
.file-progress-bar.processing {
    animation: slowProgress 15s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
}

@keyframes slowProgress {
    0% {
        width: 0%;
    }

    10% {
        width: 30%;
    }

    40% {
        width: 60%;
    }

    80% {
        width: 80%;
    }

    100% {
        width: 85%;
    }

    /* Nunca chega a 100% sozinho */
}