/* قسم الوقاية والعلاج — أنماط مستقلة */

.health-workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.health-hero {
    background: linear-gradient(135deg, #9f1239 0%, #be123c 40%, #e11d48 100%);
    border: none;
    color: #fff;
    padding: 0;
    overflow: hidden;
}

.health-hero-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
}

.health-hero-text h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.health-hero-text p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.88rem;
}

.health-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.health-hero-stat {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 88px;
    text-align: center;
}

.health-hero-stat-val {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
}

.health-hero-stat-lbl {
    display: block;
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 2px;
}

.health-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
}

.health-subtab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s;
}

.health-subtab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.health-subtab.active {
    background: linear-gradient(135deg, #be123c, #e11d48);
    color: #fff;
    font-weight: 600;
}

.health-module-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.health-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.health-env-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.health-env-tab {
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
}

.health-env-tab.active {
    border-color: #e11d48;
    color: #fda4af;
    background: rgba(225, 29, 72, 0.1);
}

.health-alert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.health-alert-card {
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
}

.health-alert-card.level-طوارئ,
.health-alert-card.level-emergency {
    border-color: #991b1b;
    background: rgba(153, 27, 27, 0.12);
}

.health-alert-card.level-خطر,
.health-alert-card.level-danger {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.health-alert-card.level-تحذير,
.health-alert-card.level-warning {
    border-color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

.health-alert-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.health-alert-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
}

.health-disease-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.health-disease-card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px;
    background: var(--card-bg);
}

.health-disease-card h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: #fda4af;
}

.health-disease-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.health-tag {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
}

.health-tag.severity-high,
.health-tag.severity-critical {
    border-color: #ef4444;
    color: #fca5a5;
}

.health-disease-detail {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.health-disease-detail strong {
    color: var(--text-primary);
}

.health-treatment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.health-treatment-card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px;
    background: var(--card-bg);
}

.health-treatment-card h3 {
    margin: 0 0 8px;
    font-size: 0.92rem;
}

.health-prev-card .health-disease-meta {
    margin-bottom: 8px;
}

.health-protocol-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.health-protocol-item {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--card-bg);
}

.health-protocol-item h4 {
    margin: 0 0 6px;
    font-size: 0.9rem;
}

.health-emergency-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.health-emergency-card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px;
    background: var(--card-bg);
}

.health-emergency-card.critical {
    border-color: #991b1b;
}

.health-emergency-scope .card-header p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.health-emergency-scope-tag {
    display: inline-block;
    margin-right: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(180, 83, 9, 0.15);
    color: #b45309;
    vertical-align: middle;
}

.health-steps {
    margin: 10px 0 0;
    padding-right: 18px;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.health-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.health-form-grid .form-group {
    margin: 0;
}

.health-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: 10px;
}

.health-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.health-table th,
.health-table td {
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid var(--card-border);
}

.health-table th {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.health-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.health-edit-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.12);
    font-size: 0.9rem;
}

.health-row-actions {
    white-space: nowrap;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.health-vet-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.health-vet-modal.hidden { display: none; }
.health-vet-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}
.health-vet-modal-panel {
    position: relative;
    width: min(720px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #0f172a);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
}
.health-vet-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border, #e2e8f0);
}
.health-vet-modal-head h3 { margin: 0; font-size: 1rem; }
.health-vet-modal-body { padding: 14px 16px; }
.health-vet-view-dl { margin: 0; display: grid; gap: 8px; }
.health-vet-view-dl > div {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--card-border, #e2e8f0);
}
.health-vet-view-dl dt { font-weight: 700; color: var(--text-muted, #64748b); }
.health-vet-view-dl dd { margin: 0; white-space: pre-wrap; }
.health-vet-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--card-border, #e2e8f0);
}

.health-month-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    line-height: 1.3;
}

.btn-danger {
    background: #b91c1c;
    border-color: #991b1b;
    color: #fff;
}

.btn-danger:hover {
    background: #991b1b;
}

.health-field-hint {
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
    font-size: 0.85em;
}

.health-field-help {
    display: block;
    margin-top: 4px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.78rem;
    line-height: 1.35;
}

.health-table .alert-danger { color: #f87171; font-weight: 600; }
.health-table .alert-watch { color: #fb923c; font-weight: 600; }
.health-table .alert-warning { color: #fbbf24; font-weight: 600; }
.health-table .alert-emergency { color: #ef4444; font-weight: 700; }

.health-alert-card.level-مراقبة,
.health-alert-card.level-watch {
    border-color: #ea580c;
    background: rgba(234, 88, 12, 0.1);
}

.health-dose-result {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    font-size: 0.85rem;
}

.health-report-box {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 14px;
    background: var(--card-bg);
}

.health-empty {
    text-align: center;
    padding: 28px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.health-daily-link-note {
    margin: 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.health-daily-link-note i {
    color: #60a5fa;
    margin-left: 6px;
}

.health-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

@media (max-width: 768px) {
    .health-subtab span { display: none; }
    .health-hero-content { flex-direction: column; align-items: flex-start; }
}

.health-unified-treat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.health-unified-treat-grid .health-treatment-card {
    min-height: 100%;
}

.health-local-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.health-local-card {
    display: flex;
    gap: 12px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    background: var(--card-bg);
    align-items: flex-start;
}

.health-local-card-media {
    flex: 0 0 110px;
    width: 110px;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--card-border);
}

.health-local-card-media img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.health-local-card-body {
    flex: 1;
    min-width: 0;
}

.health-local-card-body h3 {
    margin: 0 0 8px;
    font-size: 0.92rem;
    color: #fda4af;
    line-height: 1.35;
}

.health-local-card-body h3 small {
    display: block;
    font-size: 0.75rem;
    opacity: 0.65;
    font-weight: 400;
}

@media (max-width: 520px) {
    .health-local-card {
        flex-direction: column;
    }
    .health-local-card-media {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
}

/* ─── طباعة تقارير صحة الكارب — A4 موحّد ─── */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 14mm;
    }

    body.printing-health > *:not(#healthPrintSheet) {
        display: none !important;
        visibility: hidden !important;
    }

    body.printing-health #healthPrintSheet {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        color: #111 !important;
    }

    #healthPrintSheet .health-print-table {
        font-size: 9pt;
    }

    #healthPrintSheet .health-print-table td {
        text-align: center;
    }

    #healthPrintSheet .health-print-empty {
        text-align: center;
        color: #64748b;
        padding: 16px;
    }

    #healthPrintSheet .health-print-signs {
        display: flex;
        gap: 18px;
        margin-top: 22px;
        page-break-inside: avoid;
    }

    #healthPrintSheet .health-print-sign-box {
        flex: 1;
        border: 1px solid #cbd5e1;
        border-radius: 6px;
        padding: 12px 14px;
        min-height: 88px;
    }

    #healthPrintSheet .health-print-sign-title {
        font-weight: 700;
        font-size: 10pt;
        margin-bottom: 18px;
    }

    #healthPrintSheet .health-print-sign-line {
        border-bottom: 1px solid #94a3b8;
        min-height: 22px;
        margin-bottom: 8px;
    }

    #healthPrintSheet .health-print-sign-meta {
        font-size: 8.5pt;
        color: #64748b;
    }

    #healthPrintSheet .health-print-note {
        margin-top: 16px;
        font-size: 8.5pt;
        color: #64748b;
        text-align: center;
    }
}
