/* Context Overflow Page Styles - Extracted from templates/pages/context_overflow.html */

.ldr-overflow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Mobile responsive - single column on narrow screens */
@media screen and (max-width: 600px) {
    .ldr-overflow-grid {
        grid-template-columns: 1fr;
    }
}

.ldr-overflow-card {
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: transform 0.2s;
}

.ldr-overflow-card:hover {
    transform: translateY(-2px);
}

.ldr-metric-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.ldr-metric-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ldr-metric-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.ldr-chart-container {
    position: relative;
    height: 400px;
    margin-top: 2rem;
}

/* Add missing ldr- prefixed classes */
.ldr-page {
    padding: 2rem;
}

.ldr-page-header {
    margin-bottom: 2rem;
}

.ldr-page-header h1 {
    margin: 0;
    color: var(--text-primary);
}

.ldr-loading-spinner {
    color: var(--text-secondary);
}

.ldr-truncated-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: background-color 0.2s;
    cursor: pointer;
}

.ldr-truncated-item:hover {
    background-color: var(--border-color);
}

.ldr-truncation-badge {
    background: var(--error-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ldr-model-card {
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.ldr-model-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ldr-model-name {
    font-weight: 600;
    color: var(--text-primary);
}

.ldr-model-provider {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.ldr-progress-bar {
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.ldr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, var(--warning-color) 80%, var(--error-color) 95%);
    transition: width 0.3s ease;
}

/* Time range selector */
.ldr-time-range-selector {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}

.ldr-time-range-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    /* WCAG 2.5.5 — see metrics.css for the rationale; duplicated here
       because the rule is page-scoped per the existing CSS layout. */
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.ldr-time-range-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.ldr-warning-banner {
    background: rgba(var(--warning-color-rgb), 0.1);
    border: 1px solid var(--warning-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ldr-warning-banner i {
    color: var(--warning-color);
    font-size: 1.5rem;
}

.ldr-no-data-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.ldr-no-data-message i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.ldr-table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

.ldr-data-table {
    width: 100%;
    border-collapse: collapse;
}

.ldr-data-table th {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.ldr-data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.ldr-data-table tr:hover {
    background: var(--bg-secondary);
}

.ldr-context-limit-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Theme-aware color utility classes for JS-generated content */
.ldr-text-success { color: var(--success-color); }
.ldr-text-error { color: var(--error-color); }
.ldr-text-warning { color: var(--warning-color); }
.ldr-text-muted { color: var(--text-muted); font-style: italic; }
.ldr-text-secondary { color: var(--text-secondary); }

.ldr-icon-success { color: var(--success-color); }
.ldr-icon-error { color: var(--error-color); }

/* Truncation rate color classes */
.ldr-truncation-high { color: var(--error-color); }
.ldr-truncation-medium { color: var(--warning-color); }
.ldr-truncation-low { color: var(--success-color); }

/* Sortable table headers */
.ldr-data-table th.ldr-sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}

.ldr-data-table th.ldr-sortable:hover {
    background: var(--border-color);
}

.ldr-data-table th.ldr-sortable::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    font-size: 0.75rem;
}

.ldr-data-table th.ldr-sortable.ldr-sort-asc::after {
    content: '\f0de';
    opacity: 0.8;
}

.ldr-data-table th.ldr-sortable.ldr-sort-desc::after {
    content: '\f0dd';
    opacity: 0.8;
}

/* Pagination */
.ldr-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem 0;
}

.ldr-pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    /* WCAG 2.5.5 touch target. */
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ldr-pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.ldr-pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ldr-pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Search input */
.ldr-table-search {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    width: 250px;
    max-width: 100%;
}

.ldr-table-search::placeholder {
    color: var(--text-secondary);
}

.ldr-info-message {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.ldr-info-message i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
    display: block;
}

/* Mobile responsive fixes */
@media screen and (max-width: 767px) {
    .ldr-page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .ldr-page-header > div:first-child {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .ldr-page-header h1 {
        font-size: 1.5rem;
    }

    .ldr-time-range-selector {
        flex-wrap: wrap;
        width: 100%;
        margin-left: 0;
    }

    .ldr-time-range-btn {
        flex: 1;
        min-width: 40px;
        padding: 0.5rem 0.75rem;
        text-align: center;
    }

    /* Single column for context limit distribution on mobile */
    .ldr-card-content > div[style*="grid-template-columns: 1fr 2fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    /* Mobile nav spacing */
    .ldr-page#context-overflow {
        padding-bottom: 120px;
    }
}

@media screen and (max-width: 480px) {
    .ldr-page {
        padding: 1rem;
    }

    .ldr-metric-value {
        font-size: 1.5rem;
    }

    .ldr-overflow-card {
        padding: 1rem;
    }

    .ldr-chart-container {
        height: 300px;
    }

    .ldr-table-search {
        width: 100%;
    }
}
