﻿/* ========================================
   DOCUMENTS INDEX PAGE - SPECIFIC STYLES
   Enterprise-grade UI/UX patterns
   Aligned with Orders Index design system
   ======================================== */

/* ========================================
   PROCESSING STATUS LEGEND BAR (above stats)
   ======================================== */
.urgency-legend-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 20px;
    margin: 0 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid var(--color-border-subtle, #e5e7eb);
    border-radius: 8px;
    font-size: 0.75rem;
}

.urgency-legend-title {
    font-weight: 600;
    color: var(--color-text-secondary, #6b7280);
    display: flex;
    align-items: center;
    gap: 6px;
}

.urgency-legend-title i {
    color: var(--color-primary-500, #3b82f6);
    font-size: 0.75rem;
}

.urgency-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-secondary, #6b7280);
    padding: 3px 10px;
    background: var(--color-bg-card, #ffffff);
    border-radius: 4px;
    border: 1px solid var(--color-border-subtle, #e5e7eb);
}

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

.urgency-dot.success {
    background: #10b981;
}

.urgency-dot.neutral {
    background: #6b7280;
}

.urgency-dot.warning {
    background: #f59e0b;
}

.urgency-dot.danger {
    background: #ef4444;
}

/* Dark mode urgency legend bar */
[data-theme="dark"] .urgency-legend-bar {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.08) 0%, rgba(167, 139, 250, 0.08) 100%);
    border-color: #30363d;
}

[data-theme="dark"] .urgency-legend-title i {
    color: #58a6ff;
}

[data-theme="dark"] .urgency-legend-item {
    background: #21262d;
    border-color: #30363d;
}

/* ========================================
   STATS URGENCY BADGES
   Shows warning/failed counts inside stat cards
   ======================================== */
.stat-urgency-badges {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.stat-urgency-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.stat-urgency-badge.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.stat-urgency-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.stat-urgency-badge i {
    font-size: 0.625rem;
}

/* Dark mode stat urgency badges */
[data-theme="dark"] .stat-urgency-badge.danger {
    background: rgba(248, 81, 73, 0.2);
    color: #f85149;
}

[data-theme="dark"] .stat-urgency-badge.warning {
    background: rgba(210, 153, 34, 0.2);
    color: #d29922;
}

/* ========================================
   AI SMART SEARCH - Natural Language Input
   ======================================== */
.smart-search-container {
    position: relative;
    padding: 16px 24px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-bottom: 1px solid #bae6fd;
}

.smart-search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 16px;
    background: #ffffff;
    border: 2px solid #bae6fd;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.1);
}

.smart-search-bar:hover {
    border-color: #38bdf8;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.smart-search-bar:focus-within {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15), 0 4px 12px rgba(14, 165, 233, 0.2);
}

.smart-search-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

.smart-search-bar:focus-within .smart-search-icon {
    animation: magicPulse 1.5s ease-in-out infinite;
}

@keyframes magicPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 4px 12px rgba(139, 92, 246, 0.5); }
}

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

.smart-search-input::placeholder {
    color: #64748b;
    font-weight: 400;
}

.smart-search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.smart-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

.smart-search-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.smart-search-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.smart-search-help-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.smart-search-help-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

/* Smart Search Help Panel */
.smart-search-help {
    max-width: 900px;
    margin: 12px auto 0;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e0f2fe;
    border-radius: 10px;
    animation: helpSlideDown 0.2s ease;
}

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

.smart-search-help-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 10px;
}

.smart-search-help-header i {
    color: #f59e0b;
}

.smart-search-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.smart-search-example {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.smart-search-example:hover {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #0369a1;
}

.smart-search-example i {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Smart Search Result */
.smart-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 900px;
    margin: 12px auto 0;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    border-radius: 10px;
}

.smart-search-result-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fbbf24;
    border-radius: 8px;
    color: #78350f;
    font-size: 0.875rem;
}

.smart-search-result-text {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: #78350f;
}

.smart-search-result-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(120, 53, 15, 0.1);
    border: none;
    border-radius: 6px;
    color: #78350f;
    cursor: pointer;
    transition: all 0.15s ease;
}

.smart-search-result-close:hover {
    background: rgba(120, 53, 15, 0.2);
}

/* Dark mode Smart Search */
[data-theme="dark"] .smart-search-container {
    background: linear-gradient(135deg, #0c1929 0%, #0f172a 100%);
    border-color: #1e3a5f;
}

[data-theme="dark"] .smart-search-bar {
    background: #1a1f2e;
    border-color: #1e3a5f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .smart-search-bar:hover {
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

[data-theme="dark"] .smart-search-bar:focus-within {
    border-color: #a78bfa;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2), 0 4px 12px rgba(139, 92, 246, 0.25);
}

[data-theme="dark"] .smart-search-input {
    color: #e2e8f0;
}

[data-theme="dark"] .smart-search-input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .smart-search-help-btn {
    background: #242b3d;
    border-color: #3d4654;
    color: #94a3b8;
}

[data-theme="dark"] .smart-search-help-btn:hover {
    background: #2a3244;
    color: #e2e8f0;
}

[data-theme="dark"] .smart-search-help {
    background: #1a1f2e;
    border-color: #2d3544;
}

[data-theme="dark"] .smart-search-help-header {
    color: #94a3b8;
}

[data-theme="dark"] .smart-search-example {
    background: #242b3d;
    border-color: #3d4654;
    color: #e2e8f0;
}

[data-theme="dark"] .smart-search-example:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: #7c3aed;
    color: #a78bfa;
}

[data-theme="dark"] .smart-search-result {
    background: linear-gradient(135deg, #422006 0%, #78350f 100%);
    border-color: #92400e;
}

[data-theme="dark"] .smart-search-result-icon {
    background: #fbbf24;
    color: #78350f;
}

[data-theme="dark"] .smart-search-result-text {
    color: #fef3c7;
}

[data-theme="dark"] .smart-search-result-close {
    background: rgba(255, 255, 255, 0.1);
    color: #fcd34d;
}

[data-theme="dark"] .smart-search-result-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   CHARTS SECTION - COMPACT SINGLE ROW
   ======================================== */
.charts-section {
    border-bottom: 1px solid var(--color-border-subtle);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    margin-bottom: 0;
}

.charts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--color-border-subtle);
}

.charts-header:hover {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
}

.charts-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--color-text-primary);
}

.charts-header-left i {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    color: var(--color-primary-600);
    font-size: 1rem;
}

.charts-toggle-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-subtle);
    border-radius: 8px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8125rem;
}

.charts-toggle-btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary-500);
    color: var(--color-primary-500);
}

.charts-content {
    display: none;
    padding: 20px 24px;
    background: #ffffff;
    animation: slideDown 0.2s ease;
}

.charts-content.show {
    display: block;
}

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

/* Charts in single row - 3 columns */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Chart Card - Matching stat-card style */
.chart-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.chart-card:hover {
    background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
    border-color: var(--color-primary-200);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.chart-card-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-subtle);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.chart-card-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-card-header h4 i {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: var(--color-primary-600);
    font-size: 0.875rem;
}

/* Compact chart body */
.chart-card-body {
    padding: 16px;
    position: relative;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.chart-card-body canvas {
    max-height: 150px !important;
    max-width: 100% !important;
}

/* Charts Toggle Icon Rotation */
.charts-section.collapsed #chartsChevron {
    transform: rotate(0deg);
}

.charts-section:not(.collapsed) #chartsChevron {
    transform: rotate(180deg);
}

#chartsChevron {
    transition: transform 0.2s ease;
}

/* Responsive Charts - stack on smaller screens */
@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-card:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-card:last-child {
        grid-column: auto;
    }
    
    .chart-card-body {
        height: 160px;
    }
    
    .urgency-legend-bar {
        margin: 0 12px;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .urgency-legend-title {
        width: 100%;
        margin-bottom: 4px;
    }
}

/* Dark Mode Charts */
[data-theme="dark"] .charts-section {
    border-color: #30363d !important;
    background: linear-gradient(180deg, #21262d 0%, #1a1f2e 100%) !important;
}

[data-theme="dark"] .charts-header {
    background: linear-gradient(180deg, #1c2128 0%, #161b22 100%) !important;
    border-color: #30363d !important;
}

[data-theme="dark"] .charts-header:hover {
    background: linear-gradient(180deg, #21262d 0%, #1c2128 100%) !important;
}

[data-theme="dark"] .charts-header-left {
    color: #e6edf3 !important;
}

[data-theme="dark"] .charts-header-left i {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15) 0%, rgba(88, 166, 255, 0.1) 100%) !important;
    border-color: rgba(88, 166, 255, 0.3) !important;
    color: #58a6ff !important;
}

[data-theme="dark"] .charts-toggle-btn {
    background: #21262d !important;
    border-color: #30363d !important;
    color: #8b949e !important;
}

[data-theme="dark"] .charts-toggle-btn:hover {
    background: #30363d !important;
    border-color: #58a6ff !important;
    color: #58a6ff !important;
}

[data-theme="dark"] .charts-content {
    background: #161b22 !important;
}

[data-theme="dark"] .chart-card {
    background: linear-gradient(135deg, #21262d 0%, #1a1f2e 100%) !important;
    border-color: #30363d !important;
    box-shadow: none !important;
}

[data-theme="dark"] .chart-card:hover {
    background: linear-gradient(135deg, #2a3244 0%, #21262d 100%) !important;
    border-color: #3d4654 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .chart-card-header {
    background: linear-gradient(180deg, #21262d 0%, #1c2128 100%) !important;
    border-color: #30363d !important;
}

[data-theme="dark"] .chart-card-header h4 {
    color: #e6edf3 !important;
}

[data-theme="dark"] .chart-card-header h4 i {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15) 0%, rgba(88, 166, 255, 0.1) 100%) !important;
    border-color: rgba(88, 166, 255, 0.3) !important;
    color: #58a6ff !important;
}

[data-theme="dark"] .chart-card-body {
    background: #161b22 !important;
}

/* ========================================
   SAVED VIEWS - CONSISTENT STYLING
   ======================================== */

/* Save View Inline Button */
.save-view-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px dashed var(--color-success-500, #22c55e);
    border-radius: var(--radius-md, 8px);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-success-600, #16a34a);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.save-view-inline-btn:hover {
    background: var(--color-success-50, #f0fdf4);
    border-style: solid;
    border-color: var(--color-success-500, #22c55e);
    color: var(--color-success-700, #15803d);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}

.save-view-inline-btn:hover i {
    animation: bookmarkBounce 0.4s ease;
}

.save-view-inline-btn:active {
    transform: translateY(0);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

@keyframes bookmarkBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Saved Views Menu Button */
.saved-views-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--color-border-subtle, #e2e8f0);
    border-radius: var(--radius-md, 8px);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.saved-views-menu-btn:hover {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-color: var(--color-primary-300, #93c5fd);
    color: var(--color-primary-600, #2563eb);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
    transform: translateY(-1px);
}

.saved-views-menu-btn.active {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: var(--color-primary-500, #3b82f6);
    color: var(--color-primary-700, #1d4ed8);
    box-shadow: var(--shadow-sm), 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.saved-views-menu-text {
    font-weight: 500;
}

.saved-views-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--color-bg-active, #e2e8f0);
    border-radius: 9px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--color-text-secondary, #64748b);
}

.saved-views-count.has-views {
    background: var(--color-primary-100, #dbeafe);
    color: var(--color-primary-700, #1d4ed8);
}

.saved-views-chevron {
    font-size: 0.625rem;
    transition: transform 0.2s ease;
}

.saved-views-menu-btn.active .saved-views-chevron {
    transform: rotate(180deg);
}

/* Saved Views Dropdown */
.saved-views-dropdown {
    min-width: 300px;
}

.saved-views-list {
    max-height: 300px;
    overflow-y: auto;
}

.saved-views-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-tertiary, #94a3b8);
}

.saved-views-empty i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    opacity: 0.5;
}

.saved-views-empty-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-secondary, #64748b);
    margin-bottom: 4px;
}

.saved-views-empty-text {
    font-size: 0.75rem;
}

.saved-view-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--color-border-muted, #f1f5f9);
}

.saved-view-item:last-child {
    border-bottom: none;
}

.saved-view-item:hover {
    background: var(--color-bg-hover, #f1f5f9);
}

.saved-view-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 8px;
    color: var(--color-primary-600, #2563eb);
    font-size: 0.75rem;
}

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

.saved-view-item-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-primary, #0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-view-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--color-text-tertiary, #94a3b8);
    margin-top: 2px;
}

.saved-view-item-delete {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--color-text-tertiary, #94a3b8);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
}

.saved-view-item:hover .saved-view-item-delete {
    opacity: 1;
}

.saved-view-item-delete:hover {
    background: var(--color-danger-50, #fef2f2);
    color: var(--color-danger-500, #ef4444);
}

/* Dark mode saved views */
[data-theme="dark"] .save-view-inline-btn {
    border-color: #4ade80;
    color: #4ade80;
}

[data-theme="dark"] .save-view-inline-btn:hover {
    background: rgba(74, 222, 128, 0.15);
    color: #86efac;
}

[data-theme="dark"] .saved-views-menu-btn {
    background: linear-gradient(180deg, #21262d 0%, #1c2128 100%);
    border-color: #30363d;
    color: #8b949e;
}

[data-theme="dark"] .saved-views-menu-btn:hover {
    background: linear-gradient(180deg, #2a3244 0%, #21262d 100%);
    border-color: #58a6ff;
    color: #79c0ff;
}

[data-theme="dark"] .saved-views-menu-btn.active {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15) 0%, rgba(88, 166, 255, 0.1) 100%);
    border-color: #58a6ff;
    color: #79c0ff;
}

[data-theme="dark"] .saved-views-count {
    background: #30363d;
    color: #6e7681;
}

[data-theme="dark"] .saved-views-count.has-views {
    background: rgba(88, 166, 255, 0.2);
    color: #79c0ff;
}

[data-theme="dark"] .saved-view-item:hover {
    background: #30363d;
}

[data-theme="dark"] .saved-view-item-icon {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15) 0%, rgba(88, 166, 255, 0.1) 100%);
    color: #58a6ff;
}

[data-theme="dark"] .saved-view-item-name {
    color: #e6edf3;
}

[data-theme="dark"] .saved-view-item-delete:hover {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
}

/* ========================================
   SORTING INDICATOR BAR
   ======================================== */
.sorting-indicator-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 0 8px 8px 0;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(139, 92, 246, 0.04) 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    font-size: 13px;
    position: relative;
}

.sorting-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.sorting-label i {
    color: #8b5cf6;
    font-size: 12px;
}

.sorting-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 10px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
    box-shadow: 0 1px 3px rgba(139, 92, 246, 0.3);
}

.sorting-chip-field {
    /* Field name */
}

.sorting-chip-order {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
}

.sorting-separator {
    color: #8b5cf6;
    font-weight: 600;
    font-size: 11px;
    opacity: 0.7;
}

.sorting-chip-direction {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 10px;
}

.sorting-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: white;
    opacity: 0.8;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sorting-chip-remove:hover {
    background: rgba(255, 255, 255, 0.3);
    opacity: 1;
    color: white;
}

.sorting-clear-all {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-left: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--color-danger, #ef4444);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sorting-clear-all:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger, #ef4444);
}

.sorting-clear-all i {
    font-size: 11px;
}

/* Dark mode sorting */
[data-theme="dark"] .sorting-indicator-bar {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(139, 92, 246, 0.3);
}

[data-theme="dark"] .sorting-chip {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
}

/* ========================================
   FILTER SECTION LABELS
   ======================================== */
.filter-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-tertiary, #94a3b8);
    margin-bottom: 10px;
    padding-left: 4px;
}

/* ===== Document Cell ===== */
.document-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.document-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    font-size: 1rem;
}

.document-icon.court-decision {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.2));
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.document-icon.law {
    background: linear-gradient(135deg, var(--color-primary-50), var(--color-primary-100));
    color: var(--color-primary-600);
    border: 1px solid var(--color-primary-100);
}

.document-icon.contract {
    background: linear-gradient(135deg, var(--color-success-50), var(--color-success-100));
    color: var(--color-success-600);
    border: 1px solid var(--color-success-100);
}

.document-icon.claim {
    background: linear-gradient(135deg, var(--color-warning-50), var(--color-warning-100));
    color: var(--color-warning-600);
    border: 1px solid var(--color-warning-100);
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-number {
    display: block;
    font-weight: 600;
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.document-number:hover {
    color: var(--color-primary-600);
}

.document-title {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Document Type Badge ===== */
.document-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.document-type-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.document-type-badge.court-decision {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.15));
    border-color: rgba(139, 92, 246, 0.3);
    color: #8b5cf6;
}

.document-type-badge.law {
    background: linear-gradient(135deg, var(--color-primary-50), var(--color-primary-100));
    border-color: var(--color-primary-200);
    color: var(--color-primary-700);
}

.document-type-badge.contract {
    background: linear-gradient(135deg, var(--color-success-50), var(--color-success-100));
    border-color: var(--color-success-200);
    color: var(--color-success-700);
}

.document-type-badge.claim {
    background: linear-gradient(135deg, var(--color-warning-50), var(--color-warning-100));
    border-color: var(--color-warning-200);
    color: var(--color-warning-700);
}

.document-type-badge.badge-sm {
    padding: 3px 8px;
    font-size: 0.6875rem;
}

/* ===== Confidence Indicator ===== */
.confidence-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: var(--color-bg-active);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.confidence-fill.high {
    background: linear-gradient(90deg, var(--color-success-400), var(--color-success-500));
}

.confidence-fill.medium {
    background: linear-gradient(90deg, var(--color-warning-400), var(--color-warning-500));
}

.confidence-fill.low {
    background: linear-gradient(90deg, var(--color-danger-400), var(--color-danger-500));
}

.confidence-text {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 36px;
    text-align: right;
}

.confidence-text.high {
    color: var(--color-success-600);
}

.confidence-text.medium {
    color: var(--color-warning-600);
}

.confidence-text.low {
    color: var(--color-danger-600);
}

/* ===== Citations Count ===== */
.citations-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background: linear-gradient(135deg, var(--color-primary-50), var(--color-primary-100));
    border: 1px solid var(--color-primary-200);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-primary-700);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 16px 24px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
}

.stats-grid-5cols {
    grid-template-columns: repeat(5, 1fr);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, var(--color-bg-secondary) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card-compact {
    padding: 12px 16px;
}

.stat-card-highlight {
    border-color: var(--color-success-200);
    background: linear-gradient(135deg, var(--color-success-50), #ffffff);
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
}

.stat-icon.primary {
    background: linear-gradient(135deg, var(--color-primary-100), var(--color-primary-50));
    color: var(--color-primary-600);
    border: 1px solid var(--color-primary-200);
}

.stat-icon.success {
    background: linear-gradient(135deg, var(--color-success-100), var(--color-success-50));
    color: var(--color-success-600);
    border: 1px solid var(--color-success-200);
}

.stat-icon.warning {
    background: linear-gradient(135deg, var(--color-warning-100), var(--color-warning-50));
    color: var(--color-warning-600);
    border: 1px solid var(--color-warning-200);
}

.stat-icon.danger {
    background: linear-gradient(135deg, var(--color-danger-100), var(--color-danger-50));
    color: var(--color-danger-600);
    border: 1px solid var(--color-danger-200);
}

.stat-icon.secondary {
    background: linear-gradient(135deg, var(--color-bg-hover), var(--color-bg-secondary));
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
}

/* ===== Filter Dropdown Styles ===== */
.dropdown-menu-filters {
    min-width: 320px;
}

.filter-options-list {
    max-height: 400px;
    overflow-y: auto;
}

.filter-option-item {
    border-bottom: 1px solid var(--color-border);
}

.filter-option-item:last-child {
    border-bottom: none;
}

.filter-option-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.filter-option-header:hover {
    background: var(--color-bg-hover);
}

.filter-option-header i:first-child {
    width: 20px;
    text-align: center;
    color: var(--color-text-tertiary);
}

.filter-option-header span {
    flex: 1;
    font-weight: 500;
    color: var(--color-text-primary);
}

.filter-chevron {
    transition: transform 0.2s ease;
    color: var(--color-text-tertiary);
}

.filter-option-item.expanded .filter-chevron {
    transform: rotate(180deg);
}

.filter-option-content {
    display: none;
    padding: 0 16px 16px;
}

.filter-option-item.expanded .filter-option-content {
    display: block;
}

.filter-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-input:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-status-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.filter-status-card {
    cursor: pointer;
}

.filter-status-card input {
    display: none;
}

.status-card-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-primary);
    transition: all 0.15s ease;
}

.filter-status-card:hover .status-card-content {
    background: var(--color-bg-hover);
    border-color: var(--color-border-hover);
}

.filter-status-card input:checked + .status-card-content {
    background: linear-gradient(135deg, var(--color-primary-50), var(--color-primary-100));
    border-color: var(--color-primary-500);
}

.status-card-icon {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    font-size: 0.75rem;
}

.status-card-icon.primary {
    background: var(--color-primary-100);
    color: var(--color-primary-600);
}

.status-card-icon.success {
    background: var(--color-success-100);
    color: var(--color-success-600);
}

.status-card-icon.warning {
    background: var(--color-warning-100);
    color: var(--color-warning-600);
}

.status-card-icon.danger {
    background: var(--color-danger-100);
    color: var(--color-danger-600);
}

.status-card-icon.secondary {
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
}

.status-card-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

/* ===== Column Config ===== */
.columns-config {
    padding: 8px 12px;
}

.column-config-item {
    padding: 6px 0;
}

.column-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.column-checkbox input {
    width: 16px;
    height: 16px;
}

.column-checkbox span {
    font-size: 0.875rem;
    color: var(--color-text-primary);
}

.dropdown-menu-wide {
    min-width: 260px;
}

/* ===== Grid Card Styles ===== */
.grid-card-description {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin: 0 0 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Custom Modal Styles ===== */
.custom-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.custom-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.custom-modal {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.custom-modal.show {
    transform: translateY(0);
}

.custom-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.custom-modal-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-lg);
    font-size: 1.25rem;
}

.custom-modal-icon.info {
    background: var(--color-primary-100);
    color: var(--color-primary-600);
}

.custom-modal-icon.success {
    background: var(--color-success-100);
    color: var(--color-success-600);
}

.custom-modal-icon.warning {
    background: var(--color-warning-100);
    color: var(--color-warning-600);
}

.custom-modal-icon.danger {
    background: var(--color-danger-100);
    color: var(--color-danger-600);
}

.custom-modal-title {
    flex: 1;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.custom-modal-close {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.custom-modal-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.custom-modal-body {
    padding: 20px 24px;
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.custom-modal-body p {
    margin: 0;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
}

.btn-danger {
    background: linear-gradient(180deg, var(--color-danger-500) 0%, var(--color-danger-600) 100%);
    border: 1px solid var(--color-danger-600);
    color: #ffffff;
}

.btn-danger:hover {
    background: linear-gradient(180deg, var(--color-danger-400) 0%, var(--color-danger-500) 100%);
}

/* ===== Sortable Header ===== */
.sortable-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: none;
}

.sortable-header:hover {
    color: var(--color-text-primary);
}

.sortable-header i {
    font-size: 0.625rem;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.sortable-header:hover i {
    opacity: 0.8;
}

/* ===== Row Click Feedback ===== */
.row-click-feedback {
    animation: rowClickPulse 0.2s ease;
}

@keyframes rowClickPulse {
    0% { background: var(--color-primary-100); }
    100% { background: transparent; }
}

/* ===== Stagger Animation ===== */
.stagger-animate tr,
.stagger-animate .grid-card {
    opacity: 0;
    transform: translateY(10px);
    animation: staggerFadeIn 0.3s ease forwards;
}

.stagger-animate tr:nth-child(1),
.stagger-animate .grid-card:nth-child(1) { animation-delay: 0.02s; }
.stagger-animate tr:nth-child(2),
.stagger-animate .grid-card:nth-child(2) { animation-delay: 0.04s; }
.stagger-animate tr:nth-child(3),
.stagger-animate .grid-card:nth-child(3) { animation-delay: 0.06s; }
.stagger-animate tr:nth-child(4),
.stagger-animate .grid-card:nth-child(4) { animation-delay: 0.08s; }
.stagger-animate tr:nth-child(5),
.stagger-animate .grid-card:nth-child(5) { animation-delay: 0.10s; }
.stagger-animate tr:nth-child(6),
.stagger-animate .grid-card:nth-child(6) { animation-delay: 0.12s; }
.stagger-animate tr:nth-child(7),
.stagger-animate .grid-card:nth-child(7) { animation-delay: 0.14s; }
.stagger-animate tr:nth-child(8),
.stagger-animate .grid-card:nth-child(8) { animation-delay: 0.16s; }
.stagger-animate tr:nth-child(9),
.stagger-animate .grid-card:nth-child(9) { animation-delay: 0.18s; }
.stagger-animate tr:nth-child(10),
.stagger-animate .grid-card:nth-child(10) { animation-delay: 0.20s; }
.stagger-animate tr:nth-child(n+11),
.stagger-animate .grid-card:nth-child(n+11) { animation-delay: 0.22s; }

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .stats-grid-5cols {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid-5cols {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filter-status-cards {
        grid-template-columns: 1fr;
    }
}

/* ===== Dark Mode ===== */
[data-theme="dark"] .stat-card {
    background: linear-gradient(180deg, #242b3d 0%, #1a1f2e 100%);
    border-color: #2d3544;
}

[data-theme="dark"] .stat-card-highlight {
    border-color: var(--color-success-800);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), #1a1f2e);
}

[data-theme="dark"] .document-icon.court-decision {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    border-color: rgba(139, 92, 246, 0.3);
}

[data-theme="dark"] .custom-modal {
    background: #1a1f2e;
    border-color: #2d3544;
}

[data-theme="dark"] .custom-modal-footer {
    background: #161b22;
}

