/**
 * assets/css/ai_expert.css
 * الهدف: تصميم متقدم لقسم خبير التحليل الفني
 * يحتوي على: تصميم حديث، رسوم متحركة، تخطيط متجاوب
 */

/* متغيرات CSS للألوان والقيم */
:root {
    --ai-primary: #4ea1ff;
    --ai-secondary: #10b981;
    --ai-accent: #f59e0b;
    --ai-danger: #ef4444;
    --ai-warning: #f59e0b;
    --ai-success: #10b981;
    --ai-dark: #1f2937;
    --ai-light: #f8fafc;
    --ai-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --ai-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --ai-shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.15);
    --ai-border-radius: 12px;
    --ai-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* الحاوي الرئيسي لخبير التحليل الفني */
.ai-expert-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
}

/* رأس القسم */
.ai-expert-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.ai-expert-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ai-expert-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* الزر العائم للروبوت الذكي */
.floating-robot {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: var(--ai-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    cursor: pointer;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    z-index: 1000;
    animation: float 3s ease-in-out infinite;
}

.floating-robot:hover {
    transform: scale(1.1);
    box-shadow: var(--ai-shadow-hover);
}

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

/* التبويبات */
.ai-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--ai-border-radius);
    padding: 5px;
    backdrop-filter: blur(10px);
}

.ai-tab {
    padding: 12px 24px;
    margin: 0 5px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: var(--ai-border-radius);
    transition: var(--ai-transition);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.ai-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.ai-tab:hover::before {
    left: 100%;
}

.ai-tab.active {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.ai-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* محتوى التبويبات */
.ai-content {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--ai-border-radius);
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--ai-shadow);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease-in-out;
}

.ai-content.active {
    display: block;
}

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

/* شبكة الميزات */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.feature-card {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 25px;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--ai-gradient);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--ai-shadow-hover);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

.feature-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--ai-dark);
}

.feature-description {
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 15px;
}

.feature-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ai-success);
}

.status-training {
    background: rgba(245, 158, 11, 0.1);
    color: var(--ai-warning);
}

.status-inactive {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

/* المساعد الذكي */
.ai-assistant {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 25px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

.chat-container {
    height: 400px;
    border: 1px solid #e5e7eb;
    border-radius: var(--ai-border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: var(--ai-gradient);
    color: white;
    padding: 15px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
}

.message {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: var(--ai-border-radius);
    max-width: 80%;
    animation: slideIn 0.3s ease-out;
}

.message.user {
    background: var(--ai-primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.ai {
    background: white;
    border: 1px solid #e5e7eb;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

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

.chat-input {
    display: flex;
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
}

.chat-input input:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.1);
}

.chat-input button {
    margin-left: 10px;
    padding: 10px 20px;
    background: var(--ai-primary);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--ai-transition);
}

.chat-input button:hover {
    background: #3b82f6;
    transform: scale(1.05);
}

/* الرسوم البيانية */
.chart-container {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 25px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

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

.chart-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--ai-dark);
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.chart-controls select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

/* المؤشرات البيئية */
.environmental-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ai-shadow-hover);
}

.metric-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.metric-label {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 5px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ai-dark);
    margin-bottom: 10px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-good {
    background: var(--ai-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.status-warning {
    background: var(--ai-warning);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.status-danger {
    background: var(--ai-danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite;
}

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

/* الرؤى والتحليلات */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.insight-card {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    border-left: 4px solid var(--ai-primary);
}

.insight-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ai-shadow-hover);
}

.insight-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

.insight-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ai-dark);
    margin-bottom: 10px;
}

.insight-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ai-primary);
}

/* إدارة المديولات */
.modules-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.module-card {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 25px;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.module-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--ai-shadow-hover);
}

.module-status {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.module-card h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--ai-dark);
}

.module-card p {
    color: #6b7280;
    margin-bottom: 10px;
    line-height: 1.5;
}

.module-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.module-actions button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--ai-transition);
}

.btn-primary {
    background: var(--ai-primary);
    color: white;
}

.btn-primary:hover {
    background: #3b82f6;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--ai-dark);
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* الملخص اليومي */
.daily-summary {
    background: white;
    border-radius: var(--ai-border-radius);
    padding: 25px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

.summary-header h3 {
    color: var(--ai-dark);
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.summary-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.summary-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid var(--ai-primary);
}

.metric-label {
    font-weight: 500;
    color: #6b7280;
}

.metric-value {
    font-weight: 700;
    color: var(--ai-dark);
}

.summary-text {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 15px;
    color: #0c4a6e;
    line-height: 1.6;
}

/* الإشعارات */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: var(--ai-border-radius);
    color: white;
    font-weight: 500;
    z-index: 1100;
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
    box-shadow: var(--ai-shadow);
}

.notification-success {
    background: var(--ai-success);
}

.notification-error {
    background: var(--ai-danger);
}

.notification-warning {
    background: var(--ai-warning);
}

.notification-info {
    background: var(--ai-primary);
}

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

/* Prediction Overview Styles */
.prediction-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.prediction-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--ai-shadow);
}

.prediction-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--ai-primary), var(--ai-secondary));
}

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

.prediction-card .prediction-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.prediction-card h4 {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.prediction-card .prediction-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ai-dark);
    margin-bottom: 5px;
}

.prediction-card .prediction-change {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.prediction-change.positive {
    color: var(--ai-success);
}

.prediction-change.negative {
    color: var(--ai-danger);
}

.prediction-change.neutral {
    color: var(--ai-warning);
}

.prediction-change.warning {
    color: var(--ai-warning);
}

.prediction-card .prediction-date {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Chart Controls */
.chart-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chart-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #6b7280;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-btn:hover {
    background: var(--ai-primary);
    color: white;
    border-color: var(--ai-primary);
}

.chart-btn.active {
    background: var(--ai-primary);
    color: white;
    border-color: var(--ai-primary);
}

/* Chart Legend */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #6b7280;
}

.legend-color {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.legend-color.actual {
    background: var(--ai-primary);
}

.legend-color.predicted {
    background: var(--ai-secondary);
}

.legend-color.confidence {
    background: var(--ai-warning);
    opacity: 0.6;
}

/* Alert Styles */
.alerts-container .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-count {
    background: var(--ai-danger);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.alert-item {
    display: flex;
    gap: 12px;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid;
    background: #f9fafb;
    transition: all 0.2s ease;
}

.alert-item:hover {
    transform: translateX(2px);
    box-shadow: var(--ai-shadow);
}

.alert-item.high-priority {
    border-left-color: var(--ai-danger);
    background: rgba(239, 68, 68, 0.05);
}

.alert-item.medium-priority {
    border-left-color: var(--ai-warning);
    background: rgba(245, 158, 11, 0.05);
}

.alert-item.low-priority {
    border-left-color: var(--ai-primary);
    background: rgba(78, 161, 255, 0.05);
}

.alert-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-content h4 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    color: var(--ai-dark);
}

.alert-content p {
    margin: 0 0 10px 0;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

.action-btn {
    padding: 4px 8px;
    background: var(--ai-primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #3b82f6;
    transform: translateY(-1px);
}

.alert-time {
    font-size: 0.75rem;
    color: #9ca3af;
    flex-shrink: 0;
    align-self: flex-start;
}

/* Trend Analysis */
.trend-analysis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

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

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

.trend-header h4 {
    margin: 0;
    color: var(--ai-dark);
    font-size: 1rem;
}

.trend-indicator {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.trend-indicator.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ai-success);
}

.trend-indicator.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--ai-danger);
}

.trend-indicator.stable {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.trend-details p {
    margin: 0 0 15px 0;
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.4;
}

.trend-chart-mini {
    height: 60px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    position: relative;
    overflow: hidden;
}

.trend-chart-mini::after {
    content: '📊';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    opacity: 0.3;
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: var(--ai-dark);
    font-size: 0.85rem;
    cursor: pointer;
}

.control-btn {
    padding: 8px;
    border: 1px solid #d1d5db;
    background: white;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--ai-primary);
    color: white;
    border-color: var(--ai-primary);
}

/* التصميم المتجاوب */
@media (max-width: 768px) {
    .ai-expert-container {
        padding: 15px;
    }
    
    .ai-expert-header h1 {
        font-size: 2rem;
    }
    
    .ai-tabs {
        flex-direction: column;
        gap: 5px;
    }
    
    .ai-tab {
        margin: 0;
        text-align: center;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .environmental-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
    
    .modules-container {
        grid-template-columns: 1fr;
    }
    
    .floating-robot {
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .chat-container {
        height: 300px;
    }
    
    .module-actions {
        flex-direction: column;
    }
    
    .module-actions button {
        width: 100%;
    }
    
    .prediction-overview {
        grid-template-columns: 1fr;
    }
    
    .trend-analysis {
        grid-template-columns: 1fr;
    }
    
    .chart-controls {
        justify-content: center;
    }
    
    .header-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .environmental-metrics {
        grid-template-columns: 1fr;
    }
    
    .summary-metrics {
        grid-template-columns: 1fr;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .chart-controls {
        width: 100%;
        justify-content: flex-start;
    }
}

/* تحسينات إضافية للأداء */
.ai-content {
    will-change: transform, opacity;
}

.feature-card,
.metric-card,
.insight-card,
.module-card {
    will-change: transform, box-shadow;
}

/* تأثيرات التحميل */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* تخصيص شريط التمرير */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}