:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fcfcfd;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #1f2937; /* Dark slate */
    --text-secondary: #6b7280; /* Neutral gray */
    --accent-color: #4f46e5; /* Indigo */
    --accent-glow: rgba(79, 70, 229, 0.15);
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    --chat-bg-user: rgba(79, 70, 229, 0.08);
    --chat-bg-assistant: #f3f4f6;
    --font-family: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-speed: 0.25s;
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 10% 20%, rgba(79, 70, 229, 0.03) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(59, 130, 246, 0.03) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Setup Overlay Screen */
.setup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
}

.setup-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.setup-content {
    text-align: center;
    max-width: 450px;
    padding: 2.5rem;
    position: relative;
}

/* Pulsing Ambient Orbs */
.glow-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
}

.glowing-orb {
    width: 180px;
    height: 180px;
    background: var(--accent-gradient);
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0.1;
    animation: orbPulse 6s infinite alternate ease-in-out;
}

@keyframes orbPulse {
    0% { transform: scale(1); opacity: 0.08; }
    100% { transform: scale(1.3); opacity: 0.15; }
}

.glow-text {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

#setup-status {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

#setup-subtext {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Spinner Ring */
.spinner-ring {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 2rem;
}
.spinner-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 64px;
    height: 64px;
    margin: 8px;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-top-color: var(--accent-color);
}
.spinner-ring div:nth-child(1) { animation-delay: -0.45s; border-top-color: #3b82f6; }
.spinner-ring div:nth-child(2) { animation-delay: -0.3s; border-top-color: #4f46e5; }
.spinner-ring div:nth-child(3) { animation-delay: -0.15s; border-top-color: #60a5fa; }
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* App Main Container */
.app-container {
    width: 92vw;
    height: 90vh;
    max-width: 900px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 
                0 1px 3px rgba(0, 0, 0, 0.02);
    overflow: hidden;
    position: relative;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}

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

.logo-icon {
    font-size: 1.4rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulseLogo 3s infinite ease-in-out;
}

@keyframes pulseLogo {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.15); filter: brightness(1.1); }
}

.header-logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f3f4f6;
    padding: 0.4rem 0.8rem;
    border-radius: 100px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.status-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.9rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    color: var(--text-primary);
}

.upload-btn:hover {
    background: #f9fafb;
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.upload-btn svg {
    width: 14px;
    height: 14px;
}

/* Chat Window */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #ffffff;
    scroll-behavior: smooth;
}

/* Scrollbar Styling */
.chat-window::-webkit-scrollbar {
    width: 6px;
}
.chat-window::-webkit-scrollbar-track {
    background: transparent;
}
.chat-window::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}
.chat-window::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.18);
}

/* Empty State / Welcome Screen */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

.empty-icon {
    font-size: 3rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
}

@media (min-width: 600px) {
    .suggestions-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.suggestion-card {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-family);
    font-size: 0.88rem;
    line-height: 1.4;
}

.suggestion-card:hover {
    background: #ffffff;
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.05);
    transform: translateY(-1px);
}

.suggestion-card .arrow {
    opacity: 0;
    transform: translateX(-5px);
    transition: all var(--transition-speed) ease;
    color: var(--accent-color);
    font-weight: bold;
}

.suggestion-card:hover .arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Chat Messages */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
    margin-left: 0.5rem;
}

.message.user .message-label {
    align-self: flex-end;
    margin-left: 0;
    margin-right: 0.5rem;
    color: var(--accent-color);
}

.message.assistant .message-label {
    color: #2563eb; /* Blue */
}

.message-bubble {
    padding: 0.9rem 1.2rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.message.user .message-bubble {
    background: var(--chat-bg-user);
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-top-right-radius: 4px;
    color: #1e1b4b; /* Deep indigo text */
}

.message.assistant .message-bubble {
    background: var(--chat-bg-assistant);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-top-left-radius: 4px;
    color: #374151;
}

/* Rich text citations inside the message */
.citation {
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: #2563eb;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
    margin: 0.1rem 0.2rem;
}

/* Loading/Typing Loader */
.typing-indicator-wrapper {
    display: none;
    align-self: flex-start;
    max-width: 80%;
    animation: messageFadeIn 0.3s ease-out;
}

.typing-indicator-bubble {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--chat-bg-assistant);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.8rem 1.25rem;
    border-radius: 16px;
    border-top-left-radius: 4px;
}

.typing-indicator-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.typing-indicator-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

.typing-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Input Panel */
.input-panel {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    align-items: center;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.chat-form:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.1);
    background: #ffffff;
}

.chat-form textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    padding: 0.5rem;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.chat-form textarea::placeholder {
    color: #9ca3af;
}

.chat-form button {
    background: var(--accent-gradient);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    flex-shrink: 0;
}

.chat-form button:hover {
    transform: scale(1.03);
    filter: brightness(1.05);
}

.chat-form button:active {
    transform: scale(0.97);
}

.chat-form button svg {
    width: 16px;
    height: 16px;
    transform: translate(-1px, 1px);
}

/* Footer (Document Label at the bottom) */
.app-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 2rem;
    border-top: 1px solid var(--border-color);
    background: #f9fafb;
}

.footer-document {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.doc-icon {
    font-size: 0.9rem;
}

.doc-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Standard Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
