/* ========================================
   Modern Legal AI Assistant - v6.0
   Inspired by ChatGPT, Claude, Perplexity
   ======================================== */

/* Document Tree Styles */
.doc-tree-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-base);
    margin-bottom: 4px;
}

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

.doc-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.doc-tree-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.doc-tree-label {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-item-meta {
    display: flex;
    gap: 12px;
    padding-left: 24px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.doc-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.doc-tree-case {
    margin-bottom: 12px;
}

.doc-tree-case-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    background-color: var(--bg-secondary);
    transition: background-color var(--transition-base);
    font-weight: 500;
}

.doc-tree-case-header:hover {
    background-color: var(--bg-tertiary);
}

.doc-tree-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-tertiary);
}

.doc-tree-case-content {
    padding: 8px 0 8px 12px;
}

/* CSS Variables - Dark Theme (Default) */
:root {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #334155;
    --bg-elevated: #1E293B;

    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-tertiary: #94A3B8;

    --accent-primary: #3B82F6;
    --accent-hover: #2563EB;
    --accent-success: #10B981;
    --accent-warning: #F59E0B;
    --accent-error: #EF4444;

    --border-color: #334155;
    --border-hover: #475569;
    
    --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);
    
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    --transition-base: 200ms ease;
    
    --header-height: 60px;
    --sidebar-width: 280px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #E2E8F0;
    --bg-elevated: #FFFFFF;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #64748B;

    --accent-primary: #3B82F6;
    --accent-hover: #2563EB;
    --accent-success: #10B981;
    --accent-warning: #F59E0B;
    --accent-error: #EF4444;

    --border-color: #E2E8F0;
    --border-hover: #CBD5E1;

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* Top Header */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.header-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 var(--spacing-xl);
}

.header-search {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    transition: border-color var(--transition-base);
}

.header-search:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    color: var(--text-tertiary);
}

.header-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.header-search-input::placeholder {
    color: var(--text-tertiary);
}

.header-search-type {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.header-search-btn {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-base);
}

.header-search-btn:hover {
    background-color: var(--accent-hover);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.header-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.header-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.header-btn svg {
    flex-shrink: 0;
}

.header-model-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 150px;
}

.header-model-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.header-settings-btn {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.header-settings-btn:hover {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 420px;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    z-index: 999;
    overflow-y: auto;
}

.settings-content {
    padding: var(--spacing-xl);
}

/* Navigation Menu */
.nav-menu {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 320px;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    z-index: 999;
    overflow-y: auto;
}

.nav-menu-content {
    padding: var(--spacing-xl);
}

.nav-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.nav-menu-links {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-base);
}

.nav-link:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-hover);
    transform: translateX(-4px);
}

.nav-link svg {
    flex-shrink: 0;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
}

.settings-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

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

.settings-section {
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.section-note {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-md);
}

.api-key-input {
    margin-bottom: var(--spacing-md);
}

.api-key-input label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.api-key-input input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    margin-bottom: var(--spacing-sm);
}

.api-key-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-save-key {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color var(--transition-base);
}

.btn-save-key:hover {
    background-color: var(--accent-hover);
}

.api-key-note {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: var(--spacing-sm);
}

.agent-model-config {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.agent-model-config label {
    flex-shrink: 0;
    width: 140px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.agent-model-select {
    flex: 1;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.agent-model-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-save-settings {
    width: 100%;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: var(--spacing-md);
    transition: background-color var(--transition-base);
}

.btn-save-settings:hover {
    background-color: var(--accent-hover);
}

.setting-item {
    margin-bottom: var(--spacing-lg);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.setting-description {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: var(--spacing-xs);
    margin-left: 26px;
}

.slider {
    width: 100%;
    margin-top: var(--spacing-sm);
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.agent-list {
    padding: var(--spacing-sm) var(--spacing-md);
}

.agent-btn {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 8px;
    margin-bottom: 4px;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.agent-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-hover);
}

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

.agent-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.agent-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-btn.active .agent-name {
    color: white;
}

.agent-desc {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-btn.active .agent-desc {
    color: rgba(255, 255, 255, 0.8);
}

.sidebar-section {
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

/* Chat History */
.chat-history-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xs) 0;
}

.chat-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    margin: 2px var(--spacing-xs);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid transparent;
}

.chat-history-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.chat-history-item.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.chat-history-title {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: var(--spacing-sm);
}

.chat-history-item.active .chat-history-title {
    color: white;
}

.chat-history-meta {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.chat-history-item.active .chat-history-meta {
    color: rgba(255, 255, 255, 0.8);
}

.chat-history-delete {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition-base);
    margin-left: var(--spacing-xs);
}

.chat-history-item:hover .chat-history-delete {
    opacity: 1;
}

.chat-history-item.active .chat-history-delete {
    color: rgba(255, 255, 255, 0.8);
}

.chat-history-delete:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--accent-error);
}

.no-chats {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    padding: var(--spacing-lg);
    font-style: italic;
}

.sidebar-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.upload-area {
    margin-bottom: var(--spacing-sm);
}

.btn-upload {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-base);
}

.btn-upload:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-hover);
}

.upload-status {
    margin-top: var(--spacing-sm);
    font-size: 0.75rem;
    text-align: center;
}

.upload-status.success {
    color: var(--accent-success);
}

.upload-status.error {
    color: var(--accent-error);
}

.document-list {
    max-height: none;
    overflow: hidden;
}

.document-item {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.35rem var(--spacing-sm);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xs);
}

.document-name {
    flex: 1;
    font-size: 0.7rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

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

.sidebar-footer {
    margin-top: auto;
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    position: fixed;
    left: var(--sidebar-width);
    top: var(--header-height);
    right: 50px; /* Account for widget navigation sidebar */
    bottom: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    transition: right var(--transition-base);
}

/* When widget is open, add margin */
.main-content.widget-open {
    right: 450px; /* 50px nav + 400px widget */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

/* ChatGPT/Claude-style messages */
.message {
    margin-bottom: var(--spacing-xl);
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-md);
    transition: background-color 0.2s;
}

.message:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.message-wrapper {
    flex: 1;
    min-width: 0;
}

.message-content {
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
}

/* Markdown styling in messages */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }

.message-content p {
    margin-bottom: 1em;
}

.message-content ul,
.message-content ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.message-content li {
    margin-bottom: 0.5em;
}

.message-content pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    overflow-x: auto;
    margin: 1em 0;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9em;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--text-secondary);
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

/* Message action buttons */
.message-actions {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-md);
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-action svg {
    flex-shrink: 0;
}

.message.assistant .message-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-lg);
    background-color: var(--bg-secondary);
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    padding: var(--spacing-md);
    font-size: 0.875rem;
    resize: none;
    max-height: 200px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-button,
.stop-button {
    background-color: var(--accent-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.stop-button {
    background-color: #ef4444;
}

.send-button:hover {
    background-color: var(--accent-hover);
}

.stop-button:hover {
    background-color: #dc2626;
}

.send-button:disabled,
.stop-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.modal-small {
    max-width: 400px;
}

.modal-medium {
    max-width: 600px;
}

.modal-large {
    max-width: 900px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

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

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

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

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-input,
.form-textarea {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: var(--bg-secondary);
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    margin-top: var(--spacing-md);
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

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

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

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

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

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.search-result-item {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.search-result-item h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--accent-primary);
}

.search-result-item p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Responsive */
@media (max-width: 1024px) {
    .header-center {
        max-width: 400px;
    }
    
    .settings-panel {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

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

    .main-content {
        left: 0;
        right: 0; /* Full width on mobile, widget nav moves to bottom */
        bottom: 60px; /* Account for bottom widget nav bar */
    }

    .header-center {
        display: none;
    }
}

/* ========================================
   Advanced Upload Forms
   ======================================== */

.upload-type-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.upload-type-select:hover {
    border-color: var(--border-hover);
}

.upload-type-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.upload-form {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.upload-form h4 {
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

/* Test Data Management Styles */
.test-data-buttons {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.btn-test-data {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-test-data svg {
    flex-shrink: 0;
}

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

.btn-init:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-cleanup {
    background-color: #dc2626;
    color: white;
}

.btn-cleanup:hover {
    background-color: #b91c1c;
    transform: translateY(-1px);
}

.test-data-info {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    border-left: 3px solid var(--accent-primary);
}

.test-data-info p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.test-data-info p:last-child {
    margin-bottom: 0;
}

.test-data-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

.form-input,
.form-textarea,
.form-file {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: var(--spacing-sm);
    font-family: inherit;
    transition: all var(--transition-base);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    background-color: var(--bg-primary);
}

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

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-file {
    padding: var(--spacing-sm);
    cursor: pointer;
}

.form-file::-webkit-file-upload-button {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: var(--spacing-xs) var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.form-file::-webkit-file-upload-button:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-hover);
}

.btn-upload-advanced {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-top: var(--spacing-sm);
}

.btn-upload-advanced:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-upload-advanced:active {
    transform: translateY(0);
}

.btn-upload-advanced:disabled {
    background-color: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   Court Scraper Styles
   ======================================== */

.scraper-controls {
    margin-bottom: var(--spacing-lg);
}

.scraper-controls h4 {
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

.scraper-buttons {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.btn-scraper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-scraper svg {
    flex-shrink: 0;
}

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

.btn-scraper:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

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

.btn-scraper-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--border-hover);
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.scraper-status {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 14px;
    line-height: 1.5;
}

.scraper-status .loading {
    color: var(--accent-primary);
    font-weight: 500;
}

.scraper-status .success {
    color: var(--accent-success);
    font-weight: 500;
}

.scraper-status .error {
    color: var(--accent-error);
    font-weight: 500;
}

.scraper-status .warning {
    color: var(--accent-warning);
    font-weight: 500;
}

.scraper-status .info {
    color: var(--text-secondary);
}

/* Job Stats Display */
.job-stats {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.stats-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.stats-header strong {
    font-size: 16px;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

/* Responsive scraper controls */
@media (max-width: 768px) {
    .scraper-buttons {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-item {
        justify-content: space-between;
    }
}

/* ========================================
   Case Management Styles
   ======================================== */

.cases-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.cases-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-primary);
}

.cases-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
}

.cases-stats {
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
}

.cases-table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.action-btn {
    padding: 4px 8px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

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

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

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

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

.btn-danger {
    background: var(--error-bg);
    color: var(--error-text);
}

.btn-danger:hover {
    background: var(--error-bg-hover);
}

/* Case Details Modal */
.case-details {
    max-width: 100%;
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-primary);
}

.case-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
}

.case-status {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-closed {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-dismissed {
    background: var(--error-bg);
    color: var(--error-text);
}

.case-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.info-section {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
}

.info-section h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.info-section dl {
    margin: 0;
}

.info-section dt {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.info-section dd {
    margin: 0 0 12px 0;
    color: var(--text-primary);
}

/* Form Styles */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-input {
    padding: 10px 12px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-light);
}

.form-textarea {
    padding: 10px 12px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-light);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-primary);
}

/* Status Messages */
.status-message {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.status-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.status-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.status-info {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}

.status-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

/* Responsive Design for Case Management */
@media (max-width: 768px) {
    .cases-container {
        padding: 10px;
    }

    .cases-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .case-info-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ========================================
   Authentication Styles
   ======================================== */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--border-primary);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.password-input-container {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition-base);
}

.password-toggle:hover {
    color: var(--text-secondary);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    position: relative;
    background: var(--bg-secondary);
    transition: background-color var(--transition-base);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.forgot-password-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.forgot-password-link:hover {
    text-decoration: underline;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-primary);
}

.auth-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-link:hover {
    text-decoration: underline;
}

/* Profile Styles */
.profile-section {
    margin-bottom: 2rem;
}

.profile-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.security-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.security-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

.security-icon {
    font-size: 1.5rem;
    color: var(--accent-primary);
    margin-top: 0.25rem;
}

.security-details h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.security-details p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Responsive Authentication */
@media (max-width: 640px) {
    .auth-container {
        padding: 1rem;
    }

    .auth-card {
        padding: 2rem 1.5rem;
    }

    .auth-header h1 {
        font-size: 1.75rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* Document Search Options */
.search-options {
    display: flex;
    align-items: center;
    margin-right: 0.5rem;
}

.search-checkbox {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.search-checkbox input[type="checkbox"] {
    margin-right: 0.25rem;
}

.header-btn-danger {
    background-color: var(--error-color);
    color: white;
}

.header-btn-danger:hover {
    background-color: var(--error-hover);
    transform: translateY(-1px);
}
.evidence-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.evidence-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.evidence-summary {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.evidence-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    background: var(--bg-secondary);
}

.evidence-section h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.evidence-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.timeline-item {
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent-primary);
}

.evidence-facts {
    list-style: none;
    padding: 0;
    margin: 0;
}

.evidence-facts li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.5;
}

.evidence-facts li:last-child {
    border-bottom: none;
}

.evidence-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.evidence-details p {
    margin: 0;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent-secondary);
}

.tampering-analysis {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.4;
}

/* Case Documents Styles */
.case-documents-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.document-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    background: var(--bg-secondary);
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.document-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.document-chunks {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.document-meta {
    margin-bottom: 1rem;
}

.document-meta p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.document-actions {
    display: flex;
    gap: 0.5rem;
}

/* ========================================
   Docket Management Styles
   ======================================== */

.dockets-container {
    padding: 1rem;
}

.dockets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.dockets-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.dockets-stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dockets-stats #total-dockets {
    font-weight: 600;
    color: var(--accent-primary);
}

.dockets-table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.docket-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.detail-row label {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 120px;
    flex-shrink: 0;
}

.detail-row span {
    color: var(--text-secondary);
    flex: 1;
    word-wrap: break-word;
}

/* Action buttons for docket table */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-small:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

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

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

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

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

/* Modal enhancements for docket details */
.modal-large {
    max-width: 800px;
    width: 90vw;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: var(--bg-secondary);
}

/* Responsive adjustments for docket management */
@media (max-width: 768px) {
    .dockets-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .detail-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .detail-row label {
        min-width: auto;
        font-weight: 500;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.125rem;
    }
}

/* ========================================
   Cost Tracking Section
   ======================================== */
.cost-tracking-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}

.cost-tracking-section h3 {
    color: white;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
}

.cost-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cost-stat-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    backdrop-filter: blur(10px);
}

.cost-stat-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-stat-value {
    color: white;
    font-size: 18px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.cost-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-badge.cost-free {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
}

.cost-badge.cost-paid {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

#view-detailed-costs {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
}

#view-detailed-costs:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ========================================
   System Messages
   ======================================== */
.system-message {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    margin: 16px auto;
    max-width: 800px;
    background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
    border-left: 4px solid #0288d1;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.system-message .message-avatar {
    font-size: 20px;
    flex-shrink: 0;
}

.system-message .message-wrapper {
    flex: 1;
}

.system-message .message-content {
    color: #01579b;
    font-size: 14px;
    line-height: 1.6;
}

.system-message .message-content strong {
    color: #004d40;
    font-weight: 600;
}

/* ========================================
   Unified Search Results
   ======================================== */
.unified-result {
    border-left: 4px solid #ccc;
}

.source-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 12px;
}

.source-badge.source-document {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.source-badge.source-chat {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.source-badge.source-email {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.result-highlights .highlight {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.6;
}

.result-highlights .highlight strong {
    background: #ffc107;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 700;
}

.search-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.search-stats span {
    color: #495057;
}

.search-stats strong {
    color: #212529;
    font-weight: 600;
}

/* ========================================
   Chat History Widget Overlay
   ======================================== */
.chat-history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.chat-history-overlay.active {
    display: flex;
}

.chat-history-panel {
    background: var(--bg-primary, #ffffff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
}

.chat-history-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #111827);
}

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

.chat-history-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--primary-color, #3b82f6);
    color: white;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.chat-history-actions button:hover {
    background: var(--primary-hover, #2563eb);
}

.chat-history-actions .close-btn {
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-primary, #111827);
}

.chat-history-actions .close-btn:hover {
    background: #d1d5db;
}

.chat-history-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.chat-history-sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color, #e5e7eb);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary, #f9fafb);
}

.chat-history-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.chat-history-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-primary, #ffffff);
}

.chat-history-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    transition: all 0.2s;
}

.conversation-item:hover {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.conversation-item.selected {
    border-color: var(--primary-color, #3b82f6);
    background: rgba(59, 130, 246, 0.05);
}

.conversation-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 4px;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-tertiary, #6b7280);
    margin-bottom: 8px;
}

.conversation-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.topic-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-secondary, #4b5563);
}

.chat-history-detail {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.conversation-summary-section {
    margin-bottom: 24px;
}

.conversation-summary-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary, #4b5563);
}

.entity-list, .action-list, .decision-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entity-item, .action-item, .decision-item {
    padding: 12px;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color, #3b82f6);
}

.entity-type, .action-status {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--primary-color, #3b82f6);
    margin-bottom: 4px;
}

.entity-value, .action-task, .decision-text {
    font-size: 14px;
    color: var(--text-primary, #111827);
}

.action-context, .decision-context {
    font-size: 12px;
    color: var(--text-tertiary, #6b7280);
    margin-top: 4px;
}

.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color, #e5e7eb);
}

.timeline-item {
    position: relative;
    padding-bottom: 16px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color, #3b82f6);
}

.timeline-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color, #3b82f6);
    margin-bottom: 4px;
}

.timeline-event {
    font-size: 14px;
    color: var(--text-secondary, #4b5563);
}

/* Workspace Launcher */
.workspace-launcher-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 10px 16px;
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.workspace-launcher-btn:hover {
    background: var(--primary-hover, #2563eb);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
