/* ============================================
   PAPAFILAS IA - Estilos Principais
   Paleta: Laranja #F26522 | Verde #2E9E52 | Cinza #2D2D2D
============================================ */

:root {
    /* Cores da Marca PapaFilas */
    --primary-gradient: linear-gradient(135deg, #F26522 0%, #f5832e 50%, #2E9E52 100%);
    --primary-orange: #F26522;
    --primary-green: #2E9E52;
    --primary-light: #FFF3EC;

    /* Cores Neutras (dark theme mantido) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #252540;
    --bg-tertiary: #2d2d44;
    --text-primary: #ffffff;
    --text-secondary: #b4b4c8;
    --text-tertiary: #8a8a9e;

    /* Cores de Mensagem */
    --user-bg: #2d2d44;
    --assistant-bg: linear-gradient(135deg, rgba(242, 101, 34, 0.12) 0%, rgba(46, 158, 82, 0.12) 100%);

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);

    /* Transições */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   HEADER
============================================ */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(242, 101, 34, 0.2);
    backdrop-filter: blur(10px);
}

.header-content {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 40px;
    width: auto;
    border-radius: 6px;
}

.logo-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-md);
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-orange);
}

.logo-text-group {
    display: flex;
    flex-direction: column;
}

.logo-slogan {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.logo-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Header Actions Container */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid rgba(242, 101, 34, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-button:hover {
    background: rgba(242, 101, 34, 0.15);
    border-color: rgba(242, 101, 34, 0.4);
}

.header-button svg {
    color: var(--primary-orange);
}

.clear-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid rgba(242, 101, 34, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.clear-button:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================
   CONTAINER PRINCIPAL
============================================ */

.container {
    max-width: 1000px;
    margin: 0 auto;
    height: calc(100vh - 90px);
    display: flex;
    flex-direction: column;
    padding: 0 1rem;
}

/* ============================================
   CHAT AREA
============================================ */

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar { width: 8px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}
.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(242, 101, 34, 0.3);
}

/* ============================================
   WELCOME MESSAGE
============================================ */

.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    text-align: center;
}

.welcome-content {
    max-width: 600px;
}

.welcome-logo {
    width: 240px;
    height: auto;
    margin: 0 auto 2rem;
    border-radius: 12px;
}

.welcome-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-orange);
}

.welcome-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 2rem;
}

.suggestion-chip {
    padding: 0.75rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid rgba(242, 101, 34, 0.25);
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.suggestion-chip:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================
   MENSAGENS
============================================ */

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
}

.message.user .message-avatar      { background: var(--user-bg); }
.message.assistant .message-avatar { background: var(--primary-gradient); }

.message-content {
    flex: 1;
    max-width: 70%;
}

.message.user .message-content { text-align: right; }

.message-bubble {
    padding: 1rem 1.5rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--user-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px 16px 4px 16px;
}

.message.assistant .message-bubble {
    background: var(--assistant-bg);
    border: 1px solid rgba(242, 101, 34, 0.2);
    border-radius: 16px 16px 16px 4px;
}

.message-timestamp {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* ============================================
   INPUT AREA
============================================ */

.input-container {
    padding: 1.5rem 0;
    background: var(--bg-primary);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid rgba(242, 101, 34, 0.2);
    border-radius: 16px;
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(242, 101, 34, 0.1);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
}

#userInput::placeholder { color: var(--text-tertiary); }

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-button:disabled { opacity: 0.5; cursor: not-allowed; }
.send-button svg { stroke: white; }

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.char-count { font-weight: 500; }

/* ============================================
   TYPING INDICATOR
============================================ */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    margin: 10px 0;
    background: rgba(30, 41, 59, 0.9);
    border-radius: 18px;
    width: fit-content;
}

.typing-dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    border-radius: 50%;
    background: var(--primary-orange);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ============================================
   RESPONSIVO
============================================ */

@media (max-width: 768px) {
    .header-content { padding: 1rem; }
    .logo-text h1   { font-size: 1.2rem; }
    .clear-button   { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .welcome-content h2 { font-size: 1.5rem; }
    .message-content    { max-width: 85%; }
    .suggestion-chip    { font-size: 0.8rem; padding: 0.6rem 1rem; }
}

@media (max-width: 480px) {
    .logo-slogan { display: none; }
    .welcome-suggestions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 0 0.5rem;
        width: 100%;
    }
    .suggestion-chip {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.75rem 0.5rem;
        text-align: center;
        white-space: normal;
        line-height: 1.3;
    }
    .welcome-content { padding: 0 0.5rem; }
    .welcome-content p { font-size: 0.95rem; }
    .welcome-logo { width: 160px; margin-bottom: 1.5rem; }
}

/* ============================================
   UTILITIES
============================================ */

.hidden { display: none !important; }

.fade-out { animation: fadeOut 0.3s ease forwards; }

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ============================================
   MENU HAMBÚRGUER
============================================ */

.logo-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-orange);
}

.header-user {
    flex: 1;
    text-align: center;
    padding: 0 8px;
    min-width: 0;
}

.user-greeting-mini {
    font-size: 0.9rem;
    color: var(--primary-orange);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.menu-toggle:hover,
.menu-toggle:focus {
    background: rgba(242, 101, 34, 0.1);
    outline: none;
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--primary-orange);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.menu-toggle.active .hamburger-line:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.menu-toggle.active .hamburger-line:nth-child(2) { opacity: 0; }
.menu-toggle.active .hamburger-line:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

.dropdown-menu {
    position: fixed;
    top: 80px;
    right: 16px;
    min-width: 220px;
    background: var(--bg-secondary);
    border: 1px solid rgba(242, 101, 34, 0.2);
    border-radius: 14px;
    padding: 8px 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    z-index: 1000;
}

.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    font-family: inherit;
}

.menu-item:hover { background: rgba(242, 101, 34, 0.12); }
.menu-item svg   { flex-shrink: 0; color: var(--primary-orange); }

.menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 0;
}

.menu-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: transparent;
    z-index: 999;
    display: none;
}

.menu-overlay.active { display: block; }

@media (max-width: 360px) {
    .header-content { padding: 10px 12px !important; }
    .logo-title      { font-size: 1rem; }
    .user-greeting-mini { font-size: 0.8rem; }
    .menu-toggle     { width: 40px; height: 40px; }
}

/* ============================================
   BOTÕES DE AÇÃO NAS MENSAGENS
============================================ */

.message-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 6px;
}

.listen-button {
    padding: 6px 14px;
    background: rgba(242, 101, 34, 0.12);
    border: 1px solid rgba(242, 101, 34, 0.3);
    border-radius: 16px;
    color: var(--primary-orange);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.listen-button:hover {
    background: rgba(242, 101, 34, 0.22);
    border-color: rgba(242, 101, 34, 0.5);
}

.feedback-buttons { display: flex; gap: 6px; }

.feedback-button {
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-button:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.feedback-like:hover    { background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.3); color: #22c55e; }
.feedback-dislike:hover { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); color: #ef4444; }

.feedback-buttons.feedback-given { opacity: 0.5; pointer-events: none; }
.feedback-buttons.feedback-given::after {
    content: '✔ Obrigado!';
    color: var(--primary-orange);
    font-size: 0.75rem;
    margin-left: 8px;
}

/* ============================================
   PAINEL DE CONVERSAS ANTIGAS
============================================ */

.old-conversations-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.old-conversations-overlay.active { display: flex; }

.old-conversations-panel {
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(242, 101, 34, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.old-conversations-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid rgba(242, 101, 34, 0.15);
}

.old-conversations-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.old-conversations-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.old-conversations-close:hover {
    background: rgba(242, 101, 34, 0.2);
    color: var(--primary-orange);
}

.old-conversations-body { display: flex; flex: 1; overflow: hidden; }

.old-sessions-list {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    background: var(--bg-primary);
}

.old-sessions-loading,
.old-sessions-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-tertiary);
    gap: 8px;
}

.old-sessions-empty p { margin: 0; font-size: 0.9rem; }

.old-session-item {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s ease;
}

.old-session-item:hover  { background: rgba(255, 255, 255, 0.05); }
.old-session-item.active {
    background: rgba(242, 101, 34, 0.12);
    border-left: 3px solid var(--primary-orange);
}

.old-session-date { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.old-session-info { font-size: 0.75rem; color: var(--text-tertiary); }

.old-messages-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.old-messages-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    color: var(--text-tertiary);
}

.old-messages-placeholder p { margin: 0; font-size: 0.95rem; }

.old-messages-list { flex: 1; overflow-y: auto; padding: 16px 20px; }

.old-message { margin-bottom: 16px; display: flex; gap: 10px; }
.old-message.user { flex-direction: row-reverse; }

.old-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.old-message.assistant .old-message-avatar { background: var(--primary-gradient); }

.old-message-content { max-width: 75%; }

.old-message-bubble { padding: 10px 14px; border-radius: 16px; font-size: 0.9rem; line-height: 1.5; }

.old-message.user .old-message-bubble {
    background: var(--user-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.old-message.assistant .old-message-bubble {
    background: var(--assistant-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.old-message-time { font-size: 0.7rem; color: var(--text-tertiary); margin-top: 4px; padding: 0 4px; }
.old-message.user .old-message-time { text-align: right; }

@media (max-width: 768px) {
    .old-conversations-panel { max-height: 95vh; border-radius: 12px; }
    .old-conversations-body  { flex-direction: column; }
    .old-sessions-list       { width: 100%; min-width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.1); }
    .old-messages-container  { flex: 1; min-height: 300px; }
    .old-message-content     { max-width: 85%; }
}

/* ============================================
   CARD MOTIVACIONAL
============================================ */

.motivational-card {
    position: relative;
    max-width: 600px;
    margin: 16px auto;
    padding: 24px 48px 24px 24px;
    background: var(--bg-secondary);
    border: 1px solid rgba(242, 101, 34, 0.25);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.motivational-card.fade-in { animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.motivational-content { padding: 0 8px; }

.phrase-text {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.phrase-author {
    font-size: 0.9rem;
    color: var(--primary-orange);
    font-weight: 500;
}

.motivational-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(242, 101, 34, 0.3);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
    padding: 0;
    line-height: 1;
}

.motivational-close:hover {
    background: rgba(242, 101, 34, 0.25);
    border-color: var(--primary-orange);
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(242, 101, 34, 0.3);
}

@media (max-width: 768px) {
    .motivational-card  { margin: 12px 16px; padding: 20px 40px 20px 20px; }
    .phrase-text        { font-size: 1rem; }
    .motivational-close { top: 8px; right: 8px; width: 28px; height: 28px; font-size: 14px; }
}

/* ============================================
   LOGOS PAPAFILAS
============================================ */

.logo-header {
    height: 76px;
    width: auto;
    display: block;
}

.welcome-logo {
    width: 560px;
    height: auto;
    margin: 0 auto 2rem;
    display: block;
    border-radius: 16px;
}
