/**
 * CIPD Enhanced Analytics CSS
 * Styles for AI-powered analytics dashboard
 * 
 * @package CIPD_AI_Engine
 * @since 2.0.0
 */

/* Dashboard Container */
.analytics-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.analytics-container.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Dashboard Header */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e1e5e9;
}

.analytics-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 28px;
    font-weight: 600;
}

.analytics-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 12px;
    font-weight: 600;
    color: #5a6c7d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    min-width: 120px;
    transition: border-color 0.2s ease;
}

.control-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.refresh-btn {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.refresh-btn:hover {
    background: #2563eb;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.summary-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card-value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.summary-card-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

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

.trend-indicator.trend-up {
    color: #10b981;
}

.trend-indicator.trend-down {
    color: #ef4444;
}

.trend-indicator.trend-stable {
    color: #f59e0b;
}

/* Real-time Stats */
.realtime-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.realtime-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.realtime-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.realtime-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.realtime-refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.realtime-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.realtime-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

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

.realtime-stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.realtime-stat-label {
    font-size: 12px;
    opacity: 0.9;
}

.last-updated {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 8px;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
    text-align: center;
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

/* Insights Section */
.insights-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    margin-bottom: 30px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
}

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

.insight-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    background: #f9fafb;
}

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

.insight-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.expand-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.expand-btn:hover {
    background: #2563eb;
}

.insight-content {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

/* Recommendations Section */
.recommendations-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    margin-bottom: 30px;
}

.recommendations-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.recommendation-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    background: #fefce8;
    border-left: 4px solid #f59e0b;
    transition: opacity 0.3s ease;
}

.recommendation-item.accepted {
    background: #f0fdf4;
    border-left-color: #10b981;
}

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

.rec-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.rec-actions {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}

.accept-btn {
    background: #10b981;
    color: white;
}

.accept-btn:hover {
    background: #059669;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.rec-content {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

/* Group Analytics */
.group-summary {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.group-summary h4 {
    margin: 0 0 12px 0;
    color: #0c4a6e;
}

.group-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.metric-item {
    text-align: center;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    color: #0c4a6e;
}

.metric-label {
    font-size: 12px;
    color: #0369a1;
}

/* Notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.analytics-notification {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #3b82f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
}

.analytics-notification.error {
    border-left-color: #ef4444;
}

.analytics-notification.success {
    border-left-color: #10b981;
}

.analytics-notification span {
    color: #374151;
    font-size: 14px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    margin-left: 12px;
}

.close-btn:hover {
    color: #6b7280;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .analytics-container {
        padding: 15px;
    }
    
    .analytics-header {
        flex-direction: column;
        gap: 20px;
        align-items: stretch;
    }
    
    .analytics-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chart-wrapper {
        height: 250px;
    }
    
    .insights-container {
        grid-template-columns: 1fr;
    }
    
    .notifications-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
    
    .realtime-section {
        padding: 16px;
    }
    
    .realtime-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .rec-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .rec-actions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .realtime-stats {
        grid-template-columns: 1fr;
    }
    
    .chart-wrapper {
        height: 200px;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .analytics-container {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .summary-card {
        background: #374151;
        border-color: #4b5563;
    }
    
    .chart-container {
        background: #374151;
        border-color: #4b5563;
    }
    
    .insights-section,
    .recommendations-section {
        background: #374151;
        border-color: #4b5563;
    }
    
    .insight-item,
    .recommendation-item {
        background: #4b5563;
        border-color: #6b7280;
    }
    
    .recommendation-item {
        background: #451a03;
        border-left-color: #f59e0b;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}