/**
 * Enhanced Clinical Analysis Styles
 * تنسيقات لوحة التحليل السريري المتقدم
 */

/* =========================================
   Hero Card
   ========================================= */
.clinical-hero-card {
    background: linear-gradient(135deg, #0d9488 0%, #0891b2 50%, #0284c7 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(13, 148, 136, 0.3);
    position: relative;
    overflow: hidden;
}

.clinical-hero-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%);
    pointer-events: none;
}

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

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

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

.hero-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.feature-badge {
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* =========================================
   Quick Actions Bar
   ========================================= */
.quick-actions-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 10px;
    background: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.quick-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

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

.quick-action-btn .action-icon {
    font-size: 1.5rem;
}

.quick-action-btn .action-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-align: center;
}

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

.patient-avatar-lg {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}

.patient-info-content {
    flex: 1;
    min-width: 200px;
}

.patient-info-content h2 {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.patient-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
}

.meta-badge svg {
    opacity: 0.7;
}

.last-analysis-badge {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    padding: 10px 16px;
    border-radius: 12px;
    text-align: center;
}

.last-analysis-badge .badge-label {
    display: block;
    font-size: 0.7rem;
    color: #059669;
    margin-bottom: 2px;
}

.last-analysis-badge .badge-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #047857;
}

/* =========================================
   Analysis Summary Grid
   ========================================= */
.analysis-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: white;
    padding: 16px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.summary-card .summary-icon {
    font-size: 1.8rem;
}

.summary-card .summary-content {
    flex: 1;
}

.summary-card .summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 2px;
}

.summary-card .summary-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.summary-card .summary-value.good {
    color: #059669;
}

.summary-card .summary-value.warning {
    color: #d97706;
}

.summary-card .summary-value.danger {
    color: #dc2626;
}

/* =========================================
   Patient Selector Card
   ========================================= */
.patient-selector-card {
    background: white;
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    text-align: center;
}

.patient-selector-card h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: var(--text-primary, #1e293b);
}

.patient-selector-card .form-control-lg {
    padding: 14px 18px;
    font-size: 1rem;
}

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

.clinical-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    background: white;
    border: none;
    border-radius: 12px;
    font-size: 0.85rem;
    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);
}

.clinical-tab:hover {
    background: #f8fafc;
    color: #0d9488;
}

.clinical-tab.active {
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

.clinical-tab svg {
    opacity: 0.8;
    width: 18px;
    height: 18px;
}

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

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

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

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

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

.form-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

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

.section-title svg {
    color: #0d9488;
}

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

.form-row.two-cols .form-group {
    flex: 1;
}

.form-row.three-cols .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 14px;
}

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

.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;
}

.form-control:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
    background: white;
}

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

.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 14px;
    font-size: 0.8rem;
}

.btn-primary {
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
}

.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;
}

/* =========================================
   Results Container
   ========================================= */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

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

.section-icon {
    font-size: 1.2rem;
}

.section-content {
    font-size: 0.95rem;
    color: var(--text-primary, #1e293b);
    line-height: 1.6;
}

.placeholder-text {
    color: var(--text-secondary, #64748b);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Section Colors */
.diagnosis-section { border-right-color: #3b82f6; }
.secondary-diagnosis-section { border-right-color: #6366f1; }
.symptoms-section { border-right-color: #8b5cf6; }
.procedures-section { border-right-color: #06b6d4; }
.imaging-section { border-right-color: #0ea5e9; }
.physio-section { border-right-color: #14b8a6; }
.consultations-section { border-right-color: #10b981; }
.admission-section { border-right-color: #22c55e; }
.stay-section { border-right-color: #84cc16; }
.discharge-section { border-right-color: #eab308; }
.completeness-section { border-right-color: #f59e0b; }
.inconsistencies-section { border-right-color: #ef4444; }
.drg-section { border-right-color: #ec4899; }
.rejection-section { border-right-color: #f43f5e; }
.summary-section { border-right-color: #a855f7; }
.suggestions-section { border-right-color: #6366f1; }

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

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

.clinical-loading-content {
    text-align: center;
    color: white;
    max-width: 300px;
}

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

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

.clinical-loading-content p {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 20px;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loading-step {
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.loading-step.active {
    opacity: 1;
    background: rgba(13, 148, 136, 0.3);
    border-right: 3px solid #0d9488;
}

.loading-step.completed {
    opacity: 1;
    background: rgba(16, 185, 129, 0.3);
}

.loading-step.completed::before {
    content: '✓ ';
}

/* =========================================
   Modal
   ========================================= */
.clinical-modal {
    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: 9998;
    padding: 20px;
}

.clinical-modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}

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

.clinical-modal-content .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.clinical-modal-content .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.clinical-modal-content .modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.clinical-modal-content .modal-close:hover {
    background: #f1f5f9;
    color: var(--text-primary, #1e293b);
}

.clinical-modal-content .modal-body {
    padding: 20px;
}

.generated-note-content {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    margin: 12px 0;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.generated-note-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* =========================================
   Data Display Components
   ========================================= */
.diagnosis-item {
    padding: 14px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 10px;
}

.diagnosis-item.principal {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-right: 4px solid #10b981;
}

.diagnosis-code {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 8px;
}

.diagnosis-description {
    font-size: 0.95rem;
    color: var(--text-primary, #1e293b);
    margin-top: 6px;
}

.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;
}

.procedure-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 8px;
}

.procedure-item .procedure-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.procedure-item .procedure-details {
    flex: 1;
}

.procedure-item .procedure-name {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.procedure-item .procedure-code {
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.completed {
    background: #dcfce7;
    color: #166534;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

/* Completeness Meter */
.completeness-meter {
    margin: 16px 0;
}

.meter-bar {
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}

.meter-fill.good { background: linear-gradient(90deg, #10b981 0%, #059669 100%); }
.meter-fill.warning { background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%); }
.meter-fill.danger { background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%); }

.meter-label {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
}

/* Missing Items List */
.missing-items-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

.missing-items-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #991b1b;
}

.missing-items-list li::before {
    content: '⚠️';
}

/* Suggestion Cards */
.suggestion-card {
    padding: 14px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 12px;
    margin-bottom: 10px;
    border-right: 4px solid #3b82f6;
}

.suggestion-card.high-priority {
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
    border-right-color: #ef4444;
}

.suggestion-card.medium-priority {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-right-color: #f59e0b;
}

.suggestion-card .suggestion-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.suggestion-card .suggestion-text {
    font-size: 0.9rem;
    color: var(--text-primary, #1e293b);
}

/* =========================================
   Responsive Design
   ========================================= */
@media (max-width: 768px) {
    .quick-actions-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .analysis-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .clinical-tabs {
        gap: 4px;
    }
    
    .clinical-tab {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    
    .clinical-tab svg {
        display: none;
    }
    
    .analysis-actions {
        flex-direction: column;
    }
    
    .analysis-actions .btn {
        width: 100%;
    }
    
    .patient-info-enhanced {
        flex-direction: column;
        text-align: center;
    }
    
    .patient-meta-row {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .quick-actions-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .analysis-summary-grid {
        grid-template-columns: 1fr;
    }
    
    .clinical-hero-card {
        padding: 20px 16px;
    }
    
    .clinical-hero-card h1 {
        font-size: 1.3rem;
    }
    
    .hero-features {
        flex-direction: column;
        gap: 6px;
    }
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
    .clinical-hero-card,
    .quick-actions-bar,
    .clinical-tabs,
    .analysis-actions,
    .clinical-loading-overlay,
    .clinical-modal,
    .btn {
        display: none !important;
    }
    
    .clinical-tab-content {
        display: block !important;
    }
    
    .result-section {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e2e8f0;
        margin-bottom: 12px;
    }
}
