/* ============================================
   ENGAGEMENT ANALYTICS STYLES
   Control charts for multi-survey comparison
   ============================================ */

/* Selection Panel */
.selection-panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.selection-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--accent-cyan) 50%, var(--accent-purple) 100%);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-btn {
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn:active {
    transform: translateY(0);
}

.selection-count {
    font-size: 0.8125rem;
    color: var(--primary-blue);
    padding: 8px 16px;
    background: rgba(0, 120, 212, 0.08);
    border-radius: var(--radius-full);
    font-weight: 600;
}

.survey-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding: 4px;
    margin: -4px;
}

.survey-selection-grid::-webkit-scrollbar {
    width: 8px;
}

.survey-selection-grid::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.survey-selection-grid::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.survey-selection-grid::-webkit-scrollbar-thumb:hover {
    background: var(--primary-blue);
}

.survey-checkbox-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.survey-checkbox-item:hover {
    background: var(--bg-white);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.survey-checkbox-item.selected {
    background: linear-gradient(135deg, rgba(0, 120, 212, 0.06) 0%, rgba(16, 185, 129, 0.06) 100%);
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
}

.survey-checkbox-item input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--primary-blue);
    flex-shrink: 0;
}

.survey-checkbox-item input[type="radio"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--primary-blue);
    flex-shrink: 0;
}

.survey-checkbox-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    min-width: 0;
}

.survey-checkbox-label .survey-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.survey-checkbox-label .survey-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    letter-spacing: 0.3px;
}

/* Filter Panel */
.filter-panel {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 24px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-group select {
    padding: 12px 40px 12px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 14px center;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 160px;
    -webkit-appearance: none;
    appearance: none;
}

.filter-group select:hover {
    border-color: var(--primary-light);
    background-color: var(--bg-light);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.12);
}

/* Charts Section */
.charts-section {
    margin-bottom: 24px;
}

.chart-placeholder {
    text-align: center;
    padding: 80px 40px;
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-medium);
    color: var(--text-secondary);
}

.chart-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.chart-placeholder h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.chart-placeholder p {
    font-size: 0.9375rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
    color: var(--text-muted);
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
    gap: 24px;
}

@media (max-width: 1200px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--accent-cyan) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chart-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.chart-card:hover::before {
    opacity: 1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 12px;
}

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

.chart-stats {
    display: flex;
    gap: 8px;
    font-size: 0.8125rem;
    align-items: stretch;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    min-width: 60px;
}

.stat-item.trend {
    min-width: 50px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.5625rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-top: 2px;
    white-space: nowrap;
}

.stat-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

.stat-value.positive {
    color: var(--success-green);
}

.stat-value.negative {
    color: var(--error-red);
}

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

.chart-body {
    min-height: 240px;
    position: relative;
    padding: 4px 0;
}

.chart-body .no-data-message {
    padding: 40px 20px;
}

.chart-body svg {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

/* Control Chart specific styles */
.control-line {
    stroke-dasharray: 5, 5;
}

.control-line.ucl {
    stroke: var(--error-red);
}

.control-line.lcl {
    stroke: var(--error-red);
}

.control-line.mean {
    stroke: var(--success-green);
}

.data-point {
    transition: all var(--transition-fast);
}

.data-point:hover {
    r: 6;
}

.data-point.out-of-control {
    fill: var(--error-red);
    stroke: var(--error-red);
    r: 5;
}

/* Summary Section */
.summary-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.summary-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--success-green) 0%, var(--accent-cyan) 50%, var(--primary-blue) 100%);
}

.summary-section h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
}

.summary-card {
    background: linear-gradient(145deg, var(--bg-white) 0%, var(--bg-light) 100%);
    border-radius: var(--radius-md);
    padding: 24px 20px;
    text-align: center;
    border: 1px solid var(--border-light);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.summary-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-blue);
    transform: scaleX(0);
    transition: transform var(--transition-fast);
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.summary-card:hover::after {
    transform: scaleX(1);
}

.summary-card .metric-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: inline-block;
}

.summary-card .metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1;
}

.summary-card .metric-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card .metric-trend {
    font-size: 0.75rem;
    margin-top: 10px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    display: inline-block;
    font-weight: 600;
}

.summary-card .metric-trend.up {
    background: var(--success-light);
    color: #047857;
}

.summary-card .metric-trend.down {
    background: var(--error-light);
    color: #B91C1C;
}

.summary-card .metric-trend.neutral {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

/* Loading overlay for charts */
.chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: var(--radius-md);
    z-index: 10;
}

.chart-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.chart-loading::after {
    content: 'Loading...';
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Legend for multi-survey view */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

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

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .selection-panel,
    .filter-panel,
    .chart-card,
    .summary-section {
        padding: 20px;
    }

    .selection-panel::before,
    .summary-section::before {
        height: 3px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .selection-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .filter-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .filter-group select {
        width: 100%;
    }

    .survey-selection-grid {
        grid-template-columns: 1fr;
        max-height: 280px;
    }

    .charts-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chart-stats {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .stat-item {
        min-width: 60px;
        padding: 8px 10px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .summary-card {
        padding: 16px 12px;
    }

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

    .summary-card .metric-icon {
        font-size: 1.5rem;
    }
}

/* Tooltip styles */
.chart-tooltip {
    position: absolute;
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-xl);
    pointer-events: none;
    z-index: 100;
    font-size: 0.8125rem;
    max-width: 280px;
}

.chart-tooltip .tooltip-date {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9375rem;
}

.chart-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 6px;
}

.chart-tooltip .tooltip-label {
    color: var(--text-secondary);
}

.chart-tooltip .tooltip-value {
    font-weight: 700;
    color: var(--text-primary);
}

/* Empty data state */
.no-data-message {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-secondary);
}

.no-data-message .no-data-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.4;
    filter: grayscale(50%);
}

.no-data-message p {
    font-size: 1rem;
    line-height: 1.6;
    max-width: 350px;
    margin: 0 auto;
}

/* Subtle entrance animation for chart cards */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-card {
    animation: fadeSlideUp 0.4s ease-out;
}

.chart-card:nth-child(2) { animation-delay: 0.05s; }
.chart-card:nth-child(3) { animation-delay: 0.1s; }
.chart-card:nth-child(4) { animation-delay: 0.15s; }
.chart-card:nth-child(5) { animation-delay: 0.2s; }
.chart-card:nth-child(6) { animation-delay: 0.25s; }
.chart-card:nth-child(7) { animation-delay: 0.3s; }

/* Summary card entrance animation */
.summary-card {
    animation: fadeSlideUp 0.4s ease-out;
}

/* No surveys message */
.no-surveys-message {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    grid-column: 1 / -1;
}

/* Survey checkbox item entrance animation */
.survey-checkbox-item {
    animation: fadeSlideUp 0.3s ease-out;
    animation-fill-mode: both;
}

.survey-checkbox-item:nth-child(1) { animation-delay: 0.02s; }
.survey-checkbox-item:nth-child(2) { animation-delay: 0.04s; }
.survey-checkbox-item:nth-child(3) { animation-delay: 0.06s; }
.survey-checkbox-item:nth-child(4) { animation-delay: 0.08s; }
.survey-checkbox-item:nth-child(5) { animation-delay: 0.10s; }
.survey-checkbox-item:nth-child(6) { animation-delay: 0.12s; }
.survey-checkbox-item:nth-child(7) { animation-delay: 0.14s; }
.survey-checkbox-item:nth-child(8) { animation-delay: 0.16s; }
.survey-checkbox-item:nth-child(9) { animation-delay: 0.18s; }
.survey-checkbox-item:nth-child(10) { animation-delay: 0.20s; }
.summary-card:nth-child(2) { animation-delay: 0.05s; }
.summary-card:nth-child(3) { animation-delay: 0.1s; }
.summary-card:nth-child(4) { animation-delay: 0.15s; }
.summary-card:nth-child(5) { animation-delay: 0.2s; }
.summary-card:nth-child(6) { animation-delay: 0.25s; }
.summary-card:nth-child(7) { animation-delay: 0.3s; }
.summary-card:nth-child(8) { animation-delay: 0.35s; }

/* Retry Button - Error State */
.retry-btn {
    margin-top: 20px;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.retry-btn:active {
    transform: translateY(0);
}

/* ============================================
   NOTIFICATION PREVIEW PANEL (Distributions Page)
   ============================================ */

.notification-preview-panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
    animation: fadeSlideUp 0.3s ease-out;
}

.notification-preview-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--accent-purple) 100%);
}

.notification-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.notification-preview-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-preview-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notification-preview-title .notification-icon {
    font-size: 1.25rem;
}

.notification-edit-link,
.notification-setup-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-blue);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.08);
    transition: all var(--transition-fast);
}

.notification-edit-link:hover,
.notification-setup-link:hover {
    background: rgba(59, 130, 246, 0.15);
    transform: translateX(2px);
}

.notification-preview-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.notification-rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.notification-rule-item .rule-icon {
    font-size: 1rem;
}

.notification-rule-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.notification-preview-email {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.notification-preview-email strong {
    color: var(--text-secondary);
}

.notification-preview-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}
