/* Health Insights Page Specific Styles */

/* Page Header */
.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.insights-header-left h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.insights-header-left p {
    color: var(--text-secondary);
    font-size: 14px;
}

.insights-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-range-filter {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.time-range-filter:hover,
.time-range-filter:focus {
    border-color: var(--primary);
}

.btn-export {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Key Metrics Row */
.insights-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.insight-stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.insight-stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.insight-stat-card .stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.insight-stat-card .stat-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-icon-wrap.blue {
    background: var(--info-light);
    color: var(--info);
}

.stat-icon-wrap.purple {
    background: #f3e8ff;
    color: #9333ea;
}

.stat-icon-wrap.green {
    background: var(--success-light);
    color: var(--success);
}

.stat-icon-wrap.orange {
    background: #fff7ed;
    color: #ea580c;
}

.insight-stat-card .stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
}

.stat-trend.positive {
    color: var(--success);
    background: var(--success-light);
}

.stat-trend.negative {
    color: var(--critical);
    background: var(--critical-light);
}

.insight-stat-card .stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

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

.insight-stat-card .sparkline {
    margin-top: 16px;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.sparkline .sparkline-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.sparkline-fill.blue {
    background: linear-gradient(90deg, var(--info), var(--accent));
}

.sparkline-fill.purple {
    background: linear-gradient(90deg, #9333ea, #c084fc);
}

.sparkline-fill.green {
    background: linear-gradient(90deg, var(--success), #6ee7b7);
}

.sparkline-fill.orange {
    background: linear-gradient(90deg, #ea580c, #fb923c);
}

/* Trends Chart Card */
.trends-card {
    margin-bottom: 24px;
}

.trends-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--border-radius-sm);
}

.chart-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.chart-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.chart-tab:hover:not(.active) {
    color: var(--text-primary);
}

.chart-container {
    padding: 24px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 0 16px;
}

.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    max-width: 48px;
    border-radius: 6px 6px 0 0;
    transition: height 0.4s ease, opacity 0.2s;
    position: relative;
    cursor: pointer;
    min-height: 4px;
}

.bar:hover {
    opacity: 0.85;
}

.bar.primary {
    background: linear-gradient(180deg, var(--accent), var(--primary));
}

.bar.secondary {
    background: linear-gradient(180deg, #c084fc, #9333ea);
}

.bar-label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.bar-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-dot.primary {
    background: linear-gradient(135deg, var(--accent), var(--primary));
}

.legend-dot.secondary {
    background: linear-gradient(135deg, #c084fc, #9333ea);
}

/* Two Column Grid */
.insights-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* Cohort Breakdown */
.cohort-list {
    padding: 8px 24px 24px;
}

.cohort-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.cohort-row:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
    background: var(--bg-primary);
}

.cohort-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.cohort-icon.diabetes {
    background: var(--warning-light);
    color: var(--warning);
}

.cohort-icon.hypertension {
    background: var(--critical-light);
    color: var(--critical);
}

.cohort-icon.cardiac {
    background: #fce7f3;
    color: #db2777;
}

.cohort-icon.respiratory {
    background: var(--info-light);
    color: var(--info);
}

.cohort-info {
    flex: 1;
}

.cohort-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.cohort-count {
    font-size: 12px;
    color: var(--text-muted);
}

.cohort-stats {
    display: flex;
    gap: 16px;
}

.cohort-stat {
    text-align: center;
}

.cohort-stat-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.cohort-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cohort-action {
    color: var(--primary);
    font-size: 14px;
    flex-shrink: 0;
}

/* Risk Stratification */
.risk-content {
    padding: 24px;
}

.risk-bar-container {
    margin-bottom: 24px;
}

.risk-stacked-bar {
    display: flex;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.risk-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    transition: flex 0.4s ease;
}

.risk-segment.high {
    background: var(--critical);
}

.risk-segment.rising {
    background: var(--warning);
}

.risk-segment.moderate {
    background: var(--info);
}

.risk-segment.low {
    background: var(--success);
}

.risk-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.risk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
}

.risk-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.risk-dot.high {
    background: var(--critical);
}

.risk-dot.rising {
    background: var(--warning);
}

.risk-dot.moderate {
    background: var(--info);
}

.risk-dot.low {
    background: var(--success);
}

.risk-info {
    flex: 1;
}

.risk-level {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.risk-detail {
    font-size: 12px;
    color: var(--text-muted);
}

.risk-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.risk-count small {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

/* Wearable Analytics Card */
.wearable-analytics-content {
    padding: 24px;
}

.device-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.device-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-name {
    font-size: 13px;
    color: var(--text-secondary);
    width: 120px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-bar-container {
    flex: 1;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.device-bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), var(--primary));
}

.device-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    width: 40px;
    text-align: right;
}

.wearable-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.wearable-stat-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
}

.wearable-stat-val {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.wearable-stat-lbl {
    font-size: 11px;
    color: var(--text-muted);
}

.sync-rate {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--success-light);
    border-radius: var(--border-radius-sm);
}

.sync-rate i {
    color: var(--success);
    font-size: 16px;
}

.sync-rate span {
    font-size: 13px;
    color: var(--text-primary);
}

.sync-rate strong {
    color: var(--success);
}

/* Cohort Alerts & Recommendations */
.alerts-content {
    padding: 16px 24px 24px;
}

.insight-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 10px;
    transition: all 0.2s;
}

.insight-alert-item:last-child {
    margin-bottom: 0;
}

.insight-alert-item:hover {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin: -1px;
    margin-bottom: 9px;
}

.insight-alert-item:last-child:hover {
    margin-bottom: -1px;
}

.alert-severity {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.alert-severity.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.alert-severity.info {
    background: var(--info-light);
    color: var(--info);
}

.alert-severity.critical {
    background: var(--critical-light);
    color: var(--critical);
}

.alert-text {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.alert-action {
    flex-shrink: 0;
}

.alert-action .btn-small {
    margin-left: 0;
}

/* Top At-Risk Patients Table */
.patients-table-card {
    margin-bottom: 24px;
}

.patients-table-container {
    overflow-x: auto;
}

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

.patients-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.patients-table td {
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.patients-table tbody tr {
    transition: background 0.15s;
}

.patients-table tbody tr:hover {
    background: var(--bg-primary);
}

.patients-table tbody tr:last-child td {
    border-bottom: none;
}

.patient-cell {
    display: flex;
    flex-direction: column;
}

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

.patient-cell .mrn {
    font-size: 11px;
    color: var(--text-muted);
}

.risk-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 28px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
}

.risk-score.high {
    background: var(--critical-light);
    color: var(--critical);
}

.risk-score.rising {
    background: var(--warning-light);
    color: var(--warning);
}

.condition-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--info-light);
    color: var(--info);
}

.trend-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
}

.trend-indicator.up {
    color: var(--critical);
}

.trend-indicator.down {
    color: var(--success);
}

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

.table-action-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
}

.table-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.view-all-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-primary);
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-decoration: none;
}

.view-all-link:hover {
    background: var(--primary);
    color: white;
}

/* Chart tab content switching */
.chart-tab-content {
    display: none;
}

.chart-tab-content.active {
    display: block;
}

/* Responsive */
@media (max-width: 1400px) {
    .insights-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .insights-two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .insights-header {
        flex-direction: column;
        gap: 16px;
    }

    .insights-header-right {
        width: 100%;
    }

    .time-range-filter {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .insights-stats-grid {
        grid-template-columns: 1fr;
    }

    .cohort-row {
        flex-wrap: wrap;
    }

    .cohort-stats {
        width: 100%;
        justify-content: space-around;
    }

    .wearable-stats-row {
        grid-template-columns: 1fr;
    }

    .patients-table th:nth-child(n+5),
    .patients-table td:nth-child(n+5) {
        display: none;
    }
}
