/* AskJTCVS - AATS Styled Theme */

:root {
    --primary: #1a3a6e;
    --primary-light: #2856a0;
    --primary-hover: #234b8a;
    --bg: #f8fafc;
    --bg-alt: rgba(26, 58, 110, 0.03);
    --card: #ffffff;
    --text: #1a202c;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 0.65rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.logo-text h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}

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

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-links a {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-links .submit-btn {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-weight: 500;
}

.nav-links .submit-btn:hover {
    background: var(--primary-hover);
    color: white;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-wrapper {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Info Panel */
.info-panel {
    text-align: center;
    padding: 32px 0;
}

.hero {
    margin-bottom: 32px;
}

.hero-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.hero h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.hero p {
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
}

/* Quick Questions */
.quick-questions {
    margin-bottom: 32px;
}

.quick-questions h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.question-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.chip {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Journals Grid */
.journals-grid {
    background: var(--bg-alt);
    padding: 24px;
    border-radius: var(--radius);
}

.journals-grid h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
}

.journals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.journal-card {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s;
    text-align: left;
}

.journal-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.journal-card strong {
    display: block;
    color: var(--primary);
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.journal-card span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 0;
}

.chat-container:empty {
    display: none;
}

.chat-container:not(:empty) + .info-panel,
.chat-container:not(:empty) ~ .info-panel {
    display: none;
}

/* Messages */
.message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9375rem;
}

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

.message.assistant .message-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Collapsible excerpts */
.excerpts-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.excerpts-summary {
    cursor: pointer;
    color: var(--primary-light);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 4px 0;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.excerpts-summary:hover {
    color: var(--primary);
}

.excerpts-summary::before {
    content: '▶';
    font-size: 0.625rem;
    transition: transform 0.2s;
}

.excerpts-details[open] .excerpts-summary::before {
    transform: rotate(90deg);
}

.excerpts-content {
    margin-top: 8px;
    background: var(--bg);
    border-radius: 6px;
    padding: 12px;
}

.excerpt-item {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.excerpt-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.excerpt-number {
    font-weight: 600;
    color: var(--primary);
    margin-right: 8px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.loading-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Input Area */
.input-area {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(26, 58, 110, 0.1);
}

#userInput {
    flex: 1;
    border: none;
    padding: 12px 16px;
    font-size: 0.9375rem;
    background: transparent;
    outline: none;
    font-family: inherit;
}

#userInput::placeholder {
    color: var(--text-muted);
}

#sendButton {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: calc(var(--radius) - 4px);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton:hover {
    background: var(--primary-hover);
}

#sendButton:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.disclaimer a {
    color: var(--primary-light);
    text-decoration: none;
}

.disclaimer a:hover {
    text-decoration: underline;
}

/* Footer */
.footer {
    background: var(--primary);
    color: rgba(255,255,255,0.8);
    padding: 16px 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Responsive */
@media (max-width: 640px) {
    .header-content {
        padding: 0 16px;
    }
    
    .nav-links {
        gap: 12px;
    }
    
    .nav-links a:not(.submit-btn) {
        display: none;
    }
    
    .chat-wrapper {
        padding: 16px;
    }
    
    .hero h2 {
        font-size: 1.5rem;
    }
    
    .journals {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* Markdown in messages */
.message-content p {
    margin: 8px 0;
}

.message-content p:first-child {
    margin-top: 0;
}

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

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content code {
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
}

.message.user .message-content code {
    background: rgba(255,255,255,0.2);
}
