/* ============================================
   FIBRE UI - PRODUCTION STYLES
   ============================================ */

/* Fonts */
@font-face {
    font-family: 'Teodor';
    src: url('/fonts/TeodorTRIAL-Regular.woff2') format('woff2'),
         url('/fonts/TeodorTRIAL-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* CSS Variables */
:root {
    /* Dark mode (default) */
    --bg-gradient-start: #0a0a0a;
    --bg-gradient-end: #0f0f14;
    --text-primary: #f5f3f0;
    --text-secondary: #aaa;
    --text-muted: #666;
    --bg-primary: #141414;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #0a0a0a;
    --border-primary: #2a2a2a;
    --border-secondary: #1a1a1a;
    --accent-primary: #4a919e;
    --accent-hover: #5aa1ae;
    --accent-light: rgba(74, 145, 158, 0.1);
    --user-message-bg: #1a2430;
    --assistant-message-bg: #1a1a1a;
    --error-bg: #2a1a1a;
    --error-color: #e74c3c;
    --success-color: #27ae60;
}

body.light-mode {
    /* Light mode */
    --bg-gradient-start: #faf8f5;
    --bg-gradient-end: #f5f3f0;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #888;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f3f0;
    --bg-tertiary: #faf8f5;
    --border-primary: #e0e0e0;
    --border-secondary: #ececec;
    --accent-primary: #4a919e;
    --accent-hover: #5aa1ae;
    --accent-light: rgba(74, 145, 158, 0.08);
    --user-message-bg: #e8f4f6;
    --assistant-message-bg: #f5f3f0;
    --error-bg: #fef2f2;
    --error-color: #e74c3c;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================
   AUTH MODAL
   ============================================ */

.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.auth-content {
    background: var(--bg-primary);
    padding: 48px;
    border-radius: 16px;
    max-width: 420px;
    width: 90%;
    border: 1px solid var(--border-primary);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-content h2 {
    font-family: 'Teodor', serif;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: center;
    font-size: 32px;
    font-weight: 400;
}

.auth-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-input {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.auth-button {
    padding: 12px 24px;
    background: var(--accent-primary);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.auth-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.auth-button:active {
    transform: translateY(0);
}

.auth-toggle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 8px;
}

.auth-toggle a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.auth-error {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 13px;
    text-align: center;
}

.auth-success {
    padding: 12px 16px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    color: #22c55e;
    font-size: 13px;
    text-align: center;
}

/* ============================================
   LAYOUT
   ============================================ */

.container {
    display: grid;
    grid-template-rows: 48px 60px 1fr 72px;
    height: 100vh;
}

/* Top Bar */
.top-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: all 0.3s ease;
}

.top-left, .top-center, .top-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    font-family: 'Teodor', serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.status-dot.connected {
    background: var(--success-color);
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.memory-stats {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

/* Persona Bar */
.persona-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

.persona-bar::-webkit-scrollbar {
    display: none;
}

.persona-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    min-width: 85px;
    border-radius: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
}

.persona-pill:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.persona-pill.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Persona-specific branding colors */
.persona-pill[data-persona="default"].active {
    background: #4a919e;
    border-color: #4a919e;
}

.persona-pill[data-persona="aris"].active {
    background: #6b46c1;
    border-color: #6b46c1;
}

.persona-pill[data-persona="basil"].active {
    background: #6b8e23;
    border-color: #6b8e23;
}

.persona-pill[data-persona="nova"].active {
    background: #e07856;
    border-color: #e07856;
}

.persona-icon {
    font-size: 16px;
}

.persona-name {
    font-size: 13px;
}

/* Display Area */
.display-area {
    position: relative;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: var(--bg-tertiary);
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 20px;
    text-align: center;
}

.welcome-title {
    font-family: 'Teodor', serif;
    font-size: 64px;
    font-weight: 400;
    margin-bottom: 16px;
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-hover) 50%, var(--accent-primary) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.welcome-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 48px;
    max-width: 500px;
}

.starter-prompts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

.starter-prompt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.starter-prompt:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.prompt-icon {
    font-size: 24px;
}

.prompt-text {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Chat Messages */
.chat-messages {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    display: none; /* Hidden until first message */
}

.chat-messages.active {
    display: block;
}

.message {
    margin-bottom: 24px;
    animation: slideIn 0.3s ease;
}

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

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

.message-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.message-content {
    background: var(--assistant-message-bg);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 16px 20px;
    max-width: 100%;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--user-message-bg);
    border-color: var(--accent-primary);
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Drag Overlay */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--accent-light);
    border: 3px dashed var(--accent-primary);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.drag-overlay.active {
    display: flex;
}

.drag-content {
    text-align: center;
}

.drag-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.drag-text {
    font-size: 18px;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Input Bar */
.input-bar {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-primary);
    padding: 16px 20px;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

#messageInput {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    resize: none;
    min-height: 40px;
    max-height: 120px;
    transition: all 0.3s ease;
}

#messageInput:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

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

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

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

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

.send-icon {
    font-size: 20px;
    color: white;
}

/* Settings Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--error-bg);
    border-color: var(--error-color);
    color: var(--error-color);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.setting-item {
    margin-bottom: 16px;
}

.setting-item label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.setting-value {
    font-size: 14px;
    color: var(--text-primary);
    font-family: monospace;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
}

.settings-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-primary);
}

.theme-options {
    display: flex;
    gap: 8px;
}

.theme-option {
    flex: 1;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.theme-option:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.theme-option.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-secondary, .btn-danger {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-right: 8px;
}

.btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.btn-danger {
    background: var(--error-bg);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.btn-danger:hover {
    background: var(--error-color);
    color: white;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .container {
        grid-template-rows: 48px 56px 1fr 72px;
    }

    .brand {
        font-size: 16px;
    }

    .status-text {
        display: none;
    }

    .persona-name {
        display: none;
    }

    .persona-pill {
        padding: 8px 12px;
    }

    .welcome-title {
        font-size: 48px;
    }

    .welcome-subtitle {
        font-size: 14px;
    }

    .chat-messages {
        padding: 24px 16px;
    }

    .message-content {
        padding: 12px 16px;
    }
}