/* MemReport Analyzer Styles */

/* Sticky section headers */
.sticky-card-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: inherit;
    border-bottom: 1px solid rgba(0,0,0,.125);
}

/* Section actions alignment */
.memreport-section .section-actions {
    display: flex;
    gap: 0.25rem;
}

/* Table styling */
.memreport-data-table {
    font-size: 0.9rem;
}

.memreport-data-table th.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.memreport-data-table th.sortable-header:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.memreport-data-table th.sortable-header:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* Sort indicators */
.sort-indicator {
    font-size: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.sortable-header:hover .sort-indicator {
    opacity: 1;
}

/* Search and filter styling */
.section-search-filters {
    background-color: #2d3136;
    border: 1px solid #444;
    border-radius: 0.375rem;
    padding: 1rem;
    color: #e0e0e0;
}

.filter-status {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #444;
}

/* Table responsiveness */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
}

/* Memory value formatting */
.memory-value {
    font-family: 'Courier New', monospace;
    text-align: right;
}

/* Chart container */
.chart-container {
    max-height: 500px;
    margin: 1rem 0;
    border: 1px solid #444;
    border-radius: 0.375rem;
    padding: 1rem;
    background-color: #2d3136;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    color: #e0e0e0;
}

.chart-container h6 {
    color: #e0e0e0;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chart-container canvas {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.chart-container canvas:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chart-container canvas:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Chart tooltip */
.chart-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
    z-index: 1000;
    display: none;
    max-width: 250px;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.chart-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
}

/* Chart configuration panel */
.chart-config-panel {
    background-color: #2d3136;
    border: 1px solid #444;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    color: #e0e0e0;
}

.chart-config-panel h6 {
    color: #e0e0e0;
    font-weight: 600;
    margin-bottom: 1rem;
    border-bottom: 1px solid #444;
    padding-bottom: 0.5rem;
}

.chart-config-panel .form-check {
    margin-bottom: 0.75rem;
}

.chart-config-panel .form-check-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.chart-config-panel .form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.chart-config-panel .btn-primary {
    background-color: #007bff;
    border-color: #007bff;
    transition: all 0.2s ease;
}

.chart-config-panel .btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
}

/* Chart export dropdown */
.chart-container .dropdown-menu {
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    background-color: #23272b;
    color: #e0e0e0;
}

.chart-container .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
    color: #e0e0e0;
}

.chart-container .dropdown-item:hover {
    background-color: #2d3136;
    color: #007bff;
}

.chart-container .dropdown-item:focus {
    background-color: #007bff;
    color: white;
    outline: none;
}

/* Chart button group styling */
.chart-container .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.2rem;
    transition: all 0.2s ease;
    background-color: #444;
    border-color: #666;
    color: #e0e0e0;
}

.chart-container .btn-outline-secondary {
    background-color: #444;
    border-color: #666;
    color: #e0e0e0;
}

.chart-container .btn-outline-secondary:hover {
    background-color: #555;
    border-color: #777;
    color: white;
    transform: translateY(-1px);
}

.chart-container .btn-outline-secondary:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Chart interaction feedback */
.chart-container canvas.chart-interactive {
    cursor: crosshair;
}

.chart-container canvas.chart-interactive:hover {
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

/* Chart loading state */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #888;
    font-style: italic;
    background: linear-gradient(90deg, #2d3136 25%, #23272b 50%, #2d3136 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Chart success feedback */
.chart-config-panel .alert-success {
    border-color: #28a745;
    background-color: #155724;
    color: #a5d6a7;
    font-size: 0.9rem;
    padding: 0.75rem;
    margin-bottom: 0;
}

.chart-config-panel .alert-success .btn-close {
    font-size: 0.75rem;
    padding: 0.375rem;
}

/* Chart toggle button styling */
.section-actions button[title*="chart"] {
    position: relative;
}

.section-actions button[title*="chart"]:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Chart loading state (duplicate - removing) */

/* Chart error state */
.chart-error {
    background-color: #721c24;
    border: 1px solid #dc3545;
    color: #ef9a9a;
    padding: 1rem;
    border-radius: 0.375rem;
    text-align: center;
}

/* Chart accessibility improvements */
.chart-container canvas[role="img"] {
    border: 1px solid #444;
}

.chart-container canvas[role="img"]:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Dark theme support for charts and all components */
.chart-container {
    background-color: #2d3136;
    border-color: #444;
    color: #e0e0e0;
}

.chart-container h6 {
    color: #e0e0e0;
}

.chart-container canvas {
    border-color: #444;
}

/* Dark theme for all MemReport components */
.memreport-section .card {
    background-color: #23272b;
    border-color: #333;
    color: #e0e0e0;
}

.memreport-section .card-header {
    background-color: #2d3136;
    border-bottom-color: #333;
    color: #e0e0e0;
}

.memreport-section .card-body {
    background-color: #23272b;
    color: #e0e0e0;
}

.memreport-section .table {
    color: #e0e0e0;
    --bs-table-bg: #23272b;
    --bs-table-striped-bg: #2d3136;
    --bs-table-hover-bg: #2d3136;
    --bs-table-border-color: #444;
}

.memreport-section .table th,
.memreport-section .table td {
    border-color: #444;
}

.memreport-section .form-control {
    background-color: #23272b;
    color: #e0e0e0;
    border-color: #444;
}

.memreport-section .form-control:focus {
    background-color: #23272b;
    color: #fff;
    border-color: #888;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.memreport-section .btn {
    background-color: #444;
    border-color: #666;
    color: #e0e0e0;
}

.memreport-section .btn:hover {
    background-color: #555;
    border-color: #777;
    color: #fff;
}

.memreport-section .dropdown-menu {
    background-color: #23272b;
    border-color: #333;
    color: #e0e0e0;
}

.memreport-section .dropdown-item {
    color: #e0e0e0;
}

.memreport-section .dropdown-item:hover {
    background-color: #2d3136;
    color: #007bff;
}

.memreport-section .alert {
    border-radius: 0.375rem;
}

.memreport-section .badge {
    background-color: #444;
    color: #e0e0e0;
}

/* Override media query to always apply dark theme */
@media (prefers-color-scheme: dark), (prefers-color-scheme: light) {
    .chart-container {
        background-color: #2d3136;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .chart-container h6 {
        color: #e0e0e0;
    }
    
    .chart-container canvas {
        border-color: #444;
    }
}

/* Accessibility improvements */
.memreport-section [role="table"] {
    border-collapse: collapse;
}

.memreport-section [role="row"]:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    background-color: rgba(0, 123, 255, 0.1);
}

/* Screen reader only content */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus indicators for interactive elements */
.memreport-section button:focus,
.memreport-section input:focus,
.memreport-section [tabindex]:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Enhanced focus for sortable headers */
.sortable-header:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    background-color: rgba(255, 255, 255, 0.2);
}

/* ARIA live region styling */
#memreport-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
    .memreport-section [role="row"]:focus {
        outline: 3px solid;
        background-color: rgba(255, 255, 255, 0.3);
    }
    
    .sortable-header:focus {
        outline: 3px solid;
        background-color: rgba(255, 255, 255, 0.4);
    }
    
    .memreport-section button:focus,
    .memreport-section input:focus,
    .memreport-section [tabindex]:focus {
        outline: 3px solid;
        box-shadow: none;
    }
}

/* Loading states */
.memreport-loading {
    text-align: center;
    padding: 2rem;
    color: #888;
}

.memreport-loading::after {
    content: "...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60% { content: "..."; }
    80%, 100% { content: ""; }
}

/* Error states */
.memreport-error {
    background-color: #721c24;
    border: 1px solid #dc3545;
    color: #ef9a9a;
    padding: 1rem;
    border-radius: 0.375rem;
    margin: 1rem 0;
}

/* Empty states */
.memreport-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

/* Pin indicator styling */
.badge.bg-primary {
    background-color: #0d6efd !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sticky-card-header {
        position: relative; /* Disable sticky on mobile */
    }
    
    .section-actions {
        flex-direction: column;
        gap: 0.125rem;
    }
    
    .section-actions .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .table-responsive {
        max-height: 400px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sticky-card-header {
        border-bottom: 2px solid;
    }
    
    .sortable-header:focus {
        outline: 3px solid;
    }
}

/* Standard table styling for all tables */
.memreport-data-table {
    width: 100% !important;
    table-layout: fixed;
}

.memreport-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #2d3136;
    color: #e0e0e0;
}

.memreport-data-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.5rem;
    border-color: #444;
    vertical-align: middle;
}

/* Performance optimizations for virtual scrolling */
.virtual-scroll-container * {
    will-change: transform;
}

.virtual-scroll-table tr {
    contain: layout style paint;
}

/* Loading indicator for progressive rendering */
.virtual-scroll-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(35, 39, 43, 0.9);
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 0.375rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Progress indicator styles */
.memreport-progress-container {
    min-height: 300px;
    background: #181a1b;
    border-radius: 0.375rem;
    padding: 2rem;
}

.memreport-progress-container .card {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    background-color: #23272b;
    border-color: #333;
    color: #e0e0e0;
}

.memreport-progress-container .progress {
    height: 20px;
    background-color: #2d3136;
    border-radius: 10px;
    overflow: hidden;
}

.memreport-progress-container .progress-bar {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 20px;
    transition: width 0.3s ease;
}

/* Smooth transitions for progress updates */
.memreport-progress-container .progress-bar.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* Large table indicators */
.large-table-indicator {
    background: #856404;
    border: 1px solid #ffc107;
    color: #fff3cd;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.large-table-indicator .badge {
    margin-left: 0.5rem;
}

/* Additional dark theme overrides */
.memreport-container,
.memreport-container * {
    color: #e0e0e0 !important;
}

.memreport-container .text-muted {
    color: #888 !important;
}

.memreport-container .text-danger {
    color: #ef9a9a !important;
}

.memreport-container .text-warning {
    color: #ffd54f !important;
}

.memreport-container .text-success {
    color: #a5d6a7 !important;
}

.memreport-container .text-info {
    color: #4fc3f7 !important;
}

.memreport-container .border {
    border-color: #444 !important;
}

.memreport-container .border-primary {
    border-color: #007bff !important;
}

.memreport-container .border-danger {
    border-color: #dc3545 !important;
}

.memreport-container .border-warning {
    border-color: #ffc107 !important;
}

.memreport-container .border-success {
    border-color: #28a745 !important;
}

.memreport-container .border-info {
    border-color: #17a2b8 !important;
}

/* Force dark theme for all cards and components */
.memreport-container .card,
.memreport-container .card-header,
.memreport-container .card-body {
    background-color: #23272b !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
}

.memreport-container .card-header {
    background-color: #2d3136 !important;
}

.memreport-container .table {
    color: #e0e0e0 !important;
    --bs-table-bg: #23272b !important;
    --bs-table-striped-bg: #2d3136 !important;
    --bs-table-hover-bg: #2d3136 !important;
    --bs-table-border-color: #444 !important;
}

.memreport-container .btn {
    background-color: #444 !important;
    border-color: #666 !important;
    color: #e0e0e0 !important;
}

.memreport-container .btn:hover {
    background-color: #555 !important;
    border-color: #777 !important;
    color: #fff !important;
}

.memreport-container .form-control {
    background-color: #23272b !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

.memreport-container .form-control:focus {
    background-color: #23272b !important;
    color: #fff !important;
    border-color: #888 !important;
}

.memreport-container .alert {
    border-radius: 0.375rem !important;
}

.memreport-container .badge {
    background-color: #444 !important;
    color: #e0e0e0 !important;
}

.memreport-container .dropdown-menu {
    background-color: #23272b !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
}

.memreport-container .dropdown-item {
    color: #e0e0e0 !important;
}

.memreport-container .dropdown-item:hover {
    background-color: #2d3136 !important;
    color: #007bff !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sortable-header,
    .sort-indicator {
        transition: none;
    }
    
    .memreport-loading::after {
        animation: none;
        content: "...";
    }
    
    .virtual-scroll-container * {
        will-change: auto;
    }
    
    .progress-bar {
        transition: none;
    }
    
    .progress-bar-animated {
        animation: none;
    }
}