/**
 * AMFAS Assistant - Modern Chat Interface
 * Clean, minimal design inspired by Claude and ChatGPT
 */

/* =============================================================================
   Variables
   ============================================================================= */

:root {
    --primary: #4A90A4;
    --primary-hover: #3d7a8c;

    --bg-main: #ffffff;
    --bg-sidebar: #f9fafb;
    --bg-message-user: #f3f4f6;
    --bg-message-assistant: #ffffff;
    --bg-input: #ffffff;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border: #e5e7eb;
    --border-input: #d1d5db;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --sidebar-width: 260px;
    --header-height: 56px;
    --max-message-width: 768px;

    --transition: 150ms ease;
}

/* =============================================================================
   Reset
   ============================================================================= */

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-main);
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

textarea {
    font-family: inherit;
    font-size: inherit;
}

/* =============================================================================
   Layout
   ============================================================================= */

.app {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 12px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition);
}

.new-chat-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.sidebar-content {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.sidebar-hint {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.brand-name {
    font-weight: 500;
    font-size: 14px;
}

/* Main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    margin-right: 8px;
}

.menu-btn:hover {
    background: var(--bg-sidebar);
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.beta-badge {
    font-size: 10px;
    font-weight: 600;
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.header-spacer {
    flex: 1;
}

/* =============================================================================
   Chat Area
   ============================================================================= */

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}

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

.welcome-logo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    object-fit: contain;
    margin-bottom: 24px;
}

.welcome h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    max-width: 400px;
}

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

.welcome-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 32px;
    max-width: 450px;
}

.topic-tag {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

.suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.suggestion {
    padding: 12px 16px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    text-align: left;
    transition: all var(--transition);
}

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

.welcome.hidden {
    display: none;
}

/* Messages */
.messages {
    max-width: var(--max-message-width);
    margin: 0 auto;
    width: 100%;
}

.message {
    padding: 16px 0;
    animation: fadeIn 200ms ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--bg-message-user);
    color: var(--text-primary);
}

.message.assistant .message-avatar {
    background: var(--primary);
    color: white;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
}

.message-content {
    padding-left: 40px;
}

.message-content p {
    margin-bottom: 12px;
}

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

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

/* Sources toggle */
.sources-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.sources-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.sources-list {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    font-size: 13px;
}

.sources-list.hidden {
    display: none;
}

.source-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.source-item:first-child {
    padding-top: 0;
}

.source-title {
    font-weight: 500;
    color: var(--text-primary);
}

.source-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.source-video-link {
    display: inline-block;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    margin-top: 4px;
}

.source-video-link:hover {
    text-decoration: underline;
}

/* Streaming cursor */
.streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--primary);
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* =============================================================================
   Input Area
   ============================================================================= */

.input-area {
    padding: 16px;
    background: var(--bg-main);
    border-top: 1px solid var(--border);
}

.input-form {
    max-width: var(--max-message-width);
    margin: 0 auto;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 8px 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 164, 0.1);
}

.input {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 200px;
    line-height: 24px;
    padding: 0;
    color: var(--text-primary);
}

.input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.send-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

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

.footer-contact {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.footer-contact a {
    color: var(--primary);
    text-decoration: none;
}

.footer-contact a:hover {
    text-decoration: underline;
}

/* Feedback buttons */
.message-feedback {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-left: 40px;
}

.feedback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}

.feedback-btn:hover {
    background: var(--bg-sidebar);
    color: var(--text-secondary);
}

.feedback-btn.selected {
    color: var(--primary);
    background: rgba(74, 144, 164, 0.1);
}

.feedback-btn.selected.negative {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition);
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        visibility: visible;
    }

    .menu-btn {
        display: flex;
    }

    .header-title {
        font-size: 15px;
    }

    .welcome-logo {
        width: 64px;
        height: 64px;
    }

    .welcome h2 {
        font-size: 20px;
    }

    .message-content {
        padding-left: 0;
        margin-top: 8px;
    }

    .input-area {
        padding: 12px;
    }
}

/* =============================================================================
   Dark Mode (optional - can be enabled)
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    :root {
        /* Uncomment to enable dark mode
        --bg-main: #111827;
        --bg-sidebar: #1f2937;
        --bg-message-user: #374151;
        --bg-message-assistant: #111827;
        --bg-input: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --text-muted: #6b7280;
        --border: #374151;
        --border-input: #4b5563;
        */
    }
}

/* =============================================================================
   Utilities
   ============================================================================= */

.hidden {
    display: none !important;
}
