/* =============================================================================
   CHUCHUREX - Professional Design System
   Inspiración: Claude.ai (Clean, Serif headers, Soft UI)
   Paleta: Conchevino (#722F37) + Papel Premium
   ============================================================================= */

:root
{
    /* Colors */
    --color-bg-page: #F9F7F5;
    /* Más papel, menos crema amarillo */
    --color-bg-subtle: #F0EBE5;
    --color-surface: #FFFFFF;

    --color-conchevino: #722F37;
    --color-conchevino-dark: #5C252C;
    --color-conchevino-light: #9D4E58;
    /* Más suave para acentos */
    --color-conchevino-alpha: rgba(114, 47, 55, 0.05);

    --color-text-main: #2D2426;
    --color-text-muted: #6B5E60;
    --color-border: #E8E2D9;

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing & Layout */
    --max-width-chat: 800px;
    --header-height: 70px;

    /* Radius - Claude style (Apple-like soft curves) */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    /* Shadows - Soft & Diffused */
    --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.02);
    --shadow-floating: 0 12px 32px rgba(114, 47, 55, 0.08), 0 4px 12px rgba(114, 47, 55, 0.04);

    /* Transitions */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body
{
    height: 100%;
    overflow: hidden;
    /* App-like feel */
}

body
{
    font-family: var(--font-body);
    background-color: var(--color-bg-page);
    color: var(--color-text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

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

.header
{
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(249, 247, 245, 0.85);
    /* Glassmorphism */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.header.scrolled
{
    background: rgba(249, 247, 245, 0.95);
    border-bottom-color: var(--color-border);
}

.logo
{
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-conchevino);
    text-decoration: none;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
}

.logo span
{
    color: var(--color-conchevino-light);
    font-style: italic;
    margin-left: 1px;
}

.nav
{
    display: flex;
    gap: 1rem;
}

.nav-link
{
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.nav-link:hover
{
    color: var(--color-conchevino);
    background: var(--color-conchevino-alpha);
}

/* =============================================================================
   MAIN LAYOUT
   ============================================================================= */

.main
{
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-top: var(--header-height);
    width: 100%;
    max-width: var(--max-width-chat);
    margin: 0 auto;
}

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

.chat-container
{
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 2rem;
    /* Space for footer/input */
}

.chat-messages
{
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    /* Hide scrollbar for cleaner look */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.chat-messages::-webkit-scrollbar
{
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb
{
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* Empty state handling */
.chat-messages:empty
{
    display: none;
}

/* =============================================================================
   MESSAGES
   ============================================================================= */

.message
{
    max-width: 100%;
    line-height: 1.7;
    font-size: 1.05rem;
    animation: fadeIn 0.4s var(--ease-out);
}

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

    to
    {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user
{
    align-self: flex-end;
    background-color: var(--color-bg-subtle);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    border-bottom-right-radius: 4px;
    /* Callout shape */
    color: var(--color-text-main);
    max-width: 85%;
    font-weight: 500;
}

.message-assistant
{
    align-self: flex-start;
    padding-right: 2rem;
    color: var(--color-text-main);
}

.message-assistant p
{
    margin-bottom: 1rem;
}

.message-assistant p:last-child
{
    margin-bottom: 0;
}

/* Typing Indicator */
.typing-indicator
{
    padding: 1rem;
    margin-left: 0.5rem;
    display: flex;
    gap: 6px;
}

.typing-indicator span
{
    width: 6px;
    height: 6px;
    background: var(--color-text-muted);
    border-radius: 50%;
    opacity: 0.4;
    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%,
    100%
    {
        transform: translateY(0);
    }

    50%
    {
        transform: translateY(-4px);
    }
}

/* =============================================================================
   PROMPT / EMPTY STATE
   ============================================================================= */

/* Center container when empty */
.chat-container:has(.chat-messages:empty)
{
    justify-content: center;
    align-items: center;
}

.chat-prompt
{
    text-align: center;
    margin-bottom: 3rem;
}

/* Hide prompt when messages exist */
.chat-messages:not(:empty) ~ .chat-prompt
{
    display: none;
}

.prompt-title
{
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 500;
    font-style: italic;
    color: var(--color-conchevino);
    line-height: 1.2;
    margin-bottom: 1rem;
}

/* =============================================================================
   INPUT AREA (The "Claude" Box)
   ============================================================================= */

.chat-form
{
    width: 100%;
    padding: 0 2rem;
    position: relative;
    /* If content exists, it sticks to bottom. If empty, it's centered by parent */
    margin-bottom: 1rem;
}

.input-wrapper
{
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    /* Big round corners */
    padding: 1rem 1.25rem;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    box-shadow: var(--shadow-subtle);
    transition: all 0.3s var(--ease-out);
    position: relative;
}

/* Enhanced shadow on focus/hover */
.input-wrapper:hover,
.input-wrapper:focus-within
{
    box-shadow: var(--shadow-floating);
    border-color: transparent;
    transform: translateY(-2px);
}

.chat-input
{
    flex: 1;
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--color-text-main);
    background: transparent;
    resize: none;
    min-height: 28px;
    max-height: 200px;
    padding: 4px 0;
    line-height: 1.5;
}

.chat-input::placeholder
{
    color: #A09596;
    font-weight: 400;
}

.send-button
{
    width: 36px;
    height: 36px;
    background: var(--color-conchevino);
    color: white;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.send-button:hover
{
    background: var(--color-conchevino-dark);
    transform: scale(1.05);
}

.send-button:disabled
{
    background: #E0D8D9;
    cursor: default;
    transform: none;
}

/* =============================================================================
   FOOTER
   ============================================================================= */

.footer
{
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.footer a
{
    color: var(--color-text-muted);
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color 0.2s;
}

.footer a:hover
{
    color: var(--color-conchevino);
}

/* =============================================================================
   MODAL
   ============================================================================= */

.modal
{
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45, 36, 38, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active
{
    display: flex;
    opacity: 1;
}

.modal-content
{
    background: var(--color-surface);
    padding: 3rem;
    border-radius: var(--radius-lg);
    max-width: 550px;
    width: 100%;
    box-shadow: var(--shadow-floating);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s var(--ease-out);
}

.modal.active .modal-content
{
    transform: translateY(0);
}

.modal-close
{
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-content h2
{
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--color-conchevino);
    margin-bottom: 1.5rem;
}

.modal-content p
{
    margin-bottom: 1rem;
    color: var(--color-text-main);
    font-size: 1.1rem;
}

/* =============================================================================
   PDF STYLES
   ============================================================================= */

.message-pdf
{
    display: inline-flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pdf-download-button
{
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--color-conchevino);
    color: white;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-subtle);
}

.pdf-download-button:hover
{
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(114, 47, 55, 0.2);
}

.message-pdf-loading
{
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--color-conchevino);
    font-weight: 500;
}

.pdf-spinner
{
    width: 24px;
    height: 24px;
    border: 3px solid rgba(114, 47, 55, 0.1);
    border-top-color: var(--color-conchevino);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin
{
    to
    {
        transform: rotate(360deg);
    }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px)
{
    .header
    {
        padding: 0 1rem;
        height: 60px;
    }

    .main
    {
        padding-top: calc(60px + 1rem);
    }

    .chat-messages
    {
        padding: 1rem;
    }

    .chat-form
    {
        padding: 0 1rem;
    }

    .prompt-title
    {
        font-size: 2rem;
        padding: 0 1rem;
    }



    .message-user
    {
        max-width: 90%;
    }
}