/**
 * AI MDS Analysis Styles
 * تنسيقات لوحة تحليل MDS بالذكاء الاصطناعي
 */

/* =========================================
   Hero Card
   ========================================= */
.ai-hero-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

.ai-hero-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.ai-hero-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 8px;
}

.ai-hero-card p {
    opacity: 0.9;
    margin: 0;
    font-size: 0.9rem;
}

/* =========================================
   Tabs Navigation
   ========================================= */
.ai-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
}

.ai-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-tab:hover {
    background: #f8fafc;
    color: var(--primary, #667eea);
}

.ai-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.ai-tab svg {
    opacity: 0.8;
}

.ai-tab.active svg {
    opacity: 1;
}

/* =========================================
   Tab Content
   ========================================= */
.ai-tab-content {
    display: none;
}

.ai-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* =========================================
   Patient Info Card
   ========================================= */
.patient-info-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.patient-info-card .patient-avatar {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
}

.patient-info-card .patient-details {
    flex: 1;
}

.patient-info-card .patient-details h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 600;
}

.patient-info-card .patient-room {
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
}

/* =========================================
   MDS Form
   ========================================= */
.mds-form-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.mds-form-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 20px;
    font-size: 1.1rem;
    color: var(--text-primary, #1e293b);
}

.mds-form .form-row {
    display: flex;
    gap: 12px;
}

.mds-form .form-group {
    margin-bottom: 16px;
}

.mds-form .form-group.half {
    flex: 1;
}

.mds-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
}

.mds-form .form-control {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f8fafc;
}

.mds-form .form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.mds-form textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

.mds-form .form-actions {
    margin-top: 24px;
    text-align: center;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-primary, #1e293b);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* =========================================
   Analysis Results
   ========================================= */
.analysis-results {
    margin-top: 24px;
}

.result-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border-right: 4px solid #667eea;
}

.result-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-size: 1rem;
    color: var(--text-primary, #1e293b);
}

.result-icon {
    font-size: 1.3rem;
}

/* Specific card colors */
.diagnoses-card {
    border-right-color: #3b82f6;
}

.drg-card {
    border-right-color: #8b5cf6;
}

.procedures-card {
    border-right-color: #06b6d4;
}

.physician-card {
    border-right-color: #10b981;
}

.nursing-card {
    border-right-color: #f59e0b;
}

.gaps-card {
    border-right-color: #ef4444;
}

.aco-card {
    border-right-color: #ec4899;
}

/* Result content styling */
.result-card .diagnosis-item,
.result-card .procedure-item {
    padding: 12px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 8px;
}

.result-card .diagnosis-code {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 8px;
}

.result-card .diagnosis-description {
    font-size: 0.95rem;
    color: var(--text-primary, #1e293b);
}

.result-card .confidence-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #dcfce7;
    color: #166534;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 8px;
}

/* DRG specific styling */
.drg-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.drg-info-item {
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    text-align: center;
}

.drg-info-item .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 4px;
}

.drg-info-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.drg-info-item.drg-code .value {
    color: #8b5cf6;
    font-size: 1.4rem;
}

/* Gap items */
.gap-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: #fef2f2;
    border-radius: 10px;
    margin-bottom: 8px;
    border-right: 3px solid #ef4444;
}

.gap-item .gap-icon {
    color: #ef4444;
    flex-shrink: 0;
}

.gap-item .gap-text {
    font-size: 0.9rem;
    color: #991b1b;
}

/* ACO metrics */
.aco-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.aco-metric {
    padding: 15px;
    background: linear-gradient(135deg, #fdf4ff 0%, #fce7f3 100%);
    border-radius: 12px;
    text-align: center;
}

.aco-metric .metric-label {
    display: block;
    font-size: 0.8rem;
    color: #9333ea;
    margin-bottom: 4px;
}

.aco-metric .metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #7c3aed;
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* =========================================
   Loading Overlay
   ========================================= */
.ai-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ai-loading-content {
    text-align: center;
    color: white;
}

.ai-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.ai-loading-content p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* =========================================
   Section Headers
   ========================================= */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
}

/* =========================================
   Lists inside results
   ========================================= */
.result-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-list li {
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.result-list li::before {
    content: "•";
    color: #667eea;
    font-weight: bold;
}

/* =========================================
   Collapsible Sections
   ========================================= */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 0;
}

.collapsible-header .toggle-icon {
    transition: transform 0.3s ease;
}

.collapsible-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
}

/* =========================================
   Responsive Design
   ========================================= */
@media (max-width: 640px) {
    .ai-hero-card {
        padding: 24px 16px;
    }
    
    .ai-hero-card h1 {
        font-size: 1.3rem;
    }
    
    .ai-tabs {
        gap: 6px;
    }
    
    .ai-tab {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .ai-tab svg {
        display: none;
    }
    
    .mds-form .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .drg-info {
        grid-template-columns: 1fr;
    }
    
    .aco-metrics {
        grid-template-columns: 1fr;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn {
        width: 100%;
    }
    
    .patient-info-card {
        flex-wrap: wrap;
    }
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
    .ai-hero-card,
    .ai-tabs,
    .result-actions,
    .ai-loading-overlay {
        display: none !important;
    }
    
    .result-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
}

/* =========================================
   Additional Utility Classes
   ========================================= */
.text-muted {
    color: var(--text-secondary, #64748b);
    font-size: 0.9rem;
}

.text-success {
    color: #10b981;
}

.text-warning {
    color: #f59e0b;
}

.text-danger {
    color: #ef4444;
}

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* =========================================
   AI Analysis Widget on Patient Page
   ========================================= */
.ai-analysis-widget {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 20px;
    color: white;
    margin-bottom: 16px;
}

.ai-analysis-widget h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 1rem;
}

.ai-analysis-widget .ai-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    text-align: center;
    text-decoration: none;
}

.ai-analysis-widget .ai-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Quick stats in widget */
.ai-quick-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.ai-quick-stat {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px;
    border-radius: 10px;
    text-align: center;
}

.ai-quick-stat .stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
}

.ai-quick-stat .stat-value {
    font-size: 1rem;
    font-weight: 700;
}
