/* ============================================
   AI-GENERATED INSIGHTS SYSTEM STYLES
   ============================================ */

/* AI Insights Dashboard */
.ai-insights-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
}

.ai-insights-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

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

.insight-summary-card {
    padding: 20px;
    border-radius: 10px;
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.insight-summary-card:hover {
    transform: translateY(-2px);
}

.insight-summary-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.insight-summary-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.insight-summary-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Insight Cards */
.insight-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    background: white;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.insight-card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.insight-card.critical {
    border-left: 4px solid #dc3545;
}

.insight-card.high {
    border-left: 4px solid #fd7e14;
}

.insight-card.medium {
    border-left: 4px solid #ffc107;
}

.insight-card.low {
    border-left: 4px solid #28a745;
}

.insight-card.opportunity {
    border-left: 4px solid #17a2b8;
}

/* Insight Header */
.insight-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.insight-badges {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.insight-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.insight-badge.severity {
    color: white;
}

.insight-badge.category {
    color: inherit;
    background: rgba(0,0,0,0.1);
}

.insight-badge.confidence {
    background: #f8f9fa;
    color: #6c757d;
    font-weight: normal;
}

.insight-title {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
}

.insight-message {
    margin: 0 0 15px 0;
    color: #5a6c7d;
    line-height: 1.5;
}

.insight-animals-count {
    margin-left: 15px;
    text-align: center;
    background: #ecf0f1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    min-width: 80px;
}

.insight-animals-number {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2c3e50;
}

.insight-animals-label {
    color: #7f8c8d;
    font-size: 0.8rem;
}

/* Insight Sections */
.insight-section {
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.insight-recommendations {
    background: #f8f9fa;
    border-left: 3px solid #17a2b8;
}

.insight-metrics {
    background: #e8f6f3;
    border-left: 3px solid #27ae60;
}

.insight-actions {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
}

.insight-section-title {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-recommendation-text {
    color: #5a6c7d;
    line-height: 1.6;
    white-space: pre-line;
}

/* Metrics Grid */
.insight-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.insight-metric-item {
    padding: 10px;
    background: rgba(255,255,255,0.7);
    border-radius: 5px;
}

.insight-metric-label {
    font-weight: 600;
    color: #2c3e50;
    text-transform: uppercase;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.insight-metric-value {
    color: #27ae60;
    font-weight: 500;
}

/* Action Buttons */
.insight-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.insight-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    transition: all 0.3s ease;
    text-transform: capitalize;
}

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

.insight-action-btn.high {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.insight-action-btn.medium {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.insight-action-btn.low {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

/* Insight Footer */
.insight-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.insight-timestamp {
    color: #7f8c8d;
    font-size: 0.8rem;
}

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

.insight-footer-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: white;
    transition: all 0.3s ease;
}

.insight-footer-btn.dismiss {
    background: #95a5a6;
}

.insight-footer-btn.done {
    background: #27ae60;
}

.insight-footer-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* AI Insights Floating Button */
.ai-insights-float-btn {
    position: fixed;
    bottom: 160px;
    left: 20px;
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-insights-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.6);
}

/* Notification Badge */
.ai-insights-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Loading States */
.insights-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 1.1rem;
}

.insights-loading::before {
    content: '🤖';
    font-size: 2rem;
    margin-right: 15px;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Empty State */
.insights-empty {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.insights-empty-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.insights-empty-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.insights-empty-text {
    line-height: 1.5;
}

/* Filters */
.insights-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.insights-filter {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.insights-filter.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.insights-filter:hover {
    border-color: #3498db;
}

/* Confidence Indicator */
.confidence-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: #6c757d;
}

.confidence-bar {
    width: 30px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc3545 0%, #ffc107 50%, #28a745 100%);
    transition: width 0.3s ease;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .ai-insights-content {
        margin: 20px;
        max-width: calc(100vw - 40px);
        padding: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .insights-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .insight-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .insight-animals-count {
        margin-left: 0;
        margin-top: 10px;
        align-self: flex-start;
    }
    
    .insight-metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .insight-actions-grid {
        flex-direction: column;
    }
    
    .insight-action-btn {
        width: 100%;
        text-align: center;
    }
    
    .insight-footer {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .ai-insights-float-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 140px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ai-insights-content {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .insight-card {
        background: #34495e;
        border-color: #4a5f7a;
        color: #ecf0f1;
    }
    
    .insight-title {
        color: #ecf0f1;
    }
    
    .insight-message {
        color: #bdc3c7;
    }
    
    .insight-section {
        background: #3a4a5c !important;
    }
    
    .insight-animals-count {
        background: #4a5f7a;
        color: #ecf0f1;
    }
    
    .insight-metric-item {
        background: rgba(255,255,255,0.1);
    }
    
    .insights-filter {
        background: #34495e;
        border-color: #4a5f7a;
        color: #ecf0f1;
    }
    
    .confidence-indicator {
        background: #4a5f7a;
        color: #bdc3c7;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .insight-card {
        border: 2px solid #000;
    }
    
    .insight-badge {
        border: 1px solid #000;
    }
    
    .insight-action-btn {
        border: 1px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ai-insights-content,
    .insight-card,
    .insight-action-btn,
    .ai-insights-float-btn {
        animation: none;
        transition: none;
    }
    
    .ai-insights-badge {
        animation: none;
    }
    
    .insights-loading::before {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .ai-insights-modal {
        position: static;
        background: none;
    }
    
    .ai-insights-content {
        box-shadow: none;
        max-height: none;
        overflow: visible;
    }
    
    .insight-card {
        break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .insight-footer-actions,
    .ai-insights-float-btn {
        display: none;
    }
    
    .insight-section {
        background: #f8f9fa !important;
    }
}

/* ============ FLOATING ACTION BUTTON ============ */
.ai-insights-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    animation: bounce 2s infinite;
}

.ai-insights-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
    animation: none;
}

.ai-insights-fab.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Loading Skeleton */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    height: 20px;
    margin-bottom: 10px;
}

/* Notification System */
.ai-insights-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10001;
    font-family: 'Montserrat', sans-serif;
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.ai-insights-notification.error {
    background: #e74c3c;
}

.ai-insights-notification.warning {
    background: #f39c12;
}

.ai-insights-notification.info {
    background: #3498db;
}
