/* DataRoom.fast - Figma-inspired collaborative document room */

:root {
    /* Colors - Professional dark/light scheme */
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #334155;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F8FAFC;
    --bg-elevated: #F1F5F9;

    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-dark: #0F172A;
    --text-dark-secondary: #475569;

    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-light: #DBEAFE;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;

    --border-dark: #334155;
    --border-light: #E2E8F0;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);

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

    --topbar-height: 52px;
    --sidebar-width: 260px;
    --right-panel-width: 300px;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ── Auth Page ───────────────────────────────────── */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    overflow: auto;
}

.auth-container {
    width: 400px;
    padding: 40px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-dark);
    box-shadow: var(--shadow-xl);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo svg { margin-bottom: 16px; }

.auth-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-logo .accent { color: var(--accent); }

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-dark);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.auth-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.auth-tab:hover { color: var(--text-primary); }

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-error {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
}

.auth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-dark);
}

.auth-divider span {
    background: var(--bg-secondary);
    padding: 0 12px;
    position: relative;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Buttons ─────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

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

.btn-secondary:hover { background: var(--bg-primary); }

.btn-google {
    background: white;
    color: #333;
    border: 1px solid #ddd;
}

.btn-google:hover { background: #f8f8f8; }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ── App Shell ───────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
}

/* ── Top Bar ─────────────────────────────────────── */

.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: var(--sidebar-width);
}

.topbar-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.breadcrumb-item {
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.breadcrumb-item:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: 11px;
}

.topbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    overflow-x: auto;
}

.doc-tab {
    padding: 6px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.doc-tab.active { background: var(--accent); color: white; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Presence Avatars ────────────────────────────── */

.presence-avatars {
    display: flex;
    align-items: center;
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: 2px solid var(--bg-secondary);
    position: relative;
    cursor: pointer;
    transition: transform 0.15s;
}

.avatar:hover { transform: scale(1.1); z-index: 2; }

.avatar + .avatar { margin-left: -8px; }

.avatar-online::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg-secondary);
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

/* ── User Menu ───────────────────────────────────── */

.user-menu { position: relative; }

.user-avatar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 200;
}

.dropdown-user-info {
    padding: 8px;
    font-size: 13px;
}

.dropdown-user-info .name { font-weight: 600; }
.dropdown-user-info .email { color: var(--text-secondary); font-size: 12px; }

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-dark);
    margin: 4px 0;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover { background: var(--bg-tertiary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

/* ── Main Layout ─────────────────────────────────── */

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s, opacity 0.2s;
}

.sidebar.collapsed { width: 0; opacity: 0; overflow: hidden; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-header h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.document-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.doc-item:hover { background: var(--bg-tertiary); }
.doc-item.active { background: var(--accent); color: white; }

.doc-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.doc-item-icon.pdf { background: #FEE2E2; color: #DC2626; }
.doc-item-icon.docx { background: #DBEAFE; color: #2563EB; }
.doc-item-icon.md { background: #D1FAE5; color: #059669; }
.doc-item-icon.tex { background: #E0E7FF; color: #4338CA; }
.doc-item-icon.txt { background: #F3F4F6; color: #6B7280; }
.doc-item-icon.png, .doc-item-icon.jpg { background: #FEF3C7; color: #D97706; }
.doc-item-icon.zip { background: #FDE68A; color: #92400E; }
.doc-item-icon.eml { background: #FCE7F3; color: #DB2777; }

.doc-item-info {
    flex: 1;
    min-width: 0;
}

.doc-item-name {
    font-size: 13px;
    font-weight: 500;
    overflow-wrap: break-word;
    word-break: break-all;
    white-space: normal;
    line-height: 1.3;
}

.doc-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.doc-item.active .doc-item-meta { color: rgba(255,255,255,0.7); }

/* Version toggle button */
.toggle-versions-btn {
    display: block;
    width: calc(100% - 24px);
    margin: 0 12px 8px;
    padding: 5px 10px;
    font-size: 11px;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
}
.toggle-versions-btn:hover { background: rgba(59, 130, 246, 0.2); }

/* Alt versions badge */
.doc-alt-count {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
    border-radius: var(--radius-full);
    margin-left: 4px;
    cursor: help;
}
.doc-item.active .doc-alt-count { color: rgba(200,220,255,0.9); background: rgba(255,255,255,0.15); }

/* Presence dots on document items */
.doc-item-users {
    display: flex;
    gap: 2px;
}

.doc-user-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ── Viewer Area ─────────────────────────────────── */

.viewer-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.content-view { flex: 1; overflow-y: auto; }

/* Rooms View */
.rooms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
}

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

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 0 32px 32px;
}

.room-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s;
}

.room-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    transform: translateY(-1px);
}

.room-card-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.room-card-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
}

.room-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Viewer */
.viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

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

.page-indicator {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

#zoom-level {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 48px;
    text-align: center;
}

.viewer-canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
    position: relative;
    background: #1a1a2e;
}

#viewer-canvas {
    box-shadow: var(--shadow-lg);
    background: white;
}

.annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.annotation-layer.active { pointer-events: auto; cursor: crosshair; }

.cursor-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 50;
}

.remote-cursor {
    position: absolute;
    pointer-events: none;
    transition: all 0.1s ease-out;
    z-index: 50;
}

.remote-cursor-pointer {
    width: 16px;
    height: 20px;
}

.remote-cursor-label {
    position: absolute;
    top: -24px;
    left: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    color: white;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-muted);
}

/* ── Right Panel ─────────────────────────────────── */

.right-panel {
    width: var(--right-panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.right-panel h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* Minimap */
.minimap-section {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-dark);
}

.minimap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

.minimap-canvas-wrapper {
    position: relative;
    padding: 0 16px 12px;
}

#minimap-canvas {
    width: 100%;
    height: auto;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid var(--accent);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 2px;
    pointer-events: none;
}

.minimap-user-marker {
    position: absolute;
    width: 20px;
    height: 4px;
    border-radius: 2px;
    opacity: 0.8;
    transition: all 0.3s ease;
    cursor: pointer;
}

.minimap-user-marker:hover {
    opacity: 1;
    height: 6px;
}

.minimap-user-marker .tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 4px;
}

.minimap-user-marker:hover .tooltip { display: block; }

.minimap-breadcrumbs {
    padding: 0 16px 12px;
}

.minimap-crumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.minimap-crumb:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.minimap-crumb-users {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

/* Presence Section */
.presence-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
}

.presence-section h4 { margin-bottom: 8px; }

.presence-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.presence-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.presence-item:hover { background: var(--bg-tertiary); }

.presence-item .avatar { width: 24px; height: 24px; font-size: 10px; }

.presence-item-info {
    flex: 1;
    min-width: 0;
}

.presence-item-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-item-location {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.presence-item:hover .presence-item-actions { opacity: 1; }

.presence-btn {
    padding: 2px 8px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    background: var(--accent);
    color: white;
}

.presence-btn.secondary { background: var(--bg-tertiary); color: var(--text-primary); }

/* AI Section */
.ai-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-dark);
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-welcome {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.ai-msg {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.5;
    max-width: 90%;
    word-wrap: break-word;
}

.ai-msg.user {
    background: var(--accent);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-msg.assistant {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-msg.shared-indicator {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    max-width: 100%;
    background: none;
    padding: 4px;
}

.ai-input-form {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-dark);
}

#ai-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
}

#ai-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Comments Panel ──────────────────────────────── */

.comments-panel {
    position: absolute;
    right: var(--right-panel-width);
    top: var(--topbar-height);
    bottom: 0;
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: var(--shadow-lg);
}

.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-dark);
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.comment-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.comment-item:hover { background: var(--bg-tertiary); }

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

.comment-author {
    font-size: 13px;
    font-weight: 500;
}

.comment-time {
    font-size: 11px;
    color: var(--text-muted);
}

.comment-page {
    font-size: 11px;
    color: var(--accent);
    margin-left: auto;
}

.comment-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.comment-input-form {
    padding: 12px;
    border-top: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#comment-input {
    width: 100%;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    resize: vertical;
}

/* ── Modals ──────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 400px;
    max-width: 560px;
    box-shadow: var(--shadow-xl);
}

.modal-wide { min-width: 560px; }

.modal h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ── Settings ────────────────────────────────────── */

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

.settings-section h4 {
    margin-bottom: 8px;
    text-transform: none;
    font-size: 14px;
}

.settings-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.trust-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trust-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.trust-item-info {
    font-size: 13px;
}

/* ── Scrollbar ───────────────────────────────────── */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Markdown Render ─────────────────────────────── */

.md-render {
    padding: 32px;
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-dark);
    background: white;
    font-size: 15px;
    line-height: 1.7;
    min-height: 100%;
}

.md-render h1 { font-size: 28px; margin: 24px 0 12px; font-weight: 700; }
.md-render h2 { font-size: 22px; margin: 20px 0 10px; font-weight: 600; }
.md-render h3 { font-size: 18px; margin: 16px 0 8px; font-weight: 600; }
.md-render p { margin: 0 0 12px; }
.md-render ul, .md-render ol { margin: 0 0 12px; padding-left: 24px; }
.md-render code {
    background: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}
.md-render pre {
    background: #1E293B;
    color: #E2E8F0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0 0 12px;
}
.md-render pre code { background: none; padding: 0; color: inherit; }
.md-render blockquote {
    border-left: 4px solid var(--accent);
    padding: 8px 16px;
    margin: 0 0 12px;
    background: #F8FAFC;
    color: var(--text-dark-secondary);
}
.md-render table { border-collapse: collapse; width: 100%; margin: 0 0 12px; }
.md-render th, .md-render td {
    border: 1px solid var(--border-light);
    padding: 8px 12px;
    text-align: left;
}
.md-render th { background: #F8FAFC; font-weight: 600; }

/* ── Audit Log ───────────────────────────────────── */

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

.audit-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
}

.audit-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-dark);
    color: var(--text-primary);
}

/* ── Animations ──────────────────────────────────── */

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

.room-card { animation: fadeIn 0.2s ease-out; }

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

.loading { animation: pulse 1.5s ease-in-out infinite; }

/* ── Teleport notification ───────────────────────── */

.teleport-toast {
    position: fixed;
    bottom: 24px;
    right: calc(var(--right-panel-width) + 24px);
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    z-index: 500;
    animation: fadeIn 0.2s ease-out;
}

/* ── Document Renderers ─────────────────────────── */

/* Markdown enhanced rendering */
.md-render {
    padding: 32px 48px;
    max-width: 900px;
    margin: 0 auto;
    color: var(--text-dark);
    background: var(--bg-surface);
    min-height: 100%;
    font-size: 15px;
    line-height: 1.7;
}

.md-render h1 { font-size: 28px; font-weight: 700; margin: 24px 0 16px; color: var(--text-dark); border-bottom: 1px solid var(--border-light); padding-bottom: 8px; }
.md-render h2 { font-size: 22px; font-weight: 600; margin: 20px 0 12px; color: var(--text-dark); }
.md-render h3 { font-size: 18px; font-weight: 600; margin: 16px 0 8px; color: var(--text-dark); }
.md-render h4 { font-size: 16px; font-weight: 600; margin: 14px 0 8px; color: var(--text-dark); }
.md-render p { margin: 0 0 12px; }
.md-render ul, .md-render ol { margin: 0 0 12px; padding-left: 24px; }
.md-render li { margin: 4px 0; }
.md-render blockquote { border-left: 4px solid var(--accent); padding: 8px 16px; margin: 12px 0; background: var(--bg-elevated); color: var(--text-dark-secondary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.md-render code { font-family: var(--font-mono); font-size: 13px; background: var(--bg-elevated); padding: 2px 6px; border-radius: 3px; color: #D63384; }
.md-render pre { margin: 12px 0; border-radius: var(--radius-md); overflow-x: auto; }
.md-render pre code { display: block; padding: 16px; background: #1E293B; color: #E2E8F0; border-radius: var(--radius-md); line-height: 1.5; }
.md-render table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.md-render th, .md-render td { border: 1px solid var(--border-light); padding: 8px 12px; text-align: left; }
.md-render th { background: var(--bg-elevated); font-weight: 600; }
.md-render a { color: var(--accent); text-decoration: none; }
.md-render a:hover { text-decoration: underline; }
.md-render hr { border: none; border-top: 1px solid var(--border-light); margin: 24px 0; }
.md-render img { max-width: 100%; height: auto; border-radius: var(--radius-md); margin: 12px 0; }

/* Reset md-render container for non-markdown content */
.md-render:has(.tex-viewer),
.md-render:has(.text-viewer),
.md-render:has(.image-viewer),
.md-render:has(.unsupported-viewer) {
    max-width: 100%;
    padding: 0;
    margin: 0;
    background: transparent;
}

/* LaTeX source viewer */
.tex-viewer {
    padding: 0;
    max-width: 100%;
    min-height: 100%;
    background: #1E293B;
}

.tex-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: #0F172A;
    border-bottom: 1px solid #334155;
}

.tex-badge {
    display: inline-block;
    padding: 3px 10px;
    background: #059669;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tex-filename {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.tex-source {
    padding: 20px 24px !important;
    margin: 0 !important;
    border-radius: 0 !important;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    tab-size: 4;
}

/* Plain text viewer */
.text-viewer {
    padding: 24px 32px;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-surface);
    min-height: 100%;
}

.plain-text-content {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-dark);
    white-space: pre-wrap;
    word-break: break-word;
    tab-size: 4;
}

/* Image viewer */
.image-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    min-height: 100%;
    background: #F8FAFC;
}

.image-container {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    overflow: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.document-image {
    display: block;
    max-width: 100%;
    height: auto;
}

.image-caption {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-dark-secondary);
    font-style: italic;
}

/* Unsupported file type viewer */
.unsupported-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 32px;
    min-height: 100%;
    text-align: center;
    background: var(--bg-surface);
}

.unsupported-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    color: var(--text-dark-secondary);
    border-radius: var(--radius-lg);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
}

.unsupported-viewer h3 {
    color: var(--text-dark);
    font-size: 18px;
    margin-bottom: 8px;
}

.unsupported-meta {
    color: var(--text-dark-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.unsupported-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* KaTeX math display */
.katex-display {
    margin: 16px 0;
    overflow-x: auto;
    padding: 8px 0;
}

/* ── Billing & Pricing ────────────────────────────── */

.billing-status-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 8px;
}

.billing-plan-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.billing-tier-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--accent);
    color: white;
}

.billing-tier-badge.trial {
    background: var(--text-muted);
}

.billing-tier-badge.starter {
    background: var(--accent);
}

.billing-tier-badge.professional {
    background: var(--success);
}

.billing-tier-badge.business {
    background: linear-gradient(135deg, var(--accent), #8B5CF6);
}

.billing-status-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.billing-limits {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.6;
}

.billing-actions {
    display: flex;
    gap: 8px;
}

/* Pricing Modal */
.modal-pricing {
    max-width: 900px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}

.pricing-header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
}

.pricing-header h3 {
    margin-bottom: 6px;
}

.pricing-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.pricing-header .modal-close {
    position: absolute;
    top: 0;
    right: 0;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.pricing-card {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: border-color 0.2s;
}

.pricing-card:hover {
    border-color: var(--accent);
}

.pricing-card.popular {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

.pricing-card.popular::before {
    content: 'Most Popular';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 12px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pricing-card.current {
    border-color: var(--success);
}

.pricing-plan-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.pricing-plan-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.pricing-plan-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

.pricing-plan-period {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    flex: 1;
}

.pricing-features li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    position: relative;
    padding-left: 20px;
}

.pricing-features li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 600;
}

.pricing-card .btn {
    width: 100%;
    text-align: center;
}

.pricing-card .btn-current {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: default;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
