/* Linaris Mobile - Design tokens and base */
:root {
    --color-bg: #FFFFFF;
    --color-bg-secondary: #F8F8F8;
    --color-bg-cream: #FDF9F3;
    --color-text: #1A1A1A;
    --color-text-muted: #6B7280;
    --color-primary: #00C853;
    --color-orange: #C45C26;
    --color-orange-glow: #FF6B35;
    --color-dark: #1A1A1A;
    --color-dark-card: #262626;
    --color-border: #E5E7EB;
    --color-error: #DC2626;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.08);
    --header-h: 56px;
    --input-min-h: 44px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 16px; color: var(--color-text); background: var(--color-bg); -webkit-font-smoothing: antialiased; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
[x-cloak] { display: none !important; }

/* Auth page */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--color-bg-secondary); }
.auth-container { width: 100%; max-width: 400px; }
.auth-card { background: var(--color-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 32px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon { display: inline-block; width: 48px; height: 48px; border-radius: 50%; background: var(--color-orange); }
.auth-title { margin: 12px 0 4px; font-size: 1.5rem; font-weight: 700; color: var(--color-text); }
.auth-subtitle { margin: 0; font-size: 0.875rem; color: var(--color-text-muted); }
.auth-form .form-group { margin-bottom: 18px; }
.auth-form label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; color: var(--color-text); }
.auth-form input { width: 100%; height: var(--input-min-h); padding: 0 14px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 1rem; }
.auth-form input:focus { outline: none; border-color: var(--color-orange); }
.auth-form input:focus-visible { outline: 2px solid var(--color-orange); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 20px; border: none; border-radius: var(--radius-sm); font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-dark); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-dark-card); }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.auth-footer { margin-top: 16px; text-align: center; }
.auth-link { color: var(--color-orange); text-decoration: none; font-size: 0.875rem; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); padding: 12px 20px; border-radius: var(--radius); font-size: 0.875rem; background: var(--color-dark); color: #fff; z-index: 1000; opacity: 0; transition: transform 0.25s, opacity 0.25s; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--color-error); }
.toast.success { background: var(--color-primary); }

/* Chat page */
.chat-page { min-height: 100vh; min-height: 100dvh; overflow: hidden; }
.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.chat-header { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); padding: 0 16px; background: var(--color-bg); border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.header-logo { display: flex; align-items: center; text-decoration: none; color: inherit; }
.header-logo-btn { padding: 6px; margin: 0; border: none; background: none; cursor: pointer; color: inherit; }
.header-logo-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--color-orange); }
.header-title { margin: 0; font-size: 1rem; font-weight: 600; flex: 1; text-align: center; }
.header-menu-btn { padding: 8px; background: none; border: none; cursor: pointer; }
.hamburger { display: block; width: 22px; height: 2px; background: var(--color-text); box-shadow: 0 6px 0 var(--color-text), 0 12px 0 var(--color-text); }
.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages-wrap { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; padding: 16px; }
.messages-inner { min-height: 100%; }
.chat-empty { display: flex; align-items: center; justify-content: center; min-height: 120px; color: var(--color-text-muted); font-size: 0.875rem; text-align: center; padding: 24px; }
.message { margin-bottom: 16px; }
.message.user { display: flex; flex-direction: column; align-items: flex-end; }
.message.assistant { display: flex; flex-direction: column; align-items: flex-start; }
.message-bubble { max-width: 85%; padding: 12px 16px; border-radius: var(--radius); font-size: 0.9375rem; line-height: 1.5; }
.message.user .message-bubble { background: var(--color-dark); color: #fff; border-bottom-right-radius: 4px; }
.message.assistant .message-bubble { background: var(--color-bg-secondary); border-bottom-left-radius: 4px; }
.message-content { word-break: break-word; }
.message-content h1, .message-content h2, .message-content h3 { margin: 0.5em 0 0.25em; font-size: 1em; }
.message-content pre { overflow-x: auto; padding: 10px; background: var(--color-dark-card); color: #fff; border-radius: var(--radius-sm); font-size: 0.8125rem; }
.message-content code { padding: 2px 6px; background: var(--color-bg-cream); border-radius: 4px; font-size: 0.875em; }
.message-content table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.message-content th, .message-content td { border: 1px solid var(--color-border); padding: 6px 8px; text-align: left; }
.message-content a { color: var(--color-orange); }
.message-time { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 4px; }
.message-sources { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--color-border); }
.message-sources-label { font-size: 0.75rem; color: var(--color-text-muted); }
.message-sources-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.source-badge { display: inline-block; padding: 4px 8px; background: var(--color-bg-cream); border-radius: var(--radius-sm); font-size: 0.75rem; color: var(--color-orange); }
.typing-indicator { display: flex; gap: 6px; padding: 16px; }
.typing-indicator span { width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-muted); animation: typing 1.4s ease-in-out infinite both; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }
.input-area { flex-shrink: 0; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--color-bg); border-top: 1px solid var(--color-border); }
.input-row { display: flex; align-items: flex-end; gap: 8px; }
.btn-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; background: var(--color-bg-secondary); border: none; border-radius: var(--radius-sm); cursor: pointer; color: var(--color-text-muted); }
.btn-icon:hover { color: var(--color-orange); }
.btn-icon.recording { background: var(--color-orange-glow); color: #fff; }
.input-text { flex: 1; min-height: 40px; max-height: 120px; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 1rem; font-family: inherit; resize: none; }
.input-text:focus { outline: none; border-color: var(--color-orange); }
.input-text:focus-visible { outline: 2px solid var(--color-orange); outline-offset: 2px; }
button:focus-visible, .btn:focus-visible, .btn-icon:focus-visible { outline: 2px solid var(--color-orange); outline-offset: 2px; }
.btn-send { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; background: var(--color-primary); border: none; border-radius: var(--radius-sm); cursor: pointer; color: #fff; }
.btn-send:hover:not(:disabled) { filter: brightness(1.1); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-attach { }
.image-preview { position: relative; margin-top: 8px; }
.image-preview-img { max-width: 120px; max-height: 80px; border-radius: var(--radius-sm); object-fit: cover; }
.image-preview-remove { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border: none; border-radius: 50%; background: var(--color-dark); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 280px; max-width: 85vw; background: var(--color-bg); box-shadow: -4px 0 24px rgba(0,0,0,0.12); z-index: 101; transform: translateX(100%); transition: transform 0.25s ease; overflow: hidden; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) {
    .drawer { transition: none; }
    .toast { transition: none; }
}
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--color-border); }
.drawer-title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.drawer-close { width: 36px; height: 36px; border: none; background: none; font-size: 1.5rem; cursor: pointer; color: var(--color-text-muted); }
.drawer-actions { padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.drawer-list { flex: 1; overflow-y: auto; padding: 12px 0; }
.drawer-item { border-bottom: 1px solid var(--color-border); }
.drawer-item-btn { width: 100%; padding: 12px 16px; text-align: left; border: none; background: none; cursor: pointer; font-size: 0.9375rem; display: flex; align-items: center; justify-content: space-between; }
.drawer-item-btn:hover { background: var(--color-bg-secondary); }
.drawer-item.active .drawer-item-btn { font-weight: 600; color: var(--color-orange); }
.drawer-item-badge { font-size: 0.75rem; color: var(--color-primary); }
.drawer-sublist { padding-left: 16px; padding-bottom: 8px; }
.drawer-subitem-row { display: flex; align-items: center; }
.drawer-subitem { flex: 1; display: block; width: 100%; padding: 8px 16px; text-align: left; border: none; background: none; cursor: pointer; font-size: 0.8125rem; color: var(--color-text-muted); }
.drawer-subitem:hover { background: var(--color-bg-secondary); color: var(--color-text); }
.drawer-subitem-delete { flex-shrink: 0; padding: 8px; border: none; background: none; cursor: pointer; color: var(--color-text-muted); }
.drawer-subitem-delete:hover { color: var(--color-error); }
.drawer-footer { padding: 16px; border-top: 1px solid var(--color-border); }

@media (prefers-reduced-motion: reduce) {
    .drawer { transition: none; }
    .toast { transition: none; }
}
