/* public/css/duration-analysis.css */
/* Основана на ваших существующих стилях из portfolio-builder */

.duration-analysis-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: var(--font-primary);
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title i {
    color: var(--accent);
}

.page-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 30px;
}

/* Пояснение "что такое дюрация" */
.duration-explainer {
    background: var(--surface-2);
    border: 1px solid #dbe2fd;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.duration-explainer summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.duration-explainer summary::-webkit-details-marker {
    display: none;
}

.duration-explainer summary i {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.duration-explainer[open] summary i {
    transform: rotate(180deg);
}

.duration-explainer-body {
    margin-top: 14px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

.duration-explainer-body p {
    margin: 0 0 10px;
}

.duration-explainer-body ul {
    margin: 0 0 10px;
    padding-left: 20px;
}

.duration-explainer-body li {
    margin-bottom: 4px;
}

/* Панель фильтров (аналогично portfolio-builder) */
.filters-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent) 100%);
    color: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
    letter-spacing: 0.5px;
}

/* Индикаторы дюрации в таблице */
.duration-low { color: var(--good); }
.duration-medium { color: var(--ok); }
.duration-high { color: var(--poor); }

.duration-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.duration-low-bg { background: rgba(16, 185, 129, 0.15); }
.duration-medium-bg { background: rgba(245, 158, 11, 0.15); }
.duration-high-bg { background: rgba(239, 68, 68, 0.15); }

/* Дюрация не определена (бессрочная или уже погашенная бумага) —
   нейтральный серый, а не зелёный "низкий риск" как раньше при 0 */
.duration-unknown {
    color: var(--text-muted);
    background: rgba(108, 117, 125, 0.12);
}

.text-muted { color: var(--text-muted); }

/* График */
.chart-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    margin-top: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.chart-container {
    position: relative;
    height: 400px;
    margin: 20px 0;
}

/* Легенда */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .duration-analysis-page {
        padding: 15px;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Добавьте эти стили в ваш CSS файл */
.stats-container {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.stats-row:last-child {
    margin-bottom: 0;
}

.stat-item {
    text-align: center;
    flex: 1;
    padding: 0 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

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

.stat-total .stat-value {
    color: var(--text);
}

.stat-warning .stat-value {
    color: var(--ok);
}

.stat-danger .stat-value {
    color: var(--poor);
}

.stat-info .stat-value {
    color: var(--accent);
}

.stat-success .stat-value {
    color: var(--good);
    font-size: 28px;
}

.stat-divider {
    position: relative;
}

.stat-divider::before {
    content: "−";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border);
    font-size: 20px;
}

.stat-result {
    position: relative;
}

.stat-result::before {
    content: "=";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border);
    font-size: 20px;
    font-weight: bold;
}

/* Статистика в два ряда */
.stats-container {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.stats-row:last-child {
    margin-bottom: 0;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

.stat-item {
    text-align: center;
    flex: 1;
    padding: 0 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Цвета */
.stat-total .stat-value {
    color: var(--text);
}

.stat-warning .stat-value {
    color: var(--ok);
}

.stat-danger .stat-value {
    color: var(--poor);
}

.stat-info .stat-value {
    color: var(--accent);
}

.stat-success .stat-value {
    color: var(--good);
    font-size: 28px;
}

/* Разделители */
.stat-divider {
    position: relative;
}

.stat-divider::before {
    content: "−";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border);
    font-size: 20px;
}

.stat-result {
    position: relative;
}

.stat-result::before {
    content: "=";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border);
    font-size: 20px;
    font-weight: bold;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.market-stats {
    margin-bottom: 10px;
}

.filter-stats-container {
    background: var(--surface-2);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 10px 0;
}

.filter-stats {
    margin: 0;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border);
    text-align: center;
    position: relative;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* Карточки с вычитанием */
.stat-card-subtraction {
    padding-left: 40px;
}

.stat-subtraction-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border);
    font-size: 20px;
    font-weight: normal;
}

/* Итоговая карточка */
.stat-card-result {
    padding-left: 40px;
}

.stat-result-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border);
    font-size: 20px;
    font-weight: bold;
}

/* Цвета для значений исключенных бумаг */
.stat-color-orange {
    color: var(--ok) !important;
}

.stat-color-red {
    color: var(--poor) !important;
}

.stat-color-blue {
    color: var(--accent) !important;
}

.stat-color-green {
    color: var(--good) !important;
    font-size: 28px !important;
}

/* Стили для итогового значения */
.stat-value-result {
    color: var(--good);
    font-size: 28px;
}

.stat-label-result {
    color: var(--good);
    font-weight: bold;
}

.legend-container {
    background: var(--surface-2);
    padding: 10px;
    margin-top: 20px;
    border-radius: 5px;
    font-size: 13px;
}

.legend-badge {
    margin-left: 10px;
}

.filters-info {
    background: var(--accent-soft);
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 5px;
    border-left: 4px solid var(--accent);
}

.filters-info-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-info-icon {
    color: var(--accent);
    font-size: 18px;
}

.filters-info-badge {
    margin-left: 8px;
}

.adaptive-stats {
    margin: 20px 0;
    padding: 15px;
    background: var(--surface-2);
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}
.adaptive-stats .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 10px;
}
.adaptive-stats .stat-card {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    text-align: center;
}
.adaptive-stats .stat-value {
    font-size: 22px;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 5px;
}
.adaptive-stats .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}
.adaptive-stats .stats-note {
    font-size: 14px;
    color: var(--text-muted);
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    margin-top: 10px;
}

.composite-rating {
    display: inline-block;
    width: 36px;
    height: 36px;
    line-height: 36px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    margin: 0 auto;
}

.rating-high {
    background-color: var(--good);
    color: white;
}

.rating-medium {
    background-color: var(--ok);
    color: white;
}

.rating-low {
    background-color: var(--poor);
    color: white;
}

.quality-badge {
    margin-top: 3px;
    color: var(--ok);
    font-size: 10px;
}