/* ABEAI - Abraham Lincoln AI Chat Interface
   A 19th century aesthetic with modern usability */

:root {
    /* Antique paper and ink palette */
    --parchment: #f4efe4;
    --parchment-dark: #e8e0d0;
    --sepia: #8b7355;
    --ink: #2c2416;
    --ink-light: #4a3f2f;
    --gold: #b8960c;
    --gold-muted: #9a7b3c;
    --burgundy: #722f37;
    --cream: #faf8f3;
    
    /* Functional colors */
    --user-bg: #dcd4c4;
    --lincoln-bg: #f9f7f2;
    --border: #c4b8a4;
    --shadow: rgba(44, 36, 22, 0.15);
    
    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Times New Roman', serif;
    
    /* Spacing */
    --sidebar-width: 280px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--parchment);
    color: var(--ink);
    line-height: 1.6;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 29px,
            rgba(139, 115, 85, 0.03) 29px,
            rgba(139, 115, 85, 0.03) 30px
        ),
        var(--parchment);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #3d3226 0%, #2c2416 100%);
    color: var(--cream);
    display: flex;
    flex-direction: column;
    border-right: 3px solid var(--gold-muted);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(184, 150, 12, 0.3);
    text-align: center;
}

.logo {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--gold);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.tagline {
    font-style: italic;
    font-size: 0.85rem;
    color: rgba(250, 248, 243, 0.7);
    margin-top: 4px;
}

.new-chat-btn {
    margin: 16px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--burgundy) 0%, #5a252c 100%);
    border: 1px solid rgba(184, 150, 12, 0.4);
    border-radius: 4px;
    color: var(--cream);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.new-chat-btn:hover {
    background: linear-gradient(180deg, #8a3a44 0%, var(--burgundy) 100%);
    border-color: var(--gold);
}

.new-chat-btn .icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.session-item {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: rgba(250, 248, 243, 0.85);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item:hover {
    background: rgba(250, 248, 243, 0.1);
}

.session-item.active {
    background: rgba(184, 150, 12, 0.15);
    border-left-color: var(--gold);
    color: var(--cream);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(184, 150, 12, 0.3);
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.username {
    color: rgba(250, 248, 243, 0.7);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--gold-muted);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
}

.logout-btn:hover {
    color: var(--gold);
    text-decoration: underline;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--cream);
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 32px;
    background: linear-gradient(180deg, var(--parchment) 0%, var(--cream) 100%);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

.lincoln-portrait {
    flex-shrink: 0;
}

.portrait-frame {
    width: 64px;
    height: 64px;
    border: 3px solid var(--gold-muted);
    border-radius: 4px;
    background: var(--parchment-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        inset 0 0 10px rgba(0,0,0,0.1),
        0 2px 4px var(--shadow);
}

.portrait-placeholder {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--sepia);
}

.header-text h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink);
}

.header-text p {
    font-size: 0.9rem;
    color: var(--sepia);
    font-style: italic;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Welcome Message */
.welcome-message {
    max-width: 600px;
    margin: auto;
    text-align: center;
    padding: 40px;
}

.welcome-content {
    background: 
        linear-gradient(135deg, transparent 10px, var(--parchment) 10px),
        linear-gradient(225deg, transparent 10px, var(--parchment) 10px),
        linear-gradient(315deg, transparent 10px, var(--parchment) 10px),
        linear-gradient(45deg, transparent 10px, var(--parchment) 10px);
    padding: 32px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 32px;
}

.welcome-content blockquote {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--ink-light);
    line-height: 1.7;
}

.signature {
    margin-top: 16px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--sepia);
}

.suggested-questions p {
    font-size: 0.9rem;
    color: var(--sepia);
    margin-bottom: 12px;
}

.suggestion {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 12px 16px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.suggestion:hover {
    background: var(--parchment);
    border-color: var(--gold-muted);
    color: var(--ink);
}

/* Chat Messages */
.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
}

.message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: var(--parchment-dark);
    border: 2px solid var(--gold-muted);
    color: var(--sepia);
}

.message.user .message-avatar {
    background: var(--burgundy);
    color: var(--cream);
}

.message-content {
    padding: 16px 20px;
    border-radius: 8px;
    max-width: calc(100% - 60px);
}

.message.assistant .message-content {
    background: var(--lincoln-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold-muted);
}

.message.user .message-content {
    background: var(--user-bg);
    border: 1px solid rgba(139, 115, 85, 0.3);
}

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

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

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

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

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    padding: 20px 32px;
    background: var(--parchment);
    border-top: 2px solid var(--border);
}

.message-form {
    display: flex;
    gap: 12px;
    background: var(--cream);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: inset 0 1px 3px var(--shadow);
}

.message-form:focus-within {
    border-color: var(--gold-muted);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    resize: none;
    line-height: 1.5;
    max-height: 150px;
}

#messageInput:focus {
    outline: none;
}

#messageInput::placeholder {
    color: var(--sepia);
    font-style: italic;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(180deg, var(--burgundy) 0%, #5a252c 100%);
    border: 1px solid var(--gold-muted);
    border-radius: 6px;
    color: var(--cream);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #8a3a44 0%, var(--burgundy) 100%);
}

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

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

/* Auth Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 36, 22, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.modal {
    background: var(--cream);
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    border: 3px solid var(--gold-muted);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal h2 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    text-align: center;
    margin-bottom: 24px;
    color: var(--ink);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--ink-light);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 1rem;
    background: var(--parchment);
    color: var(--ink);
}

.form-group input:focus {
    outline: none;
    border-color: var(--gold-muted);
}

.auth-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(180deg, var(--burgundy) 0%, #5a252c 100%);
    border: 1px solid var(--gold-muted);
    border-radius: 4px;
    color: var(--cream);
    font-family: var(--font-body);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-submit-btn:hover {
    background: linear-gradient(180deg, #8a3a44 0%, var(--burgundy) 100%);
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--sepia);
}

.auth-switch button {
    background: none;
    border: none;
    color: var(--burgundy);
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
}

.auth-switch button:hover {
    color: var(--gold-muted);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--parchment-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--sepia);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ink-light);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 3px solid var(--gold-muted);
    }
    
    .sessions-list {
        display: none;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .messages-container {
        padding: 16px;
    }
    
    .input-area {
        padding: 16px;
    }
}
