/**
 * 🌵 ScholarFlow - Orange Cactus Scholar Theme
 * Warm Mexican-inspired design with vibrant orange, purple, turquoise
 */

:root {
    /* Base — Deep purple (no brown!) */
    --sf-bg: #1a1020;
    --sf-bg-light: #241830;
    --sf-bg-card: #2a1e38;
    --sf-bg-input: #1e1428;

    /* Accents — Vibrant Mexican trio */
    --sf-orange: #ff6b35;
    --sf-orange-dim: rgba(255, 107, 53, 0.15);
    --sf-purple: #9b4dca;
    --sf-purple-dim: rgba(155, 77, 202, 0.15);
    --sf-turquoise: #00c9b1;
    --sf-turquoise-dim: rgba(0, 201, 177, 0.2);

    /* Text */
    --sf-text: #fff5f0;
    --sf-text-muted: #b0a0c0;
    --sf-text-dim: #786890;

    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

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

html,
body {
    height: 100%;
    font-family: var(--font-main);
    background: var(--sf-bg);
    color: var(--sf-text);
    -webkit-font-smoothing: antialiased;
}

/* Strong geometric background pattern - more visible */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(30deg, rgba(255, 107, 53, 0.08) 2px, transparent 2px),
        linear-gradient(150deg, rgba(155, 77, 202, 0.06) 2px, transparent 2px),
        linear-gradient(90deg, rgba(255, 107, 53, 0.04) 1px, transparent 1px),
        linear-gradient(0deg, rgba(155, 77, 202, 0.04) 1px, transparent 1px);
    background-size: 80px 80px, 80px 80px, 40px 40px, 40px 40px;
    opacity: 0.8;
    pointer-events: none;
    z-index: 0;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.welcome-screen.hidden {
    display: none;
}

.welcome-card {
    background: var(--sf-bg-card);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: var(--radius-md);
    padding: var(--space-lg) var(--space-xl);
    text-align: center;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.welcome-emoji {
    font-size: 2rem;
    display: block;
    margin-bottom: var(--space-sm);
}

.welcome-card h2 {
    color: var(--sf-orange);
    margin-bottom: var(--space-xs);
    font-size: 1.3rem;
}

.welcome-card>p {
    color: var(--sf-text-muted);
    margin-bottom: var(--space-sm);
    line-height: 1.4;
    font-size: 0.9rem;
}

.welcome-card .intro-text {
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
}

.welcome-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.welcome-form input {
    background: var(--sf-bg-input);
    border: 1px solid rgba(155, 77, 202, 0.3);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    color: var(--sf-text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.welcome-form input:focus {
    border-color: var(--sf-turquoise);
}

.welcome-form input::placeholder {
    color: var(--sf-text-dim);
}

.start-btn {
    background: var(--sf-turquoise);
    color: var(--sf-bg);
    border: none;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.start-btn:hover {
    background: var(--sf-orange);
    transform: translateY(-2px);
}

.privacy-note {
    font-size: 0.75rem;
    color: var(--sf-text-dim);
    margin-top: var(--space-md);
}

/* Header */
.header {
    padding: var(--space-lg) var(--space-md);
    text-align: center;
    border-bottom: 1px solid rgba(255, 107, 53, 0.2);
    background: rgba(26, 16, 32, 0.9);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.cactus-logo {
    width: 140px;
    height: 140px;
    object-fit: contain;
}

.brand {
    font-size: 1.5rem;
    font-weight: 600;
}

.brand-scholar {
    color: var(--sf-text);
}

.brand-flow {
    color: var(--sf-orange);
}

.tagline {
    font-size: 0.85rem;
    color: var(--sf-text-muted);
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg) var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 48px;
}

/* Messages */
.message {
    max-width: 85%;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease-out;
    line-height: 1.5;
    margin-bottom: 16px;
}

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

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

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

/* AI Messages — Left aligned with orange accent */
.message.assistant {
    align-self: flex-start;
    background: var(--sf-bg-card);
    border-left: 3px solid var(--sf-orange);
    box-shadow: 0 2px 12px rgba(255, 107, 53, 0.1);
}

/* User Messages — Right aligned with purple tint */
.message.user {
    align-self: flex-end;
    background: var(--sf-purple-dim);
    border: 1px solid rgba(155, 77, 202, 0.3);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--sf-bg-card);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--sf-orange);
    width: fit-content;
}

.typing-indicator.hidden {
    display: none;
}

.cactus-typing {
    font-size: 1.2rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--sf-orange);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    padding: var(--space-md);
    background: rgba(26, 16, 32, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 107, 53, 0.2);
}

.input-wrapper {
    display: flex;
    gap: var(--space-sm);
    background: var(--sf-bg-input);
    border: 1px solid rgba(155, 77, 202, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--sf-turquoise);
    box-shadow: 0 0 0 3px var(--sf-turquoise-dim);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: var(--space-sm) var(--space-md);
    color: var(--sf-text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}

#message-input::placeholder {
    color: var(--sf-text-dim);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--sf-turquoise);
    border: none;
    border-radius: 50%;
    color: var(--sf-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--sf-orange);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--sf-text-dim);
    margin-top: var(--space-sm);
}

/* Completion Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(26, 16, 32, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--sf-bg-card);
    padding: var(--space-xl);
    border-radius: var(--radius-md);
    text-align: center;
    max-width: 400px;
    border: 1px solid var(--sf-orange);
    box-shadow: 0 0 40px rgba(255, 107, 53, 0.2);
}

.modal-content h2 {
    margin-bottom: var(--space-md);
    color: var(--sf-orange);
}

.modal-content p {
    color: var(--sf-text-muted);
    margin-bottom: var(--space-lg);
}

.modal-btn {
    background: var(--sf-turquoise);
    color: var(--sf-bg);
    border: none;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn:hover {
    background: var(--sf-orange);
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .header {
        padding: var(--space-md);
    }

    .brand {
        font-size: 1.25rem;
    }

    .chat-container {
        padding: var(--space-md);
    }

    .message {
        max-width: 90%;
        padding: var(--space-sm) var(--space-md);
    }
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--sf-bg);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--sf-purple-dim);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--sf-purple);
}