/* === mordech.ai — Purim-Themed Chat Interface === */

:root {
    /* Purim Color Palette — Purple & Gold */
    --purple-deep: #2d1b4e;
    --purple-dark: #3d2066;
    --purple-main: #5b2d8e;
    --purple-light: #7c4dba;
    --purple-lighter: #a855f7;
    --purple-subtle: #f3e8ff;
    --gold-main: #d4a017;
    --gold-light: #ffe082;
    --gold-subtle: #fef9e7;
    --cream: #fdfbf7;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Layout */
    --header-height: 64px;
    --input-area-height: auto;
    --max-width: 800px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--cream);
    color: var(--gray-800);
    line-height: 1.6;
}

/* === App Layout === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* === Header === */
.app-header {
    background: linear-gradient(135deg, var(--purple-deep) 0%, var(--purple-dark) 100%);
    border-bottom: 2px solid var(--gold-main);
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(45, 27, 78, 0.3);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.02em;
}

.ai-accent {
    color: inherit;
}

.tagline {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: -2px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
    color: var(--white);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--gold-light);
    color: var(--gold-light);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-info-btn {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-sm);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.2;
}

.email-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--gold-light);
    color: var(--gold-light);
    text-decoration: none;
}

/* === Age Selection Screen === */
.age-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 2rem 1rem;
}

.age-content {
    text-align: center;
    max-width: 600px;
}

.age-content h2 {
    font-size: 2rem;
    color: var(--purple-dark);
    margin-bottom: 0.5rem;
}

.age-content > p {
    font-size: 1.1rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.age-prompt {
    font-size: 1rem;
    color: var(--gray-700);
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.age-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.age-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 2.5rem;
    background: var(--white);
    border: 2px solid var(--purple-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(91, 45, 142, 0.1);
    min-width: 160px;
}

.age-btn:hover {
    background: var(--purple-subtle);
    border-color: var(--purple-main);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(91, 45, 142, 0.2);
}

.age-emoji {
    font-size: 2.5rem;
}

.age-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--purple-dark);
}

/* === Chat Area === */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    scroll-behavior: smooth;
}

/* === Welcome Screen === */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 2rem 1rem;
}

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

.welcome-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: gentle-float 3s ease-in-out infinite;
}

@keyframes gentle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-content h2 {
    font-size: 1.75rem;
    color: var(--purple-dark);
    margin-bottom: 0.75rem;
}

.welcome-content p {
    font-size: 1.05rem;
    color: var(--gray-600);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.purim-dates {
    margin: 1.5rem 0;
    text-align: center;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.purim-dates h3 {
    font-size: 1rem;
    color: var(--purple-dark);
    margin-bottom: 0.75rem;
}

.purim-dates table {
    margin: 0 auto;
    border-collapse: collapse;
    font-size: 0.85rem;
    width: 100%;
    background: var(--white);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(91, 45, 142, 0.1);
}

.purim-dates th {
    background: var(--purple-main);
    color: var(--white);
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.purim-dates td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
    white-space: nowrap;
}

.purim-dates tr:last-child td {
    border-bottom: none;
}

.dates-note {
    font-size: 0.78rem;
    color: var(--gray-500);
    font-style: italic;
    margin-top: 0.5rem;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.chip {
    padding: 0.6rem 1rem;
    background: var(--white);
    border: 1px solid var(--purple-light);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--purple-main);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(91, 45, 142, 0.1);
}

.chip:hover {
    background: var(--purple-subtle);
    border-color: var(--purple-main);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(91, 45, 142, 0.15);
}

/* === Messages === */
.messages-container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.message.user .message-avatar {
    background: var(--purple-light);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--gold-main), var(--gold-light));
    box-shadow: 0 2px 6px rgba(212, 160, 23, 0.3);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message.user .message-content {
    background: var(--purple-main);
    color: var(--white);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    border-top-left-radius: 4px;
    max-width: 85%;
}

.message.assistant .message-content {
    background: var(--white);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    border-top-left-radius: 4px;
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Markdown content styling */
.message.assistant .message-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
}

.message.assistant .message-content h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--purple-dark);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.message.assistant .message-content h2,
.message.assistant .message-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--purple-dark);
    margin-top: 0.75rem;
    margin-bottom: 0.4rem;
}

.message.assistant .message-content h1:first-child,
.message.assistant .message-content h2:first-child,
.message.assistant .message-content h3:first-child {
    margin-top: 0;
}

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

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

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message.assistant .message-content li {
    margin-bottom: 0.25rem;
}

.message.assistant .message-content strong {
    color: var(--purple-dark);
}

.message.assistant .message-content code {
    background: var(--gray-100);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.message.assistant .message-content blockquote {
    border-left: 3px solid var(--gold-main);
    padding-left: 1rem;
    margin: 0.75rem 0;
    color: var(--gray-600);
    font-style: italic;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--purple-light);
    animation: typing-bounce 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-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* === Input Area === */
.input-area {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1rem 0.75rem;
    flex-shrink: 0;
}

.input-container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--purple-light);
    box-shadow: 0 0 0 3px rgba(91, 45, 142, 0.1);
}

.input-container textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 150px;
    font-family: inherit;
    color: var(--gray-800);
}

.input-container textarea::placeholder {
    color: var(--gray-500);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--purple-main);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--purple-dark);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.disclaimer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
}

/* === Responsive === */
@media (max-width: 768px) {
    .app-header {
        padding: 0 1rem;
    }

    .logo-text h1 {
        font-size: 1.2rem;
    }

    .tagline {
        display: none;
    }

    .new-chat-btn span {
        display: none;
    }

    .new-chat-btn {
        padding: 0.5rem;
    }

    .chat-area {
        padding: 1rem 0.75rem;
    }

    .welcome-content h2 {
        font-size: 1.4rem;
    }

    .welcome-content p {
        font-size: 0.95rem;
    }

    .chip {
        font-size: 0.8rem;
        padding: 0.5rem 0.85rem;
    }

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

    .input-area {
        padding: 0.75rem 0.75rem 0.5rem;
    }
}

@media (max-width: 400px) {
    .suggestion-chips {
        flex-direction: column;
        align-items: center;
    }
}
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .app-header {
        padding: 0 0.75rem;
        height: 56px;
    }

    .logo-text h1 {
        font-size: 1.2rem;
    }

    .tagline {
        display: none;
    }

    /* Hide date and email buttons on mobile — keep only New Chat icon */
    .header-info-btn {
        display: none;
    }

    .new-chat-btn span {
        display: none;
    }

    .new-chat-btn {
        padding: 0.5rem;
    }

    .chat-area {
        padding: 1rem 0.75rem;
    }

    .welcome-content h2 {
        font-size: 1.5rem;
    }

    .welcome-content p {
        font-size: 1rem;
        line-height: 1.6;
    }

    .purim-dates table {
        font-size: 0.8rem;
    }

    .purim-dates th,
    .purim-dates td {
        padding: 0.4rem 0.5rem;
    }

    .chip {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }

    /* Messages — larger text on mobile */
    .message.assistant .message-content {
        font-size: 1rem;
        line-height: 1.7;
        padding: 0.85rem 1rem;
    }

    .message.user .message-content {
        font-size: 1rem;
        max-width: 90%;
        padding: 0.85rem 1rem;
    }

    .message.assistant .message-content h1 {
        font-size: 1.15rem;
    }

    .message.assistant .message-content h2,
    .message.assistant .message-content h3 {
        font-size: 1.05rem;
    }

    /* Input area — larger touch targets */
    .input-area {
        padding: 0.75rem 0.75rem 0.5rem;
    }

    .input-container textarea {
        font-size: 1rem;
    }

    .send-btn {
        width: 40px;
        height: 40px;
    }

    .disclaimer {
        font-size: 0.75rem;
    }
}

@media (max-width: 400px) {
    .suggestion-chips {
        flex-direction: column;
        align-items: stretch;
    }

    .chip {
        text-align: center;
    }

    .purim-dates {
        overflow-x: auto;
    }
}

/* === Scrollbar Styling === */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Hidden utility */
.hidden {
    display: none !important;
}
