/* ===================================
 * innoECM v11 Enterprise Design
 * itTiumBot Global Stylesheet
 * Design Token System Applied
 * =================================== */

/* ─── Design Tokens ─── */
:root {
    /* Color Palette — tinted neutrals with brand hue (220°) */
    --color-brand: #2563eb;
    --color-brand-hover: #1d4ed8;
    --color-brand-light: #eff6ff;
    --color-brand-muted: #bfdbfe;
    --color-brand-subtle: #dbeafe;

    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-danger-light: #fef2f2;
    --color-danger-muted: #fecaca;

    --color-success: #16a34a;
    --color-success-hover: #15803d;
    --color-success-light: #f0fdf4;
    --color-success-muted: #bbf7d0;

    --color-warning-light: #fffbeb;
    --color-warning-muted: #fde68a;
    --color-warning-text: #78350f;

    /* Tinted Neutrals — slight blue undertone (brand hue 220°) */
    --neutral-950: #0c1220;
    --neutral-900: #131b2e;
    --neutral-800: #1e293b;
    --neutral-700: #2d3a4e;
    --neutral-600: #475569;
    --neutral-500: #64748b;
    --neutral-400: #94a3b8;
    --neutral-300: #cbd5e1;
    --neutral-200: #e2e8f0;
    --neutral-100: #f1f5f9;
    --neutral-50: #f8fafc;
    --neutral-0: #ffffff;

    /* Surfaces */
    --surface-app: var(--neutral-50);
    --surface-card: var(--neutral-0);
    --surface-raised: var(--neutral-0);
    --surface-header: var(--neutral-900);
    --surface-code: var(--neutral-800);

    /* Borders */
    --border-default: var(--neutral-200);
    --border-subtle: var(--neutral-100);
    --border-strong: var(--neutral-300);

    /* Text */
    --text-primary: var(--neutral-800);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-500);
    --text-muted: var(--neutral-400);
    --text-inverse: var(--neutral-0);
    --text-brand: var(--color-brand);

    /* Spacing — 4pt base system */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Typography Scale — 1.2 minor third */
    --text-2xs: 10px;
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 13px;
    --text-md: 14px;
    --text-lg: 15px;
    --text-xl: 18px;
    --text-2xl: 22px;

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --leading-tight: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;

    --font-sans: 'Segoe UI', 'Malgun Gothic', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Consolas', 'Courier New', monospace;

    /* Shadows — elevation system */
    --shadow-xs: 0 1px 2px rgba(12, 18, 32, 0.05);
    --shadow-sm: 0 1px 3px rgba(12, 18, 32, 0.08), 0 1px 2px rgba(12, 18, 32, 0.04);
    --shadow-md: 0 4px 12px rgba(12, 18, 32, 0.08), 0 2px 4px rgba(12, 18, 32, 0.04);
    --shadow-lg: 0 8px 24px rgba(12, 18, 32, 0.12), 0 4px 8px rgba(12, 18, 32, 0.04);
    --shadow-xl: 0 12px 40px rgba(12, 18, 32, 0.16), 0 8px 16px rgba(12, 18, 32, 0.06);

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 10px;
    --radius-full: 9999px;

    /* Transitions — exponential easing */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

    --duration-fast: 120ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;

    /* Focus ring */
    --focus-ring: 0 0 0 2px var(--neutral-0), 0 0 0 4px var(--color-brand);
    --focus-ring-inset: inset 0 0 0 2px var(--color-brand);
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    background: var(--surface-app);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Focus Management ─── */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ─── Page Transition ─── */
.page { display: none; height: 100vh; }
.page.active { display: flex; flex-direction: column; }

/* ===================================
 * Login Page
 * =================================== */
.login-container {
    margin: auto;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 380px;
    text-align: center;
    overflow: hidden;
}
.login-brand {
    background: var(--surface-header);
    color: var(--text-inverse);
    padding: 28px var(--space-8) 22px;
}
.login-brand h1 {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--text-inverse);
    margin-bottom: var(--space-1);
    letter-spacing: -0.3px;
}
.login-brand .subtitle {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-bottom: 0;
}
.login-form-body {
    padding: 28px var(--space-8) var(--space-6);
    background: var(--surface-card);
}
.login-container h1 { margin-bottom: var(--space-2); font-size: var(--text-xl); }
.login-brand h1 { color: var(--text-inverse); }
.subtitle { color: var(--text-secondary); margin-bottom: var(--space-5); font-size: var(--text-sm); }

.form-group { margin-bottom: var(--space-3); text-align: left; }
.form-group label {
    display: block; margin-bottom: var(--space-1); font-weight: var(--weight-semibold);
    font-size: var(--text-sm); color: var(--text-secondary);
}
.form-group input {
    width: 100%; padding: var(--space-2) 10px; border: 1px solid var(--border-default);
    border-radius: var(--radius-md); font-size: var(--text-base); color: var(--text-primary);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    background: var(--surface-card);
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group select {
    width: 100%; padding: var(--space-2) 10px; border: 1px solid var(--border-default);
    border-radius: var(--radius-md); font-size: var(--text-base); background: var(--surface-card);
    cursor: pointer; appearance: auto; color: var(--text-primary);
}
.form-group .required { color: var(--color-danger); font-weight: var(--weight-normal); }
.error-msg { color: var(--color-danger); font-size: var(--text-sm); margin-top: var(--space-2); }

/* Form Actions */
.form-actions {
    display: flex; justify-content: flex-end; gap: var(--space-2);
    margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border-subtle);
}
.btn-cancel {
    background: var(--neutral-100); color: var(--text-secondary);
}
.btn-cancel:hover { background: var(--neutral-200); }

/* ─── Status Badge ─── */
.status-badge {
    display: inline-block; padding: 2px var(--space-2); border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: var(--weight-semibold);
    letter-spacing: 0.2px;
}
.status-badge.active { background: var(--color-success-light); color: #166534; }
.status-badge.inactive { background: var(--color-danger-light); color: #991b1b; }

/* ===================================
 * Buttons
 * =================================== */
.btn {
    cursor: pointer; border: none; border-radius: var(--radius-md); padding: var(--space-2) var(--space-4);
    font-size: var(--text-base); font-weight: var(--weight-semibold);
    transition: all var(--duration-fast) var(--ease-out);
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
    position: relative;
}
.btn:active:not(:disabled) {
    transform: scale(0.97);
}
.btn-primary { background: var(--color-brand); color: var(--text-inverse); }
.btn-primary:hover { background: var(--color-brand-hover); }
.btn-danger { background: var(--color-danger); color: var(--text-inverse); }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-sm { padding: 5px 10px; font-size: var(--text-sm); }
.btn-xs {
    padding: 3px var(--space-2); font-size: var(--text-xs); border-radius: var(--radius-sm);
    cursor: pointer; border: none; font-weight: var(--weight-medium);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Action Buttons (Explorer toolbar) */
.btn-action-green {
    background: var(--color-success); color: var(--text-inverse); border: none; border-radius: var(--radius-sm);
    padding: 5px var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.btn-action-green:hover:not(:disabled) { background: var(--color-success-hover); }
.btn-action-green:disabled, .btn-action-green.btn-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-action-green:active:not(:disabled) { transform: scale(0.97); }

.btn-action-blue {
    background: var(--color-brand); color: var(--text-inverse); border: none; border-radius: var(--radius-sm);
    padding: 5px var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.btn-action-blue:hover:not(:disabled) { background: var(--color-brand-hover); }
.btn-action-blue:disabled, .btn-action-blue.btn-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-action-blue:active:not(:disabled) { transform: scale(0.97); }

.btn-action-gray {
    background: var(--neutral-600); color: var(--text-inverse); border: none; border-radius: var(--radius-sm);
    padding: 5px var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.btn-action-gray:hover:not(:disabled) { background: var(--neutral-700); }
.btn-action-gray:active:not(:disabled) { transform: scale(0.97); }

.btn-action-red {
    background: var(--color-danger); color: var(--text-inverse); border: none; border-radius: var(--radius-sm);
    padding: 5px var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.btn-action-red:hover:not(:disabled) { background: var(--color-danger-hover); }
.btn-action-red:active:not(:disabled) { transform: scale(0.97); }

/* ===================================
 * Top Bar (Header) — 3-zone layout
 * =================================== */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--space-4); background: var(--surface-header); color: var(--text-inverse);
    height: 48px; flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.top-bar h2 { font-size: var(--text-lg); font-weight: var(--weight-bold); }

/* Left zone: logo */
.top-bar-left {
    display: flex; align-items: center; gap: 10px;
    min-width: 180px;
}
.top-bar-logo {
    font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--text-inverse);
    white-space: nowrap; letter-spacing: -0.5px;
}

/* Center zone: navigation */
.top-bar-center {
    display: flex; align-items: center; gap: 2px;
    flex: 1; justify-content: center;
}
.nav-item {
    background: transparent; border: none; color: rgba(255, 255, 255, 0.6);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-base);
    font-weight: var(--weight-medium);
    cursor: pointer; transition: all var(--duration-fast) var(--ease-out); white-space: nowrap;
}
.nav-item:hover { color: var(--text-inverse); background: rgba(255, 255, 255, 0.08); }
.nav-item.active {
    background: var(--color-brand); color: var(--text-inverse); font-weight: var(--weight-semibold);
}

/* Right zone: user area */
.top-bar-right {
    display: flex; align-items: center; gap: var(--space-2);
    min-width: 180px; justify-content: flex-end;
}
.top-bar-icon-btn {
    background: rgba(255, 255, 255, 0.08); border: none; color: rgba(255, 255, 255, 0.7);
    width: 32px; height: 32px; border-radius: var(--radius-md); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-lg); transition: all var(--duration-fast) var(--ease-out);
}
.top-bar-icon-btn:hover { background: rgba(255, 255, 255, 0.15); color: var(--text-inverse); }

.top-bar-user {
    display: flex; align-items: center; gap: var(--space-2);
}
.user-avatar {
    width: 28px; height: 28px; border-radius: var(--radius-full);
    background: var(--color-brand); color: var(--text-inverse); display: flex;
    align-items: center; justify-content: center;
    font-size: var(--text-xs); font-weight: var(--weight-bold); flex-shrink: 0;
}

/* Legacy user-info support */
.user-info { display: flex; align-items: center; gap: var(--space-2); }
.user-info span { font-size: var(--text-sm); color: rgba(255, 255, 255, 0.85); }
.user-info .btn {
    background: rgba(255, 255, 255, 0.1); color: var(--text-inverse);
    padding: 5px var(--space-3); font-size: var(--text-sm);
}
.user-info .btn:hover { background: rgba(255, 255, 255, 0.2); }
.user-info .btn-danger { background: rgba(220, 38, 38, 0.8); }
.user-info .btn-danger:hover { background: rgba(220, 38, 38, 1); }

/* ===================================
 * Main Layout
 * =================================== */
.main-content { display: flex; flex: 1; overflow: hidden; }

/* ─── Sidebar (Chat page) ─── */
.sidebar {
    width: 220px; background: var(--surface-card); border-right: 1px solid var(--border-default);
    padding: var(--space-3); display: flex; flex-direction: column; overflow-y: auto;
    flex-shrink: 0;
}
.session-list { margin-top: var(--space-2); flex: 1; overflow-y: auto; }
.session-item {
    padding: var(--space-2) 10px; border-radius: var(--radius-md); cursor: pointer;
    margin-bottom: 2px; font-size: var(--text-base); color: var(--text-secondary);
    display: flex; flex-direction: column; position: relative;
    transition: background var(--duration-fast) var(--ease-out);
}
.session-item:hover { background: var(--neutral-100); }
.session-item.active { background: var(--color-brand-light); color: var(--color-brand); }
.session-title {
    font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; padding-right: 22px; font-size: var(--text-base);
}
.session-item.active .session-title { font-weight: var(--weight-semibold); }
.session-meta {
    display: flex; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px;
}
.session-date { }
.session-count { color: var(--text-muted); }
.session-delete-btn {
    position: absolute; top: 6px; right: 6px;
    background: none; border: none; color: var(--text-muted);
    font-size: var(--text-md); cursor: pointer; line-height: 1;
    width: 20px; height: 20px; display: flex;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm); opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.session-item:hover .session-delete-btn { opacity: 1; }
.session-delete-btn:hover { background: var(--color-danger-light); color: var(--color-danger); }

/* ===================================
 * Chat Area
 * =================================== */
.chat-area { flex: 1; display: flex; flex-direction: column; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5);
    display: flex; flex-direction: column; gap: 10px;
}
.welcome-msg { text-align: center; margin: auto; color: var(--text-tertiary); }
.welcome-msg h3 { margin-bottom: var(--space-2); font-size: var(--text-lg); font-weight: var(--weight-semibold); }

.msg {
    max-width: 70%; padding: 10px var(--space-3); border-radius: var(--radius-xl);
    font-size: var(--text-base); line-height: var(--leading-relaxed);
}
.msg-user {
    align-self: flex-end; background: var(--color-brand); color: var(--text-inverse);
    border-bottom-right-radius: 3px;
    box-shadow: var(--shadow-xs);
}
.msg-ai {
    align-self: flex-start; background: var(--surface-card); border: 1px solid var(--border-default);
    border-bottom-left-radius: 3px;
    box-shadow: var(--shadow-xs);
}
.msg-ai .ref-docs { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-tertiary); }
.msg-ai .ref-docs a { color: var(--color-brand); text-decoration: underline; }

.chat-input-area {
    padding: var(--space-3) var(--space-4); background: var(--surface-card); border-top: 1px solid var(--border-default);
    display: flex; gap: var(--space-2); align-items: flex-end;
}
.chat-input-area textarea {
    flex: 1; resize: none; border: 1px solid var(--border-default); border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3); font-size: var(--text-base); max-height: 100px;
    font-family: inherit; color: var(--text-primary);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}
.chat-input-area textarea:focus {
    outline: none; border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===================================
 * Modal
 * =================================== */
.modal {
    position: fixed; inset: 0; background: rgba(12, 18, 32, 0.5);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    backdrop-filter: blur(2px);
}
.modal-content {
    background: var(--surface-card); border-radius: var(--radius-xl); width: 500px; max-height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modalIn var(--duration-slow) var(--ease-out);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-lg { width: 800px; }
.modal-md { width: 560px; }
.modal-sm { width: 440px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-default);
}
.modal-header h3 { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--text-primary); }
.modal-close {
    background: none; border: none; font-size: 20px; cursor: pointer;
    color: var(--text-tertiary); transition: color var(--duration-fast) var(--ease-out);
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--neutral-100); }
.modal-body { padding: var(--space-4); overflow-y: auto; }

/* ===================================
 * Tabs
 * =================================== */
.tab-bar { display: flex; gap: 3px; margin-bottom: var(--space-3); }
.tab {
    padding: var(--space-2) var(--space-3); border: none; background: var(--neutral-100);
    border-radius: var(--radius-md);
    cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary);
    transition: all var(--duration-fast) var(--ease-out);
}
.tab:hover { background: var(--neutral-200); }
.tab.active { background: var(--color-brand); color: var(--text-inverse); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===================================
 * Data Table
 * =================================== */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th {
    background: var(--neutral-50); padding: var(--space-2) 10px; text-align: left;
    border-bottom: 2px solid var(--border-default); font-weight: var(--weight-semibold);
    font-size: var(--text-xs); color: var(--text-tertiary); text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky; top: 0; z-index: 1;
}
.data-table td {
    padding: 6px 10px; border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary); vertical-align: middle;
    transition: background var(--duration-fast) var(--ease-out);
}
.data-table tr:hover td { background: var(--neutral-50); }
.toolbar { margin-bottom: 10px; }

/* ===================================
 * Admin Page
 * =================================== */
.admin-content {
    flex: 1; overflow-y: auto; padding: var(--space-5) 28px; max-width: 1200px;
    width: 100%; margin: 0 auto;
}
.admin-tab {
    padding: var(--space-2) var(--space-3); border: none; background: var(--neutral-100);
    border-radius: var(--radius-md);
    cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary);
    transition: all var(--duration-fast) var(--ease-out);
}
.admin-tab.active { background: var(--color-brand); color: var(--text-inverse); }
.admin-tab:hover:not(.active) { background: var(--neutral-200); }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

/* User docs expansion row */
.user-docs-row td { padding: 0 !important; border-bottom: 2px solid var(--border-default); }
.user-docs-container {
    padding: 10px var(--space-4) 10px 36px; background: var(--neutral-50);
    animation: slideDown var(--duration-normal) var(--ease-out);
}
.user-docs-container h4 {
    font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-2);
    font-weight: var(--weight-semibold);
}
.user-docs-container .no-docs { color: var(--text-muted); font-size: var(--text-sm); }
.user-docs-table {
    width: 100%; border-collapse: collapse; font-size: var(--text-xs);
}
.user-docs-table th {
    background: var(--neutral-100); padding: 5px var(--space-2); text-align: left;
    font-weight: var(--weight-semibold); border-bottom: 1px solid var(--border-default); font-size: var(--text-xs);
}
.user-docs-table td { padding: 5px var(--space-2); border-bottom: 1px solid var(--border-subtle); }
.btn-docs {
    padding: 3px var(--space-2); font-size: var(--text-xs); background: var(--color-brand-light);
    color: var(--color-brand);
    border: 1px solid var(--color-brand-muted); border-radius: var(--radius-sm); cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.btn-docs:hover { background: var(--color-brand-muted); }
.btn-docs.open { background: var(--color-brand); color: var(--text-inverse); border-color: var(--color-brand); }

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

/* ===================================
 * Upload
 * =================================== */
.upload-zone {
    border: 2px dashed var(--border-default); border-radius: var(--radius-lg); padding: var(--space-8);
    text-align: center; cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
}
.upload-zone:hover { border-color: var(--color-brand); background: var(--color-brand-light); }
.upload-zone .hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }
.upload-progress { margin-top: 10px; }
.upload-item {
    display: flex; justify-content: space-between; padding: 6px 0;
    font-size: var(--text-sm); border-bottom: 1px solid var(--border-subtle);
}

/* ===================================
 * Typing Indicator
 * =================================== */
.msg-typing {
    align-self: flex-start;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    border-bottom-left-radius: 3px;
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.msg-typing .dot {
    width: 7px; height: 7px;
    background: var(--text-muted); border-radius: var(--radius-full);
    animation: typingBounce 1.4s infinite ease-in-out;
}
.msg-typing .dot:nth-child(1) { animation-delay: 0s; }
.msg-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.msg-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===================================
 * Markdown Content (AI responses)
 * =================================== */
.md-content {
    line-height: var(--leading-relaxed);
}
.md-content .md-heading {
    margin: 10px 0 5px 0; font-weight: var(--weight-bold);
    color: var(--text-primary); line-height: var(--leading-tight);
}
.md-content h3.md-heading {
    font-size: var(--text-md); padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--border-default); margin-top: var(--space-3);
}
.md-content h4.md-heading { font-size: var(--text-base); }
.md-content .md-heading:first-child { margin-top: 0; }
.md-content .md-paragraph { margin: 2px 0; line-height: var(--leading-relaxed); }
.md-content .md-spacer { height: 6px; }
.md-content .md-list { margin: var(--space-1) 0 var(--space-1) var(--space-1); padding-left: var(--space-4); }
.md-content .md-list li { margin: 2px 0; line-height: var(--leading-relaxed); }
.md-content ul.md-list { list-style: none; padding-left: var(--space-2); }
.md-content ul.md-list li::before {
    content: '\2022'; color: var(--color-brand); font-weight: var(--weight-bold); margin-right: 6px;
}
.md-content ol.md-list { list-style: decimal; }
.md-content strong { color: var(--text-primary); font-weight: var(--weight-bold); }
.md-content em { color: var(--text-secondary); font-style: italic; }
.md-content .md-inline-code {
    background: var(--neutral-100); color: var(--color-danger); padding: 1px 5px;
    border-radius: 3px; font-family: var(--font-mono);
    font-size: var(--text-sm);
}
.md-content .md-code-block {
    background: var(--surface-code); color: var(--neutral-200);
    padding: 10px var(--space-3); border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-xs); line-height: var(--leading-normal);
    overflow-x: auto; margin: 6px 0; white-space: pre-wrap;
}

/* ===================================
 * Restricted Docs Notice
 * =================================== */
.restricted-docs {
    margin-top: 10px; padding: var(--space-2) var(--space-3);
    background: var(--color-warning-light); border: 1px solid var(--color-warning-muted);
    border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--color-warning-text);
}
.restricted-docs strong {
    display: block; margin-bottom: var(--space-1); color: #c2410c; font-size: var(--text-xs);
}
.restricted-doc-name {
    display: inline-block; background: #fef3c7; border: 1px solid #fcd34d;
    border-radius: 3px; padding: 1px 6px; margin: 2px 3px 2px 0;
    font-size: var(--text-xs); color: #92400e; font-weight: var(--weight-medium);
}
.restricted-docs-hint {
    margin-top: var(--space-1); font-size: var(--text-2xs); color: #a16207; font-style: italic;
}

/* ===================================
 * Web Search Results
 * =================================== */
.web-search-results {
    margin-top: 10px; padding: var(--space-2) var(--space-3);
    background: var(--color-success-light); border: 1px solid var(--color-success-muted);
    border-radius: var(--radius-md); font-size: var(--text-sm); color: #14532d;
}
.web-search-results strong {
    display: block; margin-bottom: var(--space-1); color: var(--color-success-hover); font-size: var(--text-xs);
}
.web-results-list { list-style: none; padding: 0; margin: 0; }
.web-results-list li { padding: 2px 0; font-size: var(--text-xs); }
.web-results-list li::before { content: '\1F517 '; }
.web-results-list a { color: var(--color-brand-hover); text-decoration: none; }
.web-results-list a:hover { text-decoration: underline; }

/* ===================================
 * Supplementary Info
 * =================================== */
.supplementary-info {
    margin-top: 10px; padding-top: var(--space-2);
    border-top: 1px dashed var(--border-default); font-size: var(--text-sm); color: var(--text-secondary);
}
.supplementary-info strong {
    display: block; margin-bottom: var(--space-1); color: var(--color-brand); font-size: var(--text-xs);
}
.supplementary-content {
    background: var(--neutral-50); padding: 6px 10px; border-radius: var(--radius-md);
    line-height: var(--leading-relaxed); white-space: pre-wrap;
}

/* ===================================
 * Upload Type Selector
 * =================================== */
.upload-type-selector { margin-bottom: var(--space-3); }
.upload-type-label {
    display: block; font-weight: var(--weight-semibold); font-size: var(--text-base);
    margin-bottom: var(--space-2); color: var(--text-secondary);
}
.upload-type-options { display: flex; gap: 10px; }
.upload-type-option {
    flex: 1; display: flex; align-items: center; gap: var(--space-2);
    padding: 10px var(--space-3); border: 2px solid var(--border-default);
    border-radius: var(--radius-md); cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.upload-type-option:hover { border-color: var(--border-strong); }
.upload-type-option input[type="radio"] { display: none; }
.upload-type-option input[type="radio"]:checked + .upload-type-icon + .upload-type-text {
    color: var(--color-brand);
}
.upload-type-option:has(input:checked) {
    border-color: var(--color-brand); background: var(--color-brand-light);
}
.upload-type-icon { font-size: 22px; }
.upload-type-text { display: flex; flex-direction: column; gap: 1px; }
.upload-type-text strong { font-size: var(--text-base); }
.upload-type-text small { font-size: var(--text-2xs); color: var(--text-tertiary); }

/* ===================================
 * Dept Change
 * =================================== */
.dept-change-select {
    padding: 3px 6px; font-size: var(--text-xs); border: 1px solid var(--border-default);
    border-radius: var(--radius-sm); background: var(--surface-card);
}
.btn-dept-change {
    padding: 3px var(--space-2); font-size: var(--text-xs); background: var(--color-brand-light);
    color: var(--color-brand);
    border: 1px solid var(--color-brand-muted); border-radius: var(--radius-sm); cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}
.btn-dept-change:hover { background: var(--color-brand-muted); }

/* ===================================
 * Document Action Buttons
 * =================================== */
.doc-actions { white-space: nowrap; display: flex; gap: 3px; }
.btn-doc-action {
    padding: 2px 7px; font-size: var(--text-xs); border-radius: 3px;
    cursor: pointer; border: 1px solid; transition: all var(--duration-fast) var(--ease-out);
    font-weight: var(--weight-medium);
}
.btn-doc-dept {
    background: var(--color-brand-light); color: var(--color-brand); border-color: var(--color-brand-muted);
}
.btn-doc-dept:hover { background: var(--color-brand-muted); }
.btn-doc-user {
    background: var(--color-success-light); color: #166534; border-color: var(--color-success-muted);
}
.btn-doc-user:hover { background: var(--color-success-muted); }
.btn-doc-delete {
    background: var(--color-danger-light); color: var(--color-danger); border-color: var(--color-danger-muted);
}
.btn-doc-delete:hover { background: var(--color-danger-muted); }

/* ===================================
 * Log Viewer
 * =================================== */
.log-toolbar {
    display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap;
}
.log-select {
    padding: 5px var(--space-2); font-size: var(--text-sm); border: 1px solid var(--border-default);
    border-radius: var(--radius-sm); background: var(--surface-card);
}
.log-input {
    padding: 5px var(--space-2); font-size: var(--text-sm); border: 1px solid var(--border-default);
    border-radius: var(--radius-sm); width: 180px;
}
.log-count { font-size: var(--text-xs); color: var(--text-tertiary); margin-left: var(--space-2); }
.log-viewer {
    margin-top: 10px; background: var(--surface-code); border-radius: var(--radius-md);
    overflow: auto; max-height: calc(100vh - 240px); min-height: 280px;
}
#log-content {
    padding: var(--space-3); margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs); line-height: var(--leading-relaxed); color: var(--neutral-200);
    white-space: pre-wrap; word-break: break-all;
}
.log-line-DEBUG { color: var(--text-muted); }
.log-line-INFO { color: #4ade80; }
.log-line-WARN { color: #facc15; }
.log-line-ERROR { color: #f87171; }
.log-line-itError { color: #f87171; font-weight: bold; background: rgba(248, 113, 113, 0.1); }

/* ===================================
 * File Explorer
 * =================================== */
.explorer-layout {
    display: flex; flex: 1; overflow: hidden;
}

/* ─── Explorer Sidebar (Folder Tree) ─── */
.explorer-sidebar {
    width: 220px; background: var(--surface-card); border-right: 1px solid var(--border-default);
    display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.explorer-tree-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px var(--space-3); border-bottom: 1px solid var(--border-default);
    background: var(--neutral-50);
}
.explorer-tree-header strong {
    font-size: var(--text-sm); color: var(--text-primary); font-weight: var(--weight-bold);
}

.folder-tree { padding: 6px 0; flex: 1; overflow-y: auto; }

.tree-section { margin-bottom: 2px; }
.tree-section-title {
    padding: 6px var(--space-3) 3px; font-size: var(--text-2xs); font-weight: var(--weight-bold);
    color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px;
}

.tree-item { padding-left: 6px; }
.tree-item-label {
    display: flex; align-items: center; gap: 6px;
    padding: var(--space-1) 10px; font-size: var(--text-sm); color: var(--text-secondary);
    cursor: pointer; border-radius: var(--radius-sm); margin: 1px 6px;
    transition: all var(--duration-fast) var(--ease-out); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.tree-item-label:hover { background: var(--neutral-100); }
.tree-item-label.active {
    background: var(--color-brand); color: var(--text-inverse); font-weight: var(--weight-semibold);
}
.tree-children { padding-left: var(--space-3); }

/* CSS Folder Icon */
.folder-icon {
    display: inline-block; width: 16px; height: 13px; position: relative;
    flex-shrink: 0;
}
.folder-icon::before {
    content: '';
    position: absolute; top: 0; left: 0;
    width: 7px; height: 3px;
    background: #f59e0b; border-radius: 1px 2px 0 0;
}
.folder-icon::after {
    content: '';
    position: absolute; top: 3px; left: 0;
    width: 16px; height: 10px;
    background: #fbbf24; border-radius: 0 2px 2px 2px;
}

/* ─── Explorer Main Area ─── */
.explorer-main {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; background: var(--neutral-50);
}
.explorer-breadcrumb {
    padding: var(--space-2) var(--space-4); font-size: var(--text-base); font-weight: var(--weight-semibold);
    color: var(--text-primary); background: var(--surface-card); border-bottom: 1px solid var(--border-default);
}
.explorer-toolbar {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-4); background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
}
.explorer-count {
    font-size: var(--text-xs); color: var(--text-tertiary); margin-left: auto;
}

/* Explorer Search Bar */
.explorer-search-bar {
    padding: var(--space-2) var(--space-4); background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
}
#explorer-search {
    width: 100%; padding: 6px 10px; font-size: var(--text-sm);
    border: 1px solid var(--border-default); border-radius: var(--radius-md);
    background: var(--neutral-50); color: var(--text-primary);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
}
#explorer-search:focus {
    outline: none; border-color: var(--color-brand); background: var(--surface-card);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
#explorer-search::placeholder { color: var(--text-muted); }

/* File List */
.explorer-file-list {
    flex: 1; overflow-y: auto; padding: 0 var(--space-4);
}
.explorer-file-list .data-table { margin-top: 0; }
.explorer-file-list .data-table td {
    max-width: 280px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.explorer-empty {
    text-align: center; padding: var(--space-10) var(--space-4); color: var(--text-muted);
}
.explorer-empty p:first-child { font-size: var(--text-md); margin-bottom: var(--space-1); }

/* ─── Explorer Detail Panel (right sidebar) ─── */
.explorer-detail-panel {
    width: 300px; background: var(--surface-card); border-left: 1px solid var(--border-default);
    display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.detail-panel-header {
    padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--border-default);
    font-size: var(--text-base); font-weight: var(--weight-bold); color: var(--text-primary);
    background: var(--neutral-50); display: flex; align-items: center;
    justify-content: space-between;
}
.detail-panel-tabs {
    display: flex; border-bottom: 1px solid var(--border-default);
}
.detail-tab {
    flex: 1; padding: var(--space-2) 0; text-align: center; font-size: var(--text-xs);
    font-weight: var(--weight-semibold); color: var(--text-tertiary); background: transparent;
    border: none; cursor: pointer; border-bottom: 2px solid transparent;
    transition: all var(--duration-fast) var(--ease-out);
}
.detail-tab:hover { color: var(--text-secondary); }
.detail-tab.active {
    color: var(--color-brand); border-bottom-color: var(--color-brand);
}
.detail-tab-content { display: none; padding: var(--space-3); }
.detail-tab-content.active { display: block; }
.detail-field {
    margin-bottom: 10px; display: flex; flex-direction: column;
}
.detail-field label,
.detail-field-label {
    font-size: var(--text-2xs); font-weight: var(--weight-bold); color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px;
}
.detail-field span,
.detail-field-value {
    font-size: var(--text-sm); color: var(--text-primary); word-break: break-all;
}

/* ─── Explorer Pagination ─── */
.explorer-pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-2) var(--space-4); background: var(--surface-card); border-top: 1px solid var(--border-default);
    flex-shrink: 0;
}
.pagination-controls {
    display: flex; align-items: center; gap: 2px;
}
.pagination-controls button {
    background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-2); font-size: var(--text-xs); cursor: pointer; color: var(--text-secondary);
    transition: all var(--duration-fast) var(--ease-out); min-width: 28px;
}
.pagination-controls button:hover { background: var(--neutral-100); border-color: var(--border-strong); }
.pagination-controls button:disabled { opacity: 0.35; cursor: not-allowed; }
.page-number {
    background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-2); font-size: var(--text-xs); cursor: pointer; color: var(--text-secondary);
    min-width: 28px; text-align: center; transition: all var(--duration-fast) var(--ease-out);
}
.page-number:hover { background: var(--neutral-100); }
.page-number.active {
    background: var(--color-brand); color: var(--text-inverse); border-color: var(--color-brand);
}
.pagination-info { font-size: var(--text-xs); color: var(--text-tertiary); }

/* Upload Area */
.explorer-upload-area {
    padding: var(--space-3) var(--space-4); background: var(--surface-card); border-top: 2px solid var(--border-default);
}
.explorer-upload-zone {
    border: 2px dashed var(--border-default); border-radius: var(--radius-md); padding: var(--space-4);
    text-align: center; cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
    font-size: var(--text-sm);
}
.explorer-upload-zone:hover { border-color: var(--color-brand); background: var(--color-brand-light); }
.explorer-upload-zone .hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 3px; }
.explorer-upload-actions {
    display: flex; gap: var(--space-2); margin-top: var(--space-2); justify-content: flex-end;
}

/* ===================================
 * Context Menu
 * =================================== */
.context-menu {
    position: fixed; background: var(--surface-card); border: 1px solid var(--border-default);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    z-index: 200; min-width: 150px; padding: var(--space-1) 0;
    animation: contextMenuIn var(--duration-fast) var(--ease-out);
}
@keyframes contextMenuIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.context-menu-item {
    padding: 6px var(--space-3); font-size: var(--text-sm); cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out); color: var(--text-secondary);
}
.context-menu-item:hover { background: var(--neutral-100); }
.context-menu-item.danger { color: var(--color-danger); }
.context-menu-item.danger:hover { background: var(--color-danger-light); }

/* ===================================
 * Folder Permission Modal
 * =================================== */
.folder-perm-list { max-height: 280px; overflow-y: auto; margin-bottom: 10px; }

/* Permission Sections */
.perm-section { margin-top: var(--space-4); }
.perm-section-label {
    display: block; font-weight: var(--weight-semibold); font-size: var(--text-base);
    color: var(--text-primary); margin-bottom: var(--space-2);
}

/* Default Permission Box */
.perm-default-box {
    border: 1px solid var(--border-default); border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-3); background: var(--neutral-50);
}
.perm-default-radios {
    display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2);
}
.perm-default-radios label {
    display: flex; align-items: center; gap: var(--space-1);
    font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; color: var(--text-secondary);
}
.perm-default-radios input[type="radio"] { accent-color: var(--color-brand); }
.perm-desc { font-size: var(--text-xs); color: var(--text-tertiary); line-height: 1.8; }
.perm-desc p { margin: 0; }
.perm-note { color: var(--color-danger) !important; font-weight: var(--weight-medium); }

/* Folder Owner */
.perm-owner-box {
    display: flex; align-items: center; gap: var(--space-2);
    padding: 7px 10px; background: var(--neutral-50); border: 1px solid var(--border-default);
    border-radius: var(--radius-md); margin-bottom: var(--space-1);
}
.perm-owner-display { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text-primary); }
.perm-owner-select-row {
    background: var(--color-brand-light); border: 1px solid var(--color-brand-muted);
    border-radius: var(--radius-md); overflow: hidden; margin-bottom: var(--space-1);
}

/* Per-User Permissions */
.perm-user-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: var(--space-2);
}
.perm-user-actions { display: flex; gap: 3px; }
.perm-user-add-panel {
    margin-bottom: var(--space-2); background: var(--color-brand-light); border: 1px solid var(--color-brand-muted);
    border-radius: var(--radius-md); overflow: hidden;
}
.perm-user-search-box {
    display: flex; gap: 5px; align-items: center;
    padding: 7px var(--space-2); border-bottom: 1px solid var(--color-brand-muted);
}
.perm-user-search {
    flex: 1; padding: 5px var(--space-2); font-size: var(--text-sm);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none;
}
.perm-user-search:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.perm-user-list { list-style: none; margin: 0; padding: 0; max-height: 160px; overflow-y: auto; }
.perm-user-list li {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; font-size: var(--text-sm); cursor: pointer;
    border-bottom: 1px solid var(--color-brand-subtle); transition: background var(--duration-fast) var(--ease-out);
}
.perm-user-list li:last-child { border-bottom: none; }
.perm-user-list li:hover { background: var(--color-brand-subtle); }
.perm-user-list li .user-id { font-weight: var(--weight-semibold); color: var(--color-brand-hover); }
.perm-user-list li .user-name { color: var(--text-secondary); }
.perm-user-list li .user-dept {
    margin-left: auto; font-size: var(--text-2xs); color: var(--text-tertiary);
    background: var(--neutral-100); padding: 1px 5px; border-radius: 3px;
}
.perm-user-list-empty {
    display: none; padding: var(--space-3); text-align: center;
    font-size: var(--text-sm); color: var(--text-muted);
}
.perm-user-table-wrap {
    border: 1px solid var(--border-default); border-radius: var(--radius-md);
    overflow: hidden; max-height: 220px; overflow-y: auto;
}
.perm-user-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.perm-user-table th {
    background: var(--neutral-50); padding: 6px var(--space-2); text-align: left;
    font-weight: var(--weight-semibold); font-size: var(--text-xs); color: var(--text-tertiary);
    border-bottom: 2px solid var(--border-default); position: sticky; top: 0;
}
.perm-user-table td {
    padding: 5px var(--space-2); border-bottom: 1px solid var(--border-subtle); vertical-align: middle;
}
.perm-user-table td:nth-child(n+3) { text-align: center; }
.perm-user-table input[type="radio"] { accent-color: var(--color-brand); }
.perm-user-table input[type="checkbox"] { accent-color: var(--color-brand); }
.perm-user-empty {
    text-align: center; padding: var(--space-4); color: var(--text-muted); font-size: var(--text-sm);
}

/* ===================================
 * Document AI Chat FAB
 * =================================== */
.explorer-chat-fab {
    position: fixed; bottom: 28px; right: 28px;
    width: 50px; height: 50px; border-radius: var(--radius-full);
    background: var(--color-brand); color: var(--text-inverse); border: none;
    font-size: 22px; cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
    z-index: 300; display: none;
    align-items: center; justify-content: center;
    transition: transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out);
}
.explorer-chat-fab:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
}
.explorer-chat-fab:active {
    transform: scale(1.02);
}
.explorer-chat-fab.visible { display: flex; }

/* ===================================
 * Document AI Chat Panel (slide-in)
 * =================================== */
.explorer-chat-panel {
    position: fixed; top: 0; right: 0;
    width: 400px; height: 100vh;
    background: var(--surface-card);
    box-shadow: var(--shadow-xl);
    z-index: 400; display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--duration-slow) var(--ease-out);
}
.explorer-chat-panel.open { transform: translateX(0); }

.explorer-chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-3) var(--space-4); background: var(--surface-header); color: var(--text-inverse);
    flex-shrink: 0;
}
.explorer-chat-header h3 { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); }
.explorer-chat-header .modal-close {
    color: var(--text-inverse); background: transparent; border: none;
    font-size: 20px; cursor: pointer; opacity: 0.7;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.explorer-chat-header .modal-close:hover { opacity: 1; }

/* Document Selection Info */
.explorer-chat-doc-info {
    padding: var(--space-2) var(--space-4); background: var(--neutral-50); border-bottom: 1px solid var(--border-default);
    flex-shrink: 0; min-height: 38px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.explorer-chat-doc-hint { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
.explorer-chat-doc-tag {
    display: inline-flex; align-items: center; gap: var(--space-1);
    background: var(--color-brand-light); color: var(--color-brand); font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    padding: 2px 7px; border-radius: var(--radius-full); border: 1px solid var(--color-brand-muted);
    max-width: 180px;
}
.explorer-chat-doc-tag .doc-tag-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.explorer-chat-doc-tag .doc-tag-remove {
    background: none; border: none; color: #3b82f6; cursor: pointer;
    font-size: var(--text-base); padding: 0; line-height: 1; font-weight: var(--weight-bold);
}
.explorer-chat-doc-tag .doc-tag-remove:hover { color: var(--color-danger); }

/* Messages */
.explorer-chat-messages {
    flex: 1; overflow-y: auto; padding: var(--space-3) var(--space-4);
    display: flex; flex-direction: column; gap: 10px;
}
.explorer-chat-messages .msg {
    max-width: 90%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-xl);
    font-size: var(--text-sm); line-height: var(--leading-relaxed); word-break: break-word;
}
.explorer-chat-messages .msg-user {
    align-self: flex-end; background: var(--color-brand); color: var(--text-inverse);
    border-bottom-right-radius: 3px;
    box-shadow: var(--shadow-xs);
}
.explorer-chat-messages .msg-ai {
    align-self: flex-start; background: var(--neutral-50); color: var(--text-primary);
    border: 1px solid var(--border-default); border-bottom-left-radius: 3px;
}
.explorer-chat-messages .msg-ai .md-content { line-height: var(--leading-relaxed); }
.explorer-chat-messages .msg-ai .ref-docs {
    margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--border-default);
    font-size: var(--text-xs); color: var(--text-tertiary);
}

/* Input Area */
.explorer-chat-input-area {
    display: flex; gap: var(--space-2); padding: 10px var(--space-4);
    border-top: 1px solid var(--border-default); background: var(--surface-card); flex-shrink: 0;
}
.explorer-chat-input-area textarea {
    flex: 1; padding: 7px 10px; border: 1px solid var(--border-default);
    border-radius: var(--radius-md); font-size: var(--text-sm); resize: none; outline: none;
    max-height: 72px; font-family: inherit;
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}
.explorer-chat-input-area textarea:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Typing Indicator (panel) */
.explorer-chat-typing {
    display: flex; gap: var(--space-1); align-items: center;
    padding: var(--space-2) var(--space-3); background: var(--neutral-50); border: 1px solid var(--border-default);
    border-radius: var(--radius-xl); align-self: flex-start;
}
.explorer-chat-typing .dot {
    width: 5px; height: 5px; background: var(--text-muted);
    border-radius: var(--radius-full); animation: dotBounce 1.4s ease-in-out infinite;
}
.explorer-chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.explorer-chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40% { transform: scale(1.3); opacity: 1; }
}

/* File list row — chat selection highlight */
tr.chat-selected { background: var(--color-brand-light) !important; }
tr.chat-selected td { color: var(--color-brand); }

/* ===================================
 * Footer
 * =================================== */
.app-footer {
    text-align: center; padding: 6px var(--space-4);
    font-size: var(--text-xs); color: var(--text-muted);
    background: var(--surface-card); border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

/* ===================================
 * Scrollbar Styling
 * =================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--neutral-300); border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===================================
 * Selection Styling
 * =================================== */
::selection {
    background: rgba(37, 99, 235, 0.2);
    color: var(--text-primary);
}

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