@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-app: #f8fafc;
    --bg-glass: rgba(248, 250, 252, 0.85);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-gold: #fbbf24;
    --border-glass: rgba(255, 255, 255, 0.5);
    --shadow-premium: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --header-height: 70px;
    --input-height: 80px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow-y: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Background Decoration */
.bg-gradient {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* Header */
header {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.logo-img {
    height: 32px;
    /* Slightly smaller for header */
    width: auto;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    /* Slightly smaller */
    letter-spacing: -0.025em;
    color: var(--text-primary);
    /* Dark grey text instead of gradient for header */
}

/* Header Buttons */
.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

/* Chat History Area */
.chat-container {
    flex: 1;
    overflow-y: visible;
    padding: 2rem 1rem 6rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* Message Bubbles */
.message {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: 1.5rem;
    line-height: 1.6;
    font-size: 1rem;
    position: relative;
    box-shadow: var(--shadow-premium);
    transition: all 0.3s ease;
}

.ai-message {
    line-height: 1.75;
}

.ai-message p {
    margin-bottom: 1.25rem;
}

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

.ai-message h1,
.ai-message h2,
.ai-message h3,
.ai-message h4 {
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.ai-message ul,
.ai-message ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.ai-message li {
    margin-bottom: 0.5rem;
}

.fade-in {
    animation: premiumFadeIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes premiumFadeIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
        filter: blur(4px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes fadeInSlide {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background-color: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-message {
    background-color: white;
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-glass);
}

.ai-message b {
    color: var(--primary);
    font-weight: 600;
}

.ai-message code {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    font-weight: 500;
}

/* Sources */
.sources-container {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed #e2e8f0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.source-item {
    display: inline-block;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    animation: premiumFadeIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.source-item:hover {
    background: #e2e8f0;
    color: var(--primary);
}

/* Input Area */
.input-container {
    padding: 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
}

.input-wrapper {
    width: 100%;
    max-width: 800px;
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    box-shadow: var(--shadow-premium);
    border: 1px solid #e2e8f0;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
}

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

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

.send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* Typing Indicator In-Bubble */
.typing-in-bubble {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 24px;
    transition: opacity 0.3s ease, margin 0.3s ease, height 0.3s ease;
    opacity: 1;
    overflow: hidden;
}

.typing-in-bubble.loader-hidden {
    opacity: 0;
    height: 0;
    margin: 0;
}

.typing-in-bubble .typing {
    padding: 0;
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 10px;
}

.dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

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

    40% {
        transform: scale(1.0);
    }
}


/* Scrollbar Style */
::-webkit-scrollbar {
    width: 6px;
}


::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- STATE: HOME --- */
body[data-state="home"] .chat-header {
    display: none;
}

body[data-state="home"] .chat-container {
    display: none;
}

body[data-state="home"] .home-hero {
    display: flex;
}

body[data-state="home"] .input-container {
    background: transparent;
    border-top: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding-bottom: 3rem;
}

body[data-state="home"] .input-wrapper {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    /* More pronounced floating shadow */
    border-color: transparent;
}

/* --- STATE: CHAT --- */
body[data-state="chat"] .home-hero {
    display: none;
}

body[data-state="chat"] .suggestions-container {
    display: none;
}

body[data-state="chat"] header {
    background-color: var(--bg-app);
    background-image: radial-gradient(circle at center, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
    background-attachment: fixed;
    background-position: center;
    background-size: 200% 200%;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none !important;
}

body[data-state="chat"] .input-container {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: none !important;
}

/* --- HERO SECTION --- */
.home-hero {
    flex: 1;
    display: none;
    /* Hidden by default unless in home state */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    animation: fadeInSlide 0.4s ease-out forwards;
}

.hero-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.hero-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 9999px;
    background: white;
    border: 1px solid #e2e8f0;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.hero-action-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.hero-action-btn .material-symbols-rounded {
    font-size: 1.2rem;
}

/* --- SUGGESTIONS --- */
.suggestions-container {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    max-width: 800px;
}

.suggestion-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 0.6rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.suggestion-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f8fafc;
}

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: opacity 0.3s;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    z-index: 101;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalPop 0.3s ease-out;
}

.modal.hidden,
.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

@keyframes modalPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -48%) scale(0.96);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.close-modal-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    text-align: center;
}

/* Share modal specifics */
.copy-link-container {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem;
    margin-bottom: 1.5rem;
}

.copy-link-container input {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    outline: none;
    border: none;
    background: transparent;
}

.copy-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: var(--primary-hover);
}

.social-share-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 6px;
    border: none;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.2s;
}

.social-btn:hover {
    filter: brightness(1.1);
}

.social-btn.facebook {
    background: #1877f2;
}

.social-btn.twitter {
    background: #1da1f2;
}

.social-btn.whatsapp {
    background: #25d366;
}

.social-btn.email {
    background: #64748b;
}

.social-btn.linkedin {
    background: #0a66c2;
    grid-column: span 2;
}

/* Feedback modal specifics */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.form-group .required {
    color: #ef4444;
}

.form-group input,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.submit-feedback-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.submit-feedback-btn:hover {
    background: var(--primary-hover);
}