/* =============================================================================
   BERSEAK AI — Design System v3.0
   =============================================================================
   Inspirado em: Cursor, ChatGPT Desktop, Claude, Linear
   Paleta: Preto e cinza, minimalista premium
   Espaçamento: base 8px (8-16-24-32-40-48)
   ============================================================================= */

/* =============================================================================
   DESIGN TOKENS
   ============================================================================= */
:root {
    /* ===== Backgrounds ===== */
    --bg-primary: #090909;
    --bg-secondary: #111111;
    --bg-tertiary: #181818;
    --bg-elevated: #1E1E1E;
    --bg-hover: #252525;
    --bg-inset: #050505;

    /* ===== Accent ===== */
    --accent: #D4D4D8;
    --accent-hover: #F4F4F5;
    --accent-light: rgba(255,255,255,.05);
    --accent-subtle: rgba(255,255,255,.025);

    /* ===== Status ===== */
    --success: #22C55E;
    --success-bg: rgba(34,197,94,.08);

    --warning: #EAB308;
    --warning-bg: rgba(234,179,8,.08);

    --danger: #EF4444;
    --danger-bg: rgba(239,68,68,.08);

    /* ===== Text ===== */
    --text-primary: #FAFAFA;
    --text-secondary: #B3B3B3;
    --text-muted: #7A7A7A;
    --text-inverse: #090909;

    /* ===== Borders ===== */
    --border-color: #2A2A2A;
    --border-light: #323232;
    --border-accent: #4F46E5;

    /* ===== Typography ===== */
    --font-family: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 15px;
    --font-size-lg: 16px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 32px;

    --line-height: 1.6;
    --line-height-sm: 1.45;

    /* ===== Spacing ===== */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 14px;
    --space-4: 20px;
    --space-5: 28px;
    --space-6: 36px;
    --space-7: 44px;
    --space-8: 52px;
    --space-9: 64px;
    --space-10: 76px;

    /* ===== Radius ===== */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 999px;

    /* ===== Shadows ===== */
    --shadow-xs: none;
    --shadow-sm: 0 2px 8px rgba(0,0,0,.18);
    --shadow-md: 0 6px 18px rgba(0,0,0,.25);

    /* ===== Layout ===== */
    --sidebar-width: 280px;
    --sidebar-collapsed: 0px;
    --message-max-width: 880px;
    --topbar-height: 0px;

    /* ===== Animation ===== */
    --transition-fast: 120ms ease;
    --transition-base: 180ms ease;
    --transition-slow: 260ms ease;

    /* ===== Layers ===== */
    --z-sidebar: 100;
    --z-overlay: 200;
    --z-modal: 300;
    --z-tooltip: 400;
    --z-toast: 500;
}
/* =============================================================================
   NORMALIZE / RESET
   ============================================================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    /* Safari scrollbar fix */
    -webkit-overflow-scrolling: touch;
}

/* Safari & Webkit scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Remove default list styles */
ul, ol {
    list-style: none;
}

/* Links */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Buttons base */
button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Input base */
input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* Remove spinners from number inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Safari: remove default appearance */
input, textarea, select, button {
    -webkit-appearance: none;
    appearance: none;
}

/* Pre & code */
pre, code {
    font-family: var(--font-mono);
    font-size: 14px;
}
pre {
    white-space: pre;
    overflow-x: auto;
}

/* Selection */
::selection {
    background: var(--accent);
    color: white;
}
::-moz-selection {
    background: var(--accent);
    color: white;
}

/* SVG defaults */
svg {
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* =============================================================================
   LAYOUT — App Shell
   ============================================================================= */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-primary);
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    min-height: 56px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-xl);
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: #8A98A8;
}
.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.sidebar-toggle {
    display: none;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}
.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-section-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: var(--space-3) var(--space-3) var(--space-1);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}
.sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.sidebar-item.active {
    background: var(--accent-light);
    color: var(--accent);
}
.sidebar-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* New Chat Button */
.btn-new-chat {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: calc(100% - var(--space-4));
    margin: var(--space-3) var(--space-3) var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    transition: all var(--transition-base);
}
.btn-new-chat:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-new-chat:active {
    transform: scale(0.98);
}
.btn-new-chat svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}
.btn-new-chat svg {
    width: 18px;
    height: 18px;
}

/* Conversation List */
.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-1) var(--space-2);
}

.sidebar-conversation {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
}
.sidebar-conversation:hover {
    background: var(--bg-hover);
}
.sidebar-conversation.active {
    background: var(--accent-light);
}
.sidebar-conversation.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    animation: fadeSlideIn 200ms ease both;
}

.sidebar-conversation-title {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.active .sidebar-conversation-title {
    color: var(--text-primary);
}

.sidebar-conversation-delete {
    opacity: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.sidebar-conversation:hover .sidebar-conversation-delete {
    opacity: 1;
}
.sidebar-conversation-delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-md);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}
.sidebar-user-name {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-user-plan {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.sidebar-tokens {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.token-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-1);
}
.token-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

.token-text {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Sidebar Logout & Links */
.sidebar-logout,
.sidebar-docs-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}
.sidebar-logout:hover,
.sidebar-docs-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.sidebar-logout svg,
.sidebar-docs-btn svg {
    width: 18px;
    height: 18px;
}

/* =============================================================================
   SIDEBAR - API SECTION
   ============================================================================= */
.sidebar-api {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.sidebar-api-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}
.sidebar-api-header:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.sidebar-api-header svg:first-child {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.sidebar-api-header span {
    flex: 1;
}

.sidebar-api-chevron {
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}
.sidebar-api.expanded .sidebar-api-chevron {
    transform: rotate(180deg);
}

.sidebar-api-body {
    display: none;
    padding: var(--space-2) var(--space-3) var(--space-3);
    border-top: 1px solid var(--border-color);
    gap: var(--space-2);
}
.sidebar-api.expanded .sidebar-api-body {
    display: flex;
    flex-direction: column;
}

/* API Key Display */
.sidebar-api-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.api-key-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-key-value {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-height: 38px;
}

.api-key-text {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-overlay);
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    background: var(--bg-primary);
    position: relative;
}

.top-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    min-height: 56px;
}
.top-bar-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: #8A98A8;
}

/* =============================================================================
   MESSAGES AREA
   ============================================================================= */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}

.messages-list {
    max-width: var(--message-max-width);
    width: 100%;
    margin: 0 auto;
    padding: var(--space-4) 0;
    flex: 1;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: var(--space-8) var(--space-4);
}

.welcome-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-5);
}
.welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    margin-bottom: var(--space-2);
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #8A98A8, #AAB6C4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.welcome-brand {
    font-size: var(--font-size-sm);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: #6D7C8D;
    margin-bottom: var(--space-7);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: center;
    max-width: 600px;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.suggestion-chip:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}
.suggestion-chip svg {
    width: 16px;
    height: 16px;
}

/* =============================================================================
   MESSAGES
   ============================================================================= */
.message-wrapper {
    display: flex;
    margin-bottom: var(--space-6);
    animation: fadeSlideIn var(--transition-base) ease both;
}
.message-wrapper.user {
    justify-content: flex-end;
}
.message-wrapper.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    min-width: 0;
}
.user .message-content {
    background: #1E2A45;
    color: var(--text-primary);
    border-radius: var(--radius-lg) var(--radius-lg) var(--space-1) var(--radius-lg);
    padding: var(--space-3) var(--space-4);
}
.assistant .message-content {
    background: transparent;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--space-1);
}

.message-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}
.assistant .message-header {
    margin-bottom: var(--space-2);
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.message-avatar.user {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}
.message-avatar.assistant {
    background: var(--accent);
    color: white;
}

.message-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
}
.user .message-name {
    color: rgba(255, 255, 255, 0.9);
}
.assistant .message-name {
    color: var(--text-primary);
}

/* Message Text */
.message-text {
    font-size: var(--font-size-base);
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.user .message-text {
    color: var(--text-primary);
}
.assistant .message-text {
    color: var(--text-primary);
}

.message-text p {
    margin-bottom: var(--space-3);
}
.message-text p:last-child {
    margin-bottom: 0;
}

.message-text strong {
    font-weight: 600;
}
.message-text em {
    font-style: italic;
}

/* Inline code */
.message-text code {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
}
.user .message-text code {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Headers */
.message-text h1 { font-size: var(--font-size-2xl); font-weight: 700; margin: var(--space-6) 0 var(--space-3); }
.message-text h2 { font-size: var(--font-size-xl); font-weight: 700; margin: var(--space-6) 0 var(--space-3); }
.message-text h3 { font-size: var(--font-size-lg); font-weight: 600; margin: var(--space-5) 0 var(--space-2); }
.message-text h4 { font-size: var(--font-size-base); font-weight: 600; margin: var(--space-4) 0 var(--space-2); }

/* Blockquotes */
.message-text blockquote {
    border-left: 3px solid var(--accent);
    padding: var(--space-2) var(--space-4);
    margin: var(--space-3) 0;
    color: var(--text-secondary);
    background: var(--bg-inset);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Lists */
.message-text ul,
.message-text ol {
    margin: var(--space-3) 0;
    padding-left: var(--space-6);
}
.message-text ul { list-style: disc; }
.message-text ol { list-style: decimal; }
.message-text li {
    margin-bottom: var(--space-1);
}

/* Tables */
.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--space-5) 0;
    font-size: var(--font-size-sm);
}
.message-text th,
.message-text td {
    border: 1px solid var(--border-color);
    padding: var(--space-2) var(--space-3);
    text-align: left;
}
.message-text th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}
.message-text td {
    color: var(--text-secondary);
}
.message-text tr:nth-child(even) td {
    background: var(--bg-inset);
}

/* Horizontal Rule */
.message-text hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: var(--space-6) 0;
}

/* Deleted text */
.message-text del {
    color: var(--text-muted);
    text-decoration: line-through;
}

/* Links */
.message-text a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.message-text a:hover {
    color: var(--accent-hover);
}

/* Message tokens */
.message-tokens {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.message-actions {
    display: flex;
    gap: var(--space-1);
    margin-top: var(--space-2);
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.message-wrapper:hover .message-actions {
    opacity: 1;
}
.user .message-actions {
    justify-content: flex-end;
}

.message-actions button {
    padding: var(--space-1);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    transition: all var(--transition-fast);
}
.message-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.message-actions button.copied {
    color: var(--success);
}

/* =============================================================================
   FILE ATTACHMENT (user uploads)
   ============================================================================= */
.file-attachment {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
}
.user .file-attachment {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}
.file-attachment svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.file-attachment .file-download-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
.file-attachment .file-download-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* =============================================================================
   CODE BLOCKS (in-message code)
   ============================================================================= */
.code-block-wrapper {
    margin: var(--space-4) 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-xs);
}

.code-lang-label {
    font-size: var(--font-size-xs);
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.code-block-wrapper pre {
    margin: 0;
    padding: var(--space-4);
    background: var(--bg-secondary);
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.7;
    max-height: 70vh;
    min-height: 48px;
    counter-reset: line;
}

.code-block-wrapper pre code {
    display: block;
    background: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
    tab-size: 2;
}

/* Line numbers for code blocks */
.code-block-wrapper pre code .line-number {
    display: inline-block;
    width: 32px;
    padding-right: var(--space-4);
    color: var(--text-muted);
    text-align: right;
    user-select: none;
    opacity: 0.5;
}

/* Copy button for code blocks */
.copy-code-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-xs);
    font-family: inherit;
    transition: all var(--transition-fast);
}
.copy-code-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}
.copy-code-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

/* =============================================================================
   FILE ARTIFACT (AI-generated files - Card style)
   ============================================================================= */
.file-artifact {
    margin: var(--space-5) 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}
.file-artifact:hover {
    box-shadow: var(--shadow-md);
}

.file-artifact-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.file-artifact-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.file-artifact-info {
    flex: 1;
    min-width: 0;
}
.file-artifact-name {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-artifact-meta {
    display: flex;
    gap: var(--space-2);
    margin-top: 2px;
}
.file-artifact-lang,
.file-artifact-size,
.file-artifact-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}
.file-artifact-lang {
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 600;
}

.file-artifact-actions {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

.file-artifact-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-xs);
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition-fast);
}
.file-artifact-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}
.file-artifact-btn svg {
    width: 14px;
    height: 14px;
}
.file-artifact-btn.open-btn {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.file-artifact-btn.open-btn:hover {
    background: var(--accent-hover);
}

.file-artifact-body {
    padding: 0;
    max-height: 500px;
    overflow: hidden;
    position: relative;
}
.file-artifact-body.expanded {
    max-height: none;
}

.file-artifact-body pre {
    margin: 0;
    padding: var(--space-4);
    background: var(--bg-inset);
    border: none;
    border-radius: 0;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    max-height: 400px;
}
.file-artifact-body.expanded pre {
    max-height: none;
}

.file-artifact-body pre code {
    display: block;
    background: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
    tab-size: 2;
}

.file-artifact-expand {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4);
    text-align: center;
    background: linear-gradient(transparent, var(--bg-secondary));
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--accent);
    font-weight: 500;
    transition: color var(--transition-fast);
}
.file-artifact-expand:hover {
    color: var(--accent-hover);
}

/* =============================================================================
   TOOL CARDS
   ============================================================================= */
.tool-card {
    margin: var(--space-5) 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.tool-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.tool-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.tool-card-icon.code { background: rgba(79, 124, 255, 0.15); color: var(--accent); }
.tool-card-icon.file { background: rgba(48, 209, 88, 0.15); color: var(--success); }
.tool-card-icon.image { background: rgba(255, 176, 32, 0.15); color: var(--warning); }
.tool-card-icon.search { background: rgba(255, 90, 95, 0.15); color: var(--danger); }

.tool-card-info {
    flex: 1;
}
.tool-card-title {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.tool-card-status {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--success);
    margin-top: 2px;
}

.tool-card-body {
    padding: var(--space-4);
}

.tool-card-file {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
}

.tool-card-file-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.tool-card-file-info {
    flex: 1;
}
.tool-card-file-name {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}
.tool-card-file-meta {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.tool-card-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.tool-card-actions .file-artifact-btn {
    font-size: var(--font-size-xs);
}

/* =============================================================================
   PDF / EXCEL CARDS
   ============================================================================= */
.doc-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    margin: var(--space-3) 0;
    transition: all var(--transition-fast);
}
.doc-card:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.doc-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.doc-card-icon.pdf { background: rgba(255, 90, 95, 0.15); color: var(--danger); }
.doc-card-icon.excel { background: rgba(48, 209, 88, 0.15); color: var(--success); }
.doc-card-icon.image { background: rgba(79, 124, 255, 0.15); color: var(--accent); }

.doc-card-info {
    flex: 1;
}
.doc-card-name {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.doc-card-detail {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.doc-card-actions {
    display: flex;
    gap: var(--space-1);
}

/* =============================================================================
   LOADING INDICATOR
   ============================================================================= */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    max-width: var(--message-max-width);
    margin: 0 auto;
    width: 100%;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* =============================================================================
   INPUT AREA
   ============================================================================= */
.input-area {
    border-top: 1px solid var(--border-color);
    padding: var(--space-4);
    background: var(--bg-primary);
}

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

.input-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    min-height: 56px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    outline: none;
    min-height: 28px;
    max-height: 200px;
    resize: none;
    line-height: 1.5;
}
.message-input::placeholder {
    color: var(--text-muted);
}
.message-input:focus {
    box-shadow: none;
    border-color: transparent;
}

.btn-input-action,
.btn-attach,
.btn-send {
    width: 40px;
    height: 40px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    border: none;
    padding: 0;
    min-width: 40px;
    min-height: 40px;
    line-height: 1;
}
.btn-input-action:hover,
.btn-attach:hover,
.btn-send:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.btn-input-action:active,
.btn-attach:active,
.btn-send:active {
    transform: scale(0.92);
}
.btn-input-action svg,
.btn-attach svg,
.btn-send svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

#sendButton,
.btn-send {
    color: var(--accent);
}
#sendButton:hover,
.btn-send:hover {
    background: var(--accent-light);
    color: var(--accent-hover);
}
#sendButton:disabled,
.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) var(--space-2) 0;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* File preview in input */
.file-preview {
    padding: var(--space-2);
    margin-bottom: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.file-preview-item button {
    margin-left: auto;
    color: var(--text-muted);
}
.file-preview-item button:hover {
    color: var(--danger);
}

/* =============================================================================
   AUTH PAGES
   ============================================================================= */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-5);
    background: var(--bg-primary);
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-7);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin: auto;
}

.auth-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    margin-bottom: var(--space-1);
    color: #8A98A8;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.form-group label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    height: 46px;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}
.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-group input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 44px;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
    background: none;
    color: inherit;
}
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.btn-sm {
    height: 32px;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}

.btn-full {
    width: 100%;
}

.btn-api-generate {
    width: 100%;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--accent);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    height: 40px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.btn-api-generate:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* Messages (alerts) */
.messages {
    margin-bottom: var(--space-4);
}

.message {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}
.message + .message {
    margin-top: var(--space-2);
}
.message-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(48, 209, 88, 0.2);
}
.message-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(255, 90, 95, 0.2);
}
.message-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(255, 176, 32, 0.2);
}
.message-info {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid rgba(79, 124, 255, 0.2);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-5);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}
.auth-footer a {
    color: var(--accent);
}
.auth-note {
    margin-top: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* =============================================================================
   API DOCS
   ============================================================================= */
.docs-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-7) var(--space-5) var(--space-8);
    overflow-y: auto;
    height: 100vh;
}

.docs-header {
    text-align: center;
    padding: var(--space-8) 0 var(--space-6);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-7);
}

.docs-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    background: linear-gradient(135deg, #8A98A8, #AAB6C4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.docs-header p {
    color: var(--text-secondary);
    margin-top: var(--space-2);
}

.base-url {
    display: inline-block;
    margin-top: var(--space-3);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.section {
    margin-bottom: var(--space-8);
}
.section-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.section-desc {
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    font-size: var(--font-size-sm);
}

.endpoint-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-3);
    transition: all var(--transition-fast);
}
.endpoint-card:hover {
    border-color: var(--accent);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.endpoint-header:hover {
    background: var(--bg-hover);
}

.method-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}
.method-get { background: rgba(48, 209, 88, 0.15); color: var(--success); }
.method-post { background: rgba(79, 124, 255, 0.15); color: var(--accent); }
.method-delete { background: rgba(255, 90, 95, 0.15); color: var(--danger); }
.method-patch { background: rgba(255, 176, 32, 0.15); color: var(--warning); }

.endpoint-path {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    flex: 1;
}
.endpoint-desc {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}
.expand-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}
.endpoint-card.expanded .expand-icon {
    transform: rotate(180deg);
}

.endpoint-body {
    display: none;
    padding: var(--space-4);
    border-top: 1px solid var(--border-color);
    background: var(--bg-inset);
}
.endpoint-card.expanded .endpoint-body {
    display: block;
}

.endpoint-body h4 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--space-4) 0 var(--space-2);
}
.endpoint-body h4:first-child {
    margin-top: 0;
}

.param-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    margin: var(--space-3) 0;
}
.param-table th,
.param-table td {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    text-align: left;
}
.param-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}
.param-table td {
    color: var(--text-secondary);
}
.param-type {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--accent);
}
.param-req {
    color: var(--danger);
    font-size: var(--font-size-xs);
}
.param-opt {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

.code-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    overflow-x: auto;
    margin: var(--space-3) 0;
    color: var(--text-primary);
}
.code-block .comment { color: var(--text-muted); }
.code-block .string { color: var(--success); }
.code-block .keyword { color: var(--accent); }

.status-codes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}
.status-code {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    font-family: var(--font-mono);
}
.status-2xx { background: rgba(48, 209, 88, 0.1); color: var(--success); }
.status-4xx { background: rgba(255, 176, 32, 0.1); color: var(--warning); }
.status-5xx { background: rgba(255, 90, 95, 0.1); color: var(--danger); }

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.animate-fade-in {
    animation: fadeIn var(--transition-base) ease both;
}
.animate-scale-in {
    animation: scaleIn var(--transition-base) ease both;
}
.animate-slide-in {
    animation: slideInLeft var(--transition-base) ease both;
}
.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Tablet: < 1024px */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
}

/* Mobile: < 768px */
@media (max-width: 768px) {
    :root {
        --message-max-width: 100%;
    }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: var(--z-sidebar);
        width: 280px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.show {
        display: block;
    }
    .sidebar-toggle {
        display: flex;
    }
    .top-bar {
        display: flex;
    }
    .main-content {
        padding-top: 0;
    }
    .message-content {
        max-width: 95%;
    }
    .messages-container {
        padding: var(--space-3);
    }
    .welcome-title {
        font-size: var(--font-size-2xl);
    }
    .welcome-suggestions {
        flex-direction: column;
        align-items: center;
    }
    .input-area {
        padding: var(--space-3);
    }
    .file-artifact-header {
        flex-wrap: wrap;
    }
    .file-artifact-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .doc-card {
        flex-wrap: wrap;
    }
    .doc-card-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .welcome-screen {
        padding: var(--space-6) var(--space-3);
    }
    .message-wrapper {
        margin-bottom: var(--space-5);
    }
}

/* Small mobile: < 480px */
@media (max-width: 480px) {
    .message-content {
        max-width: 100%;
    }
    .auth-card {
        padding: var(--space-5);
    }
    .sidebar {
        width: 100%;
    }
    .file-artifact-btn span {
        display: none;
    }
    .input-area {
        padding: var(--space-2) var(--space-2);
    }
    .input-row {
        min-height: 48px;
        padding: var(--space-1) var(--space-1);
    }
    .messages-container {
        padding: var(--space-2);
    }
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #4A5A7A;
        --text-muted: #7A8A9A;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Skip to content (keyboard) */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: var(--accent);
    color: white;
    border-radius: var(--radius-md);
    z-index: var(--z-toast);
    font-weight: 600;
    transition: top var(--transition-fast);
}
.skip-to-content:focus {
    top: var(--space-3);
}

/* Docs info box */
.docs-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
}

.docs-info code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 6px;
    border-radius: 4px;
}

/* =============================================================================
   MODAL (API Docs, Token Stats)
   ============================================================================= */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    margin: 40px auto;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-lg {
    max-width: 1000px;
}

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

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header-left svg {
    color: var(--accent);
}

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

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

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* =============================================================================
   TOKEN STATS
   ============================================================================= */

.stats-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stats-total-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stats-total-card .stats-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    display: block;
}

.stats-total-card .stats-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table tr:hover td {
    background: var(--bg-hover);
}

.stats-table .num {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
}

.stats-table .total-row td {
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
}

.stats-section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* ARIA friendly */
[aria-hidden="true"] {
    display: none;
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */
@media print {
    .sidebar,
    .input-area,
    .top-bar,
    .file-artifact-actions,
    .message-actions,
    .loading-indicator {
        display: none !important;
    }
    .main-content {
        height: auto;
    }
    .messages-container {
        overflow: visible;
    }
    body {
        background: white;
        color: black;
    }
    .message-content {
        max-width: 100%;
    }
}