
@import url('variables.css');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-tertiary);
    padding: var(--space-xl);
}

/* ==========================================================================
   Search & Relevance
   ========================================================================== */

.relevance-score {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 6px;
    background: var(--info-light);
    color: var(--info-color);
    border-radius: var(--radius-2xl);
    font-size: 11px;
    font-weight: 600;
}

/* ==========================================================================
   Matter Status Badges
   ========================================================================== */

.matter-status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.matter-status-badge.status-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.matter-status-badge.status-closed {
    background: var(--error-light);
    color: var(--error-color);
}

.matter-status-badge.status-archived {
    background: var(--info-light);
    color: #1565c0;
}

.matter-status-badge.status-deep-archived {
    background: #e1f5fe;
    color: #01579b;
}

/* Archive Warning Banner */
.archive-warning {
    background: var(--warning-muted);
    border: 1px solid #ffc107;
    border-radius: var(--radius-lg);
    padding: 12px 15px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #856404;
}

.archive-warning-icon {
    font-size: 20px;
    flex-shrink: 0;
}

/* Matter card status styling */
.matter-item .matter-status-info,
.matter-compact-item .matter-status-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--space-xs);
}

/* ==========================================================================
   Matter Documents Panel
   ========================================================================== */

.matter-documents-panel {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
}

/* Individual Matter Card */
.matter-result-item {
    padding: var(--space-lg);
    background: var(--bg-white);
    border: 2px solid #e8e8e8;
    border-radius: var(--radius-2xl);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: var(--space-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.matter-result-item:hover {
    background: #f9f9ff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.matter-result-item.selected {
    background: var(--primary-gradient);
    border-color: var(--primary-color);
    color: var(--bg-white);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.matter-result-number span[style*="background"] {
    font-size: 10px !important;
    font-weight: 600 !important;
    padding: 4px 8px !important;
    border-radius: var(--radius-lg) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.matter-result-item.selected .matter-result-number,
.matter-result-item.selected .matter-result-client,
.matter-result-item.selected .matter-result-stats {
    color: var(--bg-white);
}

#search-matter-results {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

#search-matter-results .matter-search-results {
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--radius-md);
    max-height: none !important;
}

#search-matter-input:read-only {
    background: #f0f4ff;
    border-color: var(--primary-color);
}

/* ==========================================================================
   Date & Filter Styling
   ========================================================================== */

.quick-filters input[type="date"] {
    cursor: pointer;
}

.quick-filters input[type="date"]:focus {
    outline: none;
}

/* Type column styling */
table td:first-child,
table th:first-child {
    text-align: center;
    width: 50px;
}

/* Version column */
table td:nth-child(3),
table th:nth-child(3) {
    width: 80px;
    text-align: center;
}

/* ==========================================================================
   Dropdown Menus
   ========================================================================== */

.dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1000;
    margin-bottom: 0;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 14px;
}

.dropdown-menu a:hover {
    background: var(--bg-tertiary);
}

.dropdown-menu a:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dropdown-menu a:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: var(--z-modal-overlay);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-white);
    padding: 15px 20px;
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 500px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
}

.toast.success {
    border-left-color: var(--active-green);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
}

.toast-close {
    cursor: pointer;
    color: var(--text-placeholder);
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ==========================================================================
   Email Routing Styles
   ========================================================================== */

.routing-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 15px;
}

.routing-panel-header h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 16px;
}

.email-address-item {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.email-address-item:hover {
    background: #f9f9ff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.email-address-item.selected {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.email-address-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.email-address-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.email-type-badge {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.email-type-badge.client {
    background: var(--email-client-bg);
    color: var(--email-client-color);
}

.email-type-badge.attorney_internal {
    background: var(--email-attorney-internal-bg);
    color: var(--email-attorney-internal-color);
}

.email-type-badge.attorney_external {
    background: var(--email-attorney-external-bg);
    color: var(--email-attorney-external-color);
}

.email-type-badge.vendor {
    background: var(--email-vendor-bg);
    color: var(--email-vendor-color);
}

.email-type-badge.spam {
    background: var(--email-spam-bg);
    color: var(--email-spam-color);
}

.email-type-badge.unknown {
    background: var(--email-unknown-bg);
    color: var(--email-unknown-color);
}

.email-status-indicators {
    display: flex;
    gap: 5px;
    font-size: 12px;
}

.email-actions-row {
    display: flex;
    gap: 5px;
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.mapping-item {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: 10px;
    transition: all var(--transition-fast);
}

.mapping-item.inactive {
    opacity: 0.6;
    background: var(--bg-muted);
}

.mapping-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.mapping-matter {
    font-weight: 600;
    color: var(--text-primary);
}

.mapping-source-badge {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
}

.mapping-source-badge.manual_association {
    background: var(--email-client-bg);
    color: var(--email-client-color);
}

.mapping-source-badge.clio_api {
    background: var(--email-attorney-external-bg);
    color: var(--email-attorney-external-color);
}

.mapping-source-badge.auto_learned {
    background: var(--email-attorney-internal-bg);
    color: var(--email-attorney-internal-color);
}

.mapping-source-badge.csv_import {
    background: var(--email-vendor-bg);
    color: var(--email-vendor-color);
}

.mapping-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.mapping-actions {
    display: flex;
    gap: 5px;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.status-indicator {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--radius-2xl);
    font-size: 11px;
    font-weight: 600;
}

.status-indicator.blocked {
    background: var(--error-light);
    color: var(--error-color);
}

.status-indicator.active {
    background: #e8f5e9;
    color: #388e3c;
}

.status-indicator.primary {
    background: var(--email-attorney-external-bg);
    color: var(--email-attorney-external-color);
}

.stat-box {
    background: #f8f9ff;
    padding: 15px;
    border-radius: var(--radius-xl);
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 5px;
}

/* ==========================================================================
   Form Styles
   ========================================================================== */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-placeholder);
    font-size: 12px;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition-normal);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: var(--space-xl);
}

/* ==========================================================================
   Simple Search Styles
   ========================================================================== */

.simple-search-container {
    max-width: none;
    margin: 0;
    padding: var(--space-xl) 0;
}

.search-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.simple-search-input {
    flex: 1;
    padding: 14px 20px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    transition: border-color var(--transition-normal);
}

.simple-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

.search-btn {
    padding: 14px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
}

/* Entity Type Selector */
.entity-type-selector {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    margin-bottom: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 6px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-label:hover {
    color: var(--primary-color);
}

/* Advanced Search Toggle */

.advanced-filters {
    margin-top: 20px;
    margin-bottom: 20px;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    max-width: 400px; /* Optional: keeps fields from stretching too wide */
}

.advanced-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 14px;
    padding: var(--space-sm);
    display: block;
    margin: 0 auto;
    transition: color var(--transition-normal);
}

.advanced-toggle:hover {
    color: var(--primary-hover);
}

/* Advanced Search Section */
.advanced-search-section {
    margin-top: var(--space-3xl);
    padding-top: var(--space-3xl);
    border-top: 2px solid var(--border-color);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter Grid */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-top: var(--space-xl);
}

.filter-section {
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
}

.filter-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    margin: 0 0 15px 0;
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--border-color);
}

/* Hide irrelevant sections based on selection */
body.search-documents-only #email-filters,
body.search-emails-only #document-filters {
    opacity: 0.5;
    pointer-events: none;
}

/* Quick filters styling */
.quick-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: var(--space-xl);
}

.quick-filter {
    padding: 8px 14px;
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 13px;
}

.quick-filter:hover {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.quick-filter.active {
    background: var(--primary-color);
    color: var(--bg-white);
    border-color: var(--primary-color);
}

/* Results table - Type column styling */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: #f0f4ff;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}

.type-badge.type-document {
    background: var(--email-client-bg);
    color: var(--email-client-color);
}

.type-badge.type-email {
    background: #fce4ec;
    color: #c2185b;
}

/* ==========================================================================
   Upload Section Styles
   ========================================================================== */

#drop-zone {
    transition: all var(--transition-normal);
}

#drop-zone:hover {
    border-color: var(--primary-hover);
    background: #f9f9ff;
}

#drop-zone.drag-over {
    border-color: var(--primary-color);
    background: #f0f4ff;
    transform: scale(1.02);
}

.file-item {
    transition: background var(--transition-fast);
}

.file-item:hover {
    background: #f9f9ff;
}

#file-queue,
#upload-progress {
    animation: slideDown 0.3s ease-out;
}

/* Progress bar animation */
@keyframes progressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.uploading-bar {
    animation: progressPulse 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 1024px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .simple-search-input {
        font-size: 14px;
        padding: 12px 16px;
    }

    .entity-type-selector {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

/* ==========================================================================
   Matter Content Tabs
   ========================================================================== */

.matter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--border-color);
}

.matter-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all var(--transition-normal);
}

.matter-tab:hover {
    color: var(--primary-color);
}

.matter-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.matter-tab-content {
    display: none;
}

.matter-tab-content.active {
    display: block;
}

/* Email list styles */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.email-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.email-item:hover {
    background: #f9f9ff;
    border-color: var(--primary-color);
}

.email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.email-sender {
    font-weight: 600;
    color: var(--text-primary);
}

.email-date {
    font-size: 12px;
    color: var(--text-placeholder);
}

.email-subject {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.email-meta {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: var(--text-placeholder);
}

.attachment-indicator {
    background: #f0f4ff;
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: var(--radius-2xl);
    font-size: 11px;
}

/* ==========================================================================
   Login Styles
   ========================================================================== */

#login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--primary-gradient);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

.login-box {
    background: var(--bg-white);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: var(--space-3xl);
    font-size: 28px;
}

.login-box input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: var(--space-xl);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-xl);
    font-size: 14px;
    transition: border-color var(--transition-normal);
}

.login-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: var(--bg-white);
    border: none;
    border-radius: var(--radius-xl);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-normal);
}

.login-box button:hover {
    background: var(--primary-hover);
}

.login-error {
    color: #e53e3e;
    text-align: center;
    margin-bottom: 15px;
    font-size: 14px;
}

.matter-type-badge {
    background: #f0f4ff;
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.matter-description {
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matter-stats {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* ==========================================================================
   User Info Styles
   ========================================================================== */

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 20px;
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    margin-left: auto;
}

.user-info span {
    font-weight: 600;
    color: var(--text-primary);
}

.user-info button {
    padding: 6px 12px;
    background: #e53e3e;
    color: var(--bg-white);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
    transition: background var(--transition-normal);
}

.user-info button:hover {
    background: #c53030;
}

/* Settings Button */
.settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f0f4ff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    color: var(--primary-color);
}

.settings-btn:hover {
    background: var(--primary-color);
    color: var(--bg-white);
    transform: rotate(180deg);
}

.settings-btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Main App Container
   ========================================================================== */

#app-container {
    display: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    background: var(--bg-white);
    padding: var(--space-xl);
    border-radius: var(--radius-2xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    flex: 1;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--border-color);
}

.tab {
    padding: 12px 24px;
    background: var(--bg-white);
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all var(--transition-normal);
}

.tab:hover {
    color: var(--primary-color);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==========================================================================
   Matter Browser Styles
   ========================================================================== */

.matter-browser {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: var(--space-xl);
    height: calc(100vh - 200px);
}

.matter-list-panel {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#matter-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
    height: calc(100vh - 350px);
}

#matter-list .matter-search-results {
    border: none !important;
    background: transparent !important;
    max-height: none !important;
    overflow: visible !important;
}

#matter-list > * {
    margin-top: 0;
}

.matter-search {
    padding: 10px;
    width: 100%;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
}

.matter-search-results {
    max-height: 400px;
    overflow-y: auto;
    border: none;
    border-radius: var(--radius-xl);
    background: transparent;
    padding: var(--space-sm);
}

.matter-recent-section h4 {
    font-size: 12px !important;
    color: var(--text-secondary) !important;
    margin: 10px 0 !important;
    text-transform: none !important;
    font-weight: normal !important;
    display: none !important;
}

.matter-recent-list,
.matter-suggestions-list {
    overflow: visible !important;
    max-height: none !important;
}

.matter-suggestions-section {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

.matter-compact-item {
    padding: var(--space-md);
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-white);
    display: block;
}

.matter-compact-item:hover {
    background: #f9f9ff;
    border-color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.matter-compact-number {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.matter-compact-client {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.matter-compact-docs {
    font-size: 11px;
    color: var(--text-placeholder);
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: var(--radius-2xl);
}

.matter-search-inline {
    padding: 0 !important;
    background: transparent !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.matter-item .matter-description {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: var(--space-xs);
}

.matter-item {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.matter-item:hover {
    background: #f9f9ff;
    border-color: var(--primary-color);
}

.matter-item.selected {
    background: var(--primary-color);
    color: var(--bg-white);
    border-color: var(--primary-color);
}

.matter-item.selected .matter-meta {
    color: rgba(255, 255, 255, 0.9);
}

.matter-number {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: var(--space-xs);
}

.matter-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.document-count {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-pill);
    font-size: 11px;
    margin-left: var(--space-sm);
}

.matter-header-info {
    padding: var(--space-xl);
    background: var(--primary-gradient);
    color: var(--bg-white);
    border-radius: var(--radius-2xl);
    margin-bottom: var(--space-xl);
}

.document-grid {
    display: grid;
    gap: 15px;
}

.document-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 15px;
    transition: all var(--transition-fast);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    align-items: center;
}

.document-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.doc-icon {
    width: 40px;
    height: 40px;
    background: #f0f4ff;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.doc-info {
    flex: 1;
}

.doc-name {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.doc-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.doc-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
}

/* ==========================================================================
   Search Panel Styles
   ========================================================================== */

.search-panel {
    background: transparent;
    padding: 0;
    border-radius: 0;
    margin-bottom: var(--space-xl);
    box-shadow: none;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color var(--transition-normal);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.date-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.search-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-primary {
    background: var(--primary-color);
    color: var(--bg-white);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.results-panel {
    background: var(--bg-white);
    padding: var(--space-xl);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-sm);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-hover);
}

.results-count {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.results-actions {
    display: flex;
    gap: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: var(--space-md);
    background: #f7f7f7;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
    font-size: 12px;
    text-transform: uppercase;
}

td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

tr:hover {
    background: #f9f9ff;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--badge-purple-bg);
    color: var(--badge-purple-color);
    border-radius: var(--radius-pill);
    font-size: 12px;
    margin-right: var(--space-xs);
}

.matter-badge {
    background: var(--badge-amber-bg);
    color: var(--badge-amber-color);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 12px;
}

.client-badge {
    background: var(--badge-blue-bg);
    color: var(--badge-blue-color);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.loading,
.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-placeholder);
    font-size: 16px;
}

.btn-view-pdf {
    background: #4CAF50 !important;
    color: var(--bg-white) !important;
}

.btn-view-pdf:hover {
    background: #45a049 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.action-buttons {
    display: flex;
    gap: 5px;
}

.action-btn {
    padding: 4px 8px;
    background: var(--bg-hover);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: background var(--transition-fast);
}

.action-btn:hover {
    background: var(--border-color);
}

.pdf-indicator {
    color: #d32f2f;
    font-weight: bold;
    margin-left: 5px;
}

.alert-badge {
    background: var(--danger-color);
    color: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: 2px 6px;
    font-size: 11px;
    margin-left: 5px;
    font-weight: bold;
}

/* ==========================================================================
   Alerts Panel
   ========================================================================== */

.alerts-panel {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.alerts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-hover);
}

.alert-filters {
    display: flex;
    gap: 10px;
}

.filter-btn {
    padding: 6px 12px;
    background: var(--bg-hover);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.filter-btn.active {
    background: var(--primary-color);
    color: var(--bg-white);
}

.alert-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 15px;
    margin-bottom: var(--space-md);
    transition: all var(--transition-fast);
}

.alert-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.alert-item.severity-critical {
    border-left: 4px solid var(--danger-color);
}

.alert-item.severity-warning {
    border-left: 4px solid #ffc107;
}

.alert-item.severity-info {
    border-left: 4px solid var(--role-provider);
}

.alert-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.alert-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.alert-timestamp {
    font-size: 12px;
    color: var(--text-placeholder);
}

.alert-message {
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

.alert-metadata {
    background: var(--bg-secondary);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: var(--space-md);
}

.alert-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.alert-actions button {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-resolve {
    background: var(--active-green);
    color: var(--bg-white);
}

.btn-view-details {
    background: var(--primary-color);
    color: var(--bg-white);
}

.btn-dismiss {
    background: var(--secondary-color);
    color: var(--bg-white);
}

.conflict-details {
    background: var(--warning-muted);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
}

.no-alerts {
    text-align: center;
    padding: 40px;
    color: var(--text-placeholder);
}

/* ==========================================================================
   Matter Cards
   ========================================================================== */

.matter-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.matter-card {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 15px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.matter-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.matter-card.selected {
    border-color: var(--primary-color);
    background: #f8f9ff;
}

.matter-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.badge {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-color);
    color: var(--bg-white);
}

.badge-info {
    background: var(--role-provider);
    color: var(--bg-white);
}

.badge-danger {
    background: var(--error-light);
    color: var(--error-color);
}

.badge-warning {
    background: var(--email-attorney-external-bg);
    color: var(--email-attorney-external-color);
}

.clio-badge {
    font-size: 14px;
    cursor: help;
}

.client-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.manual-entry-section {
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-xl);
}

/* ==========================================================================
   Routing Behavior Radio Options
   ========================================================================== */

.routing-options {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 15px;
}

.routing-option {
    display: flex;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.routing-option:hover {
    background: rgba(102, 126, 234, 0.05);
}

.routing-option:last-child {
    margin-bottom: 0;
}

.routing-option input[type="radio"] {
    margin: 3px 12px 0 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.routing-option-content {
    flex: 1;
}

.routing-option-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.routing-option-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ==========================================================================
   Review Tasks Styles
   ========================================================================== */

.review-panel {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-hover);
}

.review-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: #f8f9ff;
    padding: 15px;
    border-radius: var(--radius-xl);
    text-align: center;
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.review-task-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 15px;
    margin-bottom: var(--space-md);
    transition: all var(--transition-fast);
}

.review-task-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.review-task-item.priority-high {
    border-left: 4px solid var(--danger-color);
}

.review-task-item.priority-medium {
    border-left: 4px solid #ffc107;
}

.review-task-item.priority-low {
    border-left: 4px solid var(--active-green);
}

.task-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.task-type-badge {
    background: var(--primary-color);
    color: var(--bg-white);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.confidence-score {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-left: 10px;
}

.confidence-high {
    background: var(--success-light);
    color: var(--success-dark);
}

.confidence-medium {
    background: var(--warning-muted);
    color: #856404;
}

.confidence-low {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.task-suggestion {
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: var(--radius-md);
    margin: 10px 0;
}

.task-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-top: 10px;
}

.btn-claim {
    background: var(--primary-color);
    color: var(--bg-white);
}

.btn-approve {
    background: var(--active-green);
    color: var(--bg-white);
}

.btn-reject {
    background: var(--danger-color);
    color: var(--bg-white);
}

.btn-modify {
    background: #ffc107;
    color: #212529;
}

.btn-defer {
    background: var(--secondary-color);
    color: var(--bg-white);
}

/* ==========================================================================
   Modal Styles
   ========================================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: var(--radius-pill);
    width: 90%;
    max-width: 900px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s;
}

.modal-header {
    padding: 20px 25px;
    background: var(--primary-gradient);
    color: var(--bg-white);
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close {
    color: var(--bg-white);
    font-size: 32px;
    font-weight: normal;
    cursor: pointer;
    line-height: 20px;
    padding: 0;
    transition: transform var(--transition-fast);
}

.close:hover,
.close:focus {
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px;
    max-height: 80vh;
    overflow-y: auto;
}

/* ==========================================================================
   Email Modal Styles
   ========================================================================== */

.email-modal-header {
    background: var(--bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xl);
}

.email-modal-subject {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.email-modal-meta {
    display: grid;
    gap: 10px;
    font-size: 14px;
}

.email-modal-meta-row {
    display: flex;
    gap: 10px;
}

.email-modal-meta-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 80px;
}

.email-modal-meta-value {
    color: var(--text-primary);
    flex: 1;
}

.email-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.recipient-chip {
    background: var(--email-client-bg);
    color: var(--email-client-color);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 12px;
}

.email-modal-body {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-white);
}

.email-body-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.body-toggle-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-input);
    background: var(--bg-white);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
}

.body-toggle-btn.active {
    background: var(--primary-color);
    color: var(--bg-white);
    border-color: var(--primary-color);
}

.email-html-content {
    line-height: 1.6;
}

.email-text-content {
    font-family: monospace;
    white-space: pre-wrap;
    line-height: 1.5;
}

.email-attachments {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 15px;
    margin: var(--space-xl) 0;
}

.email-attachments-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.attachment-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.attachment-name {
    color: var(--text-primary);
    font-size: 14px;
}

.attachment-size {
    color: var(--text-placeholder);
    font-size: 12px;
}

.attachment-status {
    padding: 2px 6px;
    border-radius: var(--radius-2xl);
    font-size: 11px;
    font-weight: 600;
}

.attachment-status.processed {
    background: #e8f5e9;
    color: #2e7d32;
}

.attachment-status.pending {
    background: var(--email-attorney-external-bg);
    color: #ef6c00;
}

.email-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border-color);
}

.email-thread-info {
    background: #fef7e0;
    border: 1px solid #f9e4a1;
    border-radius: var(--radius-lg);
    padding: 10px 15px;
    margin: 15px 0;
    font-size: 13px;
    color: #795548;
}

.email-labels {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.email-label {
    background: #f0f4ff;
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
}

/* ==========================================================================
   Version Modal Styles
   ========================================================================== */

.version-info {
    background: #f8f9ff;
    padding: 15px;
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xl);
    border-left: 4px solid var(--primary-color);
}

.version-info h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 18px;
}

.version-info p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.versions-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 15px;
}

.versions-table th {
    background: #f7f8fc;
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
}

.versions-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #e8e8e8;
    font-size: 14px;
    color: var(--text-primary);
}

.versions-table tbody tr {
    transition: background-color var(--transition-fast);
}

.versions-table tbody tr:hover {
    background-color: #f9f9ff;
}

.versions-table tbody tr.current-version {
    background-color: var(--info-light);
}

.versions-table tbody tr.current-version:hover {
    background-color: #d1e7f8;
}

.version-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 13px;
}

.version-badge.current {
    background: #4caf50;
    color: var(--bg-white);
}

.version-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

.version-status.complete {
    background: #e8f5e9;
    color: #2e7d32;
}

.version-status.pending {
    background: var(--email-attorney-external-bg);
    color: #e65100;
}

.version-status.failed {
    background: var(--error-light);
    color: var(--error-color);
}

.version-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-start;
}

.version-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-download {
    background: var(--primary-color);
    color: var(--bg-white);
}

.btn-download:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.btn-edit {
    background: #48bb78;
    color: var(--bg-white);
}

.btn-edit:hover {
    background: #38a169;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.4);
}

.btn-edit:disabled {
    background: #cbd5e0;
    color: #718096;
    cursor: not-allowed;
    transform: none;
}

.btn-compare {
    background: #ed8936;
    color: var(--bg-white);
}

.btn-compare:hover {
    background: #dd6b20;
    transform: translateY(-1px);
}

.file-size {
    color: #718096;
    font-size: 13px;
}

.loading-versions {
    text-align: center;
    padding: 40px;
    color: var(--text-placeholder);
}

.loading-versions::before {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.no-versions {
    text-align: center;
    padding: 40px;
    color: var(--text-placeholder);
}

.no-versions svg {
    width: 60px;
    height: 60px;
    opacity: 0.3;
    margin-bottom: 15px;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--bg-white);
}

.btn-danger:hover {
    background: #c82333;
}

.deleted-items-table {
    width: 100%;
    border-collapse: collapse;
}

.deleted-items-table th,
.deleted-items-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-input);
}

/* ==========================================================================
   Matter Details Tab Styles
   ========================================================================== */

.matter-details-content {
    padding: var(--space-xl);
}

.matter-details-section {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.matter-details-section h3 {
    margin: 0 0 var(--space-xl) 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.matter-details-section h4 {
    margin: 0 0 15px 0;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Matter Information - Two Column Layout */

.clio-data-panel,
.ibex-data-panel {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-item label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: var(--space-xs);
}

.info-value {
    font-size: 14px;
    color: var(--text-primary);
    padding: 8px 12px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* Email Routing List */

.email-routing-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.email-routing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.email-routing-item:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
}

.routing-email-info {
    flex: 1;
}

.routing-email-address {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.routing-email-address a {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.routing-email-address a:hover {
    text-decoration: underline;
}

.primary-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 8px;
    background: #ffc107;
    color: #000;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
}

.routing-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.routing-meta span {
    margin-right: 10px;
}

/* Permissions List */

.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.permission-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.permission-user-info {
    flex: 1;
}

.permission-user-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.permission-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    color: var(--bg-white);
}

.permission-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.permission-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Statistics Grid */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: var(--space-xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--primary-gradient);
    border-radius: var(--radius-xl);
    color: var(--bg-white);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.stat-icon {
    font-size: 32px;
    opacity: 0.9;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 12px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Document Types List */

.document-types-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.document-type-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.type-name {
    font-weight: 600;
    color: var(--text-primary);
}

.type-count {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-white);
    padding: 2px 8px;
    border-radius: var(--radius-2xl);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .matter-details-section {
        padding: 15px;
    }

    .matter-details-section > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .email-routing-item,
    .permission-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .routing-email-address {
        flex-direction: column;
        align-items: flex-start;
    }

    .permission-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ==========================================================================
   Styles for email search results
   ========================================================================== */

.email-search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-white);
}

.email-search-result-item:hover {
    background: #f8f9ff;
}

.email-search-result-item.selected {
    background: var(--primary-color);
    color: var(--bg-white);
}

.email-result-info {
    flex: 1;
}

.email-result-address {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.email-search-result-item.selected .email-result-address {
    color: var(--bg-white);
}

.email-result-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.email-search-result-item.selected .email-result-meta {
    color: rgba(255, 255, 255, 0.9);
}

.email-search-result-item.selected .email-type-badge {
    background: rgba(255, 255, 255, 0.2);
    color: var(--bg-white);
}

.no-email-results {
    padding: 40px;
    text-align: center;
    color: var(--text-placeholder);
}