/* User Analytics Styles */
.analytics-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    margin-bottom: 2rem;
}

.analytics-hero-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.live-activity-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.live-activity-card h6 {
    color: #374151;
    margin-bottom: 1rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.85rem;
    line-height: 1.3;
    color: #374151;
}

.activity-time {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.activity-empty {
    text-align: center;
    padding: 2rem 0;
    color: #6b7280;
}

/* Dashboard Tabs */
.dashboard-tabs {
    margin-bottom: 2rem;
    border-bottom: 2px solid #e5e7eb;
}

.dashboard-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: #6b7280;
    font-weight: 500;
    padding: 1rem 1.5rem;
    transition: all 0.2s ease;
}

.dashboard-tabs .nav-link:hover {
    border-bottom-color: #d1d5db;
    color: #374151;
}

.dashboard-tabs .nav-link.active {
    border-bottom-color: #3b82f6;
    color: #3b82f6;
    background: none;
}

/* Analytics Cards */
.analytics-sidebar .card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.analytics-sidebar .card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Metrics */
.attendance-metrics {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.metric-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #374151;
}

/* Timeline Controls */
.timeline-controls {
    display: flex;
    gap: 0.5rem;
}

.timeline-controls .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.timeline-controls .btn.active {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Pattern Insights */
.insight-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.insight-item:last-child {
    border-bottom: none;
}

.insight-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.insight-content h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
}

.insight-content p {
    margin: 0;
    font-size: 0.8rem;
    color: #6b7280;
}


/* Smart Insights */
.insight-card {
    border: 1px solid #e5e7eb;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: white;
    transition: box-shadow 0.2s ease;
}

.insight-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.insight-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.insight-icon.positive {
    background: #10b981;
}

.insight-icon.warning {
    background: #f59e0b;
}

.insight-icon.info {
    background: #3b82f6;
}

.insight-icon.prediction {
    background: #8b5cf6;
}

.insight-card h6 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
}

.insight-card p {
    margin: 0 0 1rem 0;
    color: #6b7280;
    line-height: 1.5;
}

.insight-action {
    margin-top: 1rem;
}

.insight-action .btn {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

.no-insights {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

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

/* Predictions Card */
.predictions-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
}

.predictions-card .card-header {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-bottom: none;
}

.insights-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .analytics-hero .row {
        flex-direction: column;
    }

    .live-activity-card {
        margin-top: 1rem;
    }

    .engagement-score-container {
        padding: 1rem 0;
    }

    .score-circle {
        width: 100px;
        height: 100px;
    }

    .score-circle::before {
        width: 80px;
        height: 80px;
    }

    .score-number {
        font-size: 2rem;
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .attendance-metrics {
        flex-direction: column;
        gap: 0.5rem;
    }

    .insight-card {
        padding: 1rem;
    }

    .insight-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Chart Container Styles */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
}

/* Loading States */
.analytics-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.analytics-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

/* Error States */
.error-state {
    color: #6b7280;
}

.error-state i {
    display: block;
    margin-bottom: 1rem;
}

/* Animation Classes */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Live Updates Section Styles */
.live-status-indicator .badge {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
}

.pulse-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Live Updates Panels */
.live-updates-panel,
.live-stats-panel {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.live-updates-panel h6,
.live-stats-panel h6 {
    color: #374151;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Live Statistics Items */
.live-stat-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.live-stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
}

/* Enhanced Activity Feed */
.activity-feed-container {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.activity-feed-container::-webkit-scrollbar {
    width: 4px;
}

.activity-feed-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

.activity-feed-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.activity-feed-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.activity-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background: rgba(59, 130, 246, 0.05);
    transform: translateX(2px);
    border-radius: 6px;
    padding-left: 0.5rem;
}

.activity-latest {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-left: 3px solid #10b981;
    padding-left: 0.75rem !important;
    border-radius: 6px;
}

.activity-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.activity-item:hover .activity-icon {
    transform: scale(1.1);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.875rem;
    line-height: 1.4;
    color: #374151;
    margin-bottom: 0.25rem;
}

.activity-time {
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.activity-empty i {
    display: block;
    margin-bottom: 0.5rem;
}

/* Activity Pulse Effect */
.activity-pulse {
    position: absolute;
    top: 50%;
    left: -8px;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    transform: translateY(-50%);
    animation: activityPulse 2s infinite;
}

@keyframes activityPulse {
    0% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 0.3;
        transform: translateY(-50%) scale(1.5);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Count Update Animation */
.count-updated {
    animation: countUpdate 0.8s ease;
    color: #10b981 !important;
}

@keyframes countUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #10b981;
    }
    100% {
        transform: scale(1);
    }
}

/* Real-time Notifications */
.realtime-notifications-container {
    position: relative;
    min-height: 20px;
}

.realtime-notification {
    animation: slideInFromTop 0.3s ease;
    border-left: 4px solid #10b981;
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress Bars for Live Stats */
.live-stat-item .progress {
    margin-top: 0.5rem;
}

.live-stat-item .progress-bar {
    transition: width 0.8s ease;
}

/* Responsive Design for Live Updates */
@media (max-width: 768px) {
    .live-updates-panel,
    .live-stats-panel {
        margin-bottom: 1rem;
        padding: 0.75rem;
    }

    .activity-feed-container {
        max-height: 200px;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .activity-text {
        font-size: 0.8rem;
    }

    .activity-time {
        font-size: 0.7rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .live-updates-panel,
    .live-stats-panel {
        background: rgba(31, 41, 55, 0.8);
        border-color: #374151;
    }

    .live-updates-panel h6,
    .live-stats-panel h6 {
        color: #f9fafb;
    }

    .stat-label {
        color: #d1d5db;
    }

    .stat-value {
        color: #f9fafb;
    }

    .activity-text {
        color: #f9fafb;
    }

    .activity-time {
        color: #9ca3af;
    }

    .activity-latest {
        background: linear-gradient(90deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.1) 100%);
    }
}

.slide-in {
    animation: slideIn 0.5s ease-out;
}

/* Toast Container */
.toast-container {
    z-index: 1080;
}

/* Plan-based Features */
.analytics-upgrade-prompt {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    border: 2px dashed #cbd5e1;
    margin: 1rem 0;
}

.analytics-upgrade-prompt h5 {
    color: #374151;
    margin-bottom: 1rem;
}

.analytics-upgrade-prompt p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.analytics-upgrade-prompt .btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 600;
}

/* Premium Features Overlay */
.premium-overlay {
    position: relative;
}

.premium-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
}

.premium-overlay::before {
    content: '🔒 Upgrade to unlock advanced analytics';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 11;
    cursor: pointer;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .analytics-hero-card {
        background: rgba(31, 41, 55, 0.95);
        color: #f9fafb;
    }

    .card {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .card-header {
        background: #111827;
        border-color: #374151;
    }

    .insight-card {
        background: #1f2937;
        border-color: #374151;
    }

    .achievement-badge {
        background: #1f2937;
        border-color: #374151;
    }

    .live-activity-card {
        background: rgba(31, 41, 55, 0.9);
        color: #f9fafb;
    }
}

/* CRITICAL: Prevent canvas overflow */
.card-body canvas {
    max-width: 100% !important;
    max-height: 300px !important;
}

#responseTimelineChart,
#attendanceChart,
#guestBreakdownChart {
    max-width: 100% !important;
    max-height: 300px !important;
}

/* Fix chart containers */
.chart-container,
.card-body {
    overflow: hidden;
}

/* Print Styles */
@media print {
    .analytics-hero,
    .live-activity-card,
    .insight-action,
    .timeline-controls {
        display: none;
    }

    .card {
        border: 1px solid #000;
        break-inside: avoid;
        margin-bottom: 1rem;
    }

    .chart-container {
        height: auto;
    }
}

/* Enhanced Activity Feed Styles */
.activity-item {
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 0.75rem 0;
}

.activity-item:hover {
    background: rgba(59, 130, 246, 0.05);
    transform: translateX(2px);
}

.activity-icon {
    transition: all 0.2s ease;
}

.activity-item:hover .activity-icon {
    transform: scale(1.1);
}

/* Gentle Update Notification */
.gentle-update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gentle-update-notification.show {
    transform: translateX(0);
    opacity: 1;
}

/* Enhanced Insight Cards */
.insight-card {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.insight-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.insight-card.border-success {
    border-left-color: #10b981;
}

.insight-card.border-warning {
    border-left-color: #f59e0b;
}

.insight-card.border-info {
    border-left-color: #3b82f6;
}

.insight-card.border-primary {
    border-left-color: #8b5cf6;
}

/* Prediction-specific styling */
.insight-card.border-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #8b5cf6, #3b82f6);
    animation: predictiveGlow 2s ease-in-out infinite alternate;
}

@keyframes predictiveGlow {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .gentle-update-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
        transform: translateY(-100%);
    }

    .gentle-update-notification.show {
        transform: translateY(0);
    }
}
