/* ============================================================
   RELATÓRIO DE OBRAS — ASSISTENTE JULIANA
   Design System: profissional, clean, tons terrosos
   ============================================================ */

:root {
    /* Paleta principal */
    --bg-app: #f5f1eb;
    --bg-chat: #faf8f4;
    --bg-sidebar: #1e1b18;
    --bg-card: #ffffff;
    --bg-bubble-assistant: #ffffff;
    --bg-bubble-user: #2c2416;
    --bg-input: #ffffff;

    /* Texto */
    --text-primary: #2c2416;
    --text-secondary: #6b5e4a;
    --text-sidebar: #d4c8b8;
    --text-sidebar-muted: #8c7e6b;
    --text-user-bubble: #f5f1eb;
    --text-on-accent: #ffffff;

    /* Acento */
    --accent: #c78d3c;
    --accent-hover: #b0782e;
    --accent-light: rgba(199, 141, 60, 0.1);
    --accent-glow: rgba(199, 141, 60, 0.25);

    /* Funcionais */
    --success: #4a7c59;
    --warning: #c44e3d;
    --info: #5b8cbf;

    /* Bordas */
    --border: #e0d5c7;
    --border-light: #ede6db;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(44, 36, 22, 0.06);
    --shadow-md: 0 4px 16px rgba(44, 36, 22, 0.08);
    --shadow-lg: 0 12px 40px rgba(44, 36, 22, 0.12);
    --shadow-sidebar: 4px 0 24px rgba(0, 0, 0, 0.15);

    /* Raio */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Tipografia */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8rem;
    --fs-md: 0.875rem;
    --fs-lg: 1rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;

    /* Transições */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    font-size: var(--fs-md);
    color: var(--text-primary);
    background: var(--bg-app);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- App Container --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sidebar);
    z-index: 10;
    transition: transform var(--transition-smooth);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    line-height: 1;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.logo-sub {
    font-size: var(--fs-xs);
    color: var(--text-sidebar-muted);
    letter-spacing: 0.3px;
}

/* Progresso */
.progress-section {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: var(--fs-sm);
    font-weight: 500;
}

.progress-pct {
    color: var(--accent);
    font-weight: 700;
    font-size: var(--fs-md);
}

.progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #e0a84c);
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Resumo */
.resumo-section {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.resumo-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.resumo-content {
    font-size: var(--fs-sm);
    line-height: 1.7;
}

.resumo-placeholder {
    color: var(--text-sidebar-muted);
    font-style: italic;
    font-size: var(--fs-xs);
}

.resumo-item {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: #c8bda8;
}

.resumo-item strong {
    color: var(--accent);
}

.resumo-item:last-child {
    border-bottom: none;
}

/* Sidebar Actions */
.sidebar-actions {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-gerar-pdf, .btn-reiniciar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: var(--fs-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-gerar-pdf {
    background: var(--accent);
    color: var(--text-on-accent);
}

.btn-gerar-pdf:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-gerar-pdf:disabled {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-sidebar-muted);
    cursor: not-allowed;
}

.btn-reiniciar {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sidebar);
}

.btn-reiniciar:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    font-size: var(--fs-xs);
    color: var(--text-sidebar-muted);
    text-align: center;
}

.sidebar-footer .dev {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.65rem;
}

/* ============================================================
   CHAT MAIN
   ============================================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-chat);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--accent-light);
}

.chat-header-info h1 {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.chat-header-info .status {
    font-size: var(--fs-xs);
    color: var(--success);
    font-weight: 500;
}

.chat-header-avatar {
    font-size: 32px;
    margin-left: auto;
    line-height: 1;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

/* Message */
.message {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: messageIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.message.user .message-avatar {
    background: var(--accent-light);
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: var(--fs-md);
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.message.assistant .message-bubble {
    background: var(--bg-bubble-assistant);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-light);
}

.message.user .message-bubble {
    background: var(--bg-bubble-user);
    color: var(--text-user-bubble);
    border-bottom-right-radius: 4px;
}

.message-bubble p {
    margin-bottom: 6px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul {
    margin: 4px 0;
    padding-left: 18px;
}

.message-bubble ul li {
    margin-bottom: 2px;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble em {
    font-style: italic;
    opacity: 0.9;
}

/* Mensagem de foto */
.message-photo {
    margin: 4px 0;
}

.message-photo img {
    max-width: 280px;
    max-height: 200px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}

.message-photo img:hover {
    transform: scale(1.03);
}

/* Feedback visual */
.message.thinking .message-bubble {
    opacity: 0.7;
}

.message .typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.message .typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: var(--radius-full);
    animation: typingDot 1.4s infinite ease-in-out;
}

.message .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.message .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.chat-input-container {
    padding: 12px 20px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -2px 12px rgba(44, 36, 22, 0.04);
}

.image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
    animation: messageIn 0.3s ease;
}

.image-preview.hidden {
    display: none;
}

.image-preview img {
    max-height: 100px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.remove-preview {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--warning);
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

.remove-preview:hover {
    transform: scale(1.15);
}

.chat-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-app);
    border-radius: var(--radius-xl);
    padding: 6px 8px;
    border: 1.5px solid var(--border);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.btn-attach {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    transition: background var(--transition);
    line-height: 1;
    color: var(--text-secondary);
}

.btn-attach:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.btn-attach.uploading {
    animation: pulse 0.8s infinite;
    color: var(--accent);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: var(--fs-md);
    color: var(--text-primary);
    padding: 8px 4px;
    outline: none;
}

.chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.btn-send {
    background: var(--accent);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================================
   MODAL PDF
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 27, 24, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 36px 32px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.modal-card h2 {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.modal-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: var(--text-on-accent);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--fs-md);
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-download:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-close-modal {
    padding: 12px 24px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--fs-md);
    font-weight: 500;
    transition: all var(--transition);
}

.btn-close-modal:hover {
    background: var(--bg-app);
    border-color: var(--text-secondary);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }

    .message {
        max-width: 90%;
    }

    .chat-messages {
        padding: 16px 12px;
    }

    .chat-input-container {
        padding: 10px 12px 14px;
    }
}
