/* ===== لوحة التحكم الاحترافية — تصميم التبويبات والمتابعة =====
   طبقة فوق app.css (لا تُعدّل الملف الأصلي) */

/* شريط التبويبات */
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 8px; margin-bottom: 22px;
  box-shadow: var(--shadow); position: sticky; top: 84px; z-index: 30;
}
.tab {
  font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  padding: 12px 20px; border-radius: 12px; transition: .15s;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.tab:hover { background: var(--brand-soft); color: var(--brand-dark); }
.tab.active {
  background: linear-gradient(135deg, var(--brand), #0891b2); color: #fff;
  box-shadow: 0 8px 18px rgba(13,148,136,.35);
}
.tab .badge {
  background: rgba(255,255,255,.28); color: #fff; font-size: 12px; font-weight: 800;
  padding: 1px 9px; border-radius: 999px; min-width: 20px; text-align: center;
}
.tab:not(.active) .badge { background: var(--line); color: var(--muted); }
.tab .badge.alert { background: var(--red); color: #fff; }

.panel { display: none; animation: fadeIn .25s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

/* ===== تبويب المتابعة ===== */
.availability-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.availability-bar .av-dot {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: var(--green); box-shadow: 0 0 0 5px var(--green-soft);
}
.availability-bar.out .av-dot { background: var(--red); box-shadow: 0 0 0 5px #fee2e2; animation: pulseDot 1.4s infinite; }
@keyframes pulseDot { 50% { box-shadow: 0 0 0 9px rgba(220,38,38,.18); } }
.availability-bar b { font-size: 17px; }
.availability-bar .av-note { color: var(--muted); font-size: 14px; }

.monitor-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.dept-status-card {
  background: var(--surface); border: 2px solid var(--line); border-radius: 18px;
  padding: 18px; box-shadow: var(--shadow); transition: .2s; position: relative; overflow: hidden;
}
.dept-status-card .dsc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dept-status-card .dsc-icon { font-size: 30px; }
.dept-status-card .dsc-name { font-size: 19px; font-weight: 800; }
.dsc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dsc-stat {
  text-align: center; border-radius: 10px; padding: 8px 4px; background: #f8fafc;
}
.dsc-stat .n { font-size: 22px; font-weight: 800; display: block; line-height: 1.1; }
.dsc-stat .l { font-size: 11px; color: var(--muted); }
.dsc-stat.s-ack .n { color: var(--green); }
.dsc-stat.s-pending .n { color: var(--amber); }
.dsc-stat.s-noresp .n { color: var(--red); }

/* علم القسم */
.dept-status-card.flag-pending { border-color: var(--amber); }
.dept-status-card.flag-no_response {
  border-color: var(--red); background: linear-gradient(180deg, #fff5f5, var(--surface));
  animation: cardFlash 1.1s ease-in-out infinite;
}
@keyframes cardFlash {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
  50%     { box-shadow: 0 0 0 6px rgba(220,38,38,.18); }
}
.flag-mark {
  position: absolute; top: 12px; inset-inline-end: 12px;
  font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
}
.flag-mark.pending { background: #fef3c7; color: var(--amber); }
.flag-mark.no_response { background: var(--red); color: #fff; }

/* عدّاد البطاقات في الجدول */
.countdown { font-weight: 800; font-variant-numeric: tabular-nums; }
.countdown.warn { color: var(--amber); }
.countdown.crit { color: var(--red); animation: pulseDot 1s infinite; }
.countdown.expired { color: var(--red-dark); }

/* ووسوم الحالة النهائية */
.final-tag {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 800; white-space: nowrap;
}
.final-tag.no_response { background: #fee2e2; color: var(--red-dark); }
.final-tag.pending { background: #fef3c7; color: var(--amber); }
.final-tag.acknowledged { background: var(--green-soft); color: var(--green); }

/* بطاقات مفتوحة (بديل الجدول على الشاشات الصغيرة) */
.monitor-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.mc-card {
  border-radius: var(--radius); padding: 18px; background: var(--surface);
  border: 2px solid var(--line); box-shadow: var(--shadow);
}
.mc-card.no_response { border-color: var(--red); background: linear-gradient(180deg, #fff5f5, var(--surface)); }
.mc-card .mc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.mc-card .mc-clinic { font-size: 22px; font-weight: 800; }
.mc-card .mc-dept { color: var(--muted); font-size: 14px; font-weight: 700; }
.mc-card .mc-patient { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.mc-card .mc-patient span { color: var(--muted); font-size: 12px; }
.mc-card .mc-patient b { font-size: 15px; }
.mc-card .mc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* ===== تبويب الإعدادات ===== */
.settings-form {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow); max-width: 620px;
}
.settings-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.settings-form .field { gap: 7px; }
.settings-form .field label { font-weight: 700; font-size: 14px; color: var(--muted); }
.settings-form .field input { font-family: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; }
.settings-form .field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.settings-form .hint { color: var(--muted); font-size: 13px; margin: -6px 0 18px; }
.settings-form .preview-box {
  background: var(--brand-soft); border: 1px dashed var(--brand); border-radius: 12px;
  padding: 12px 16px; margin: 18px 0; font-weight: 700; color: var(--brand-dark);
  display: flex; align-items: center; gap: 10px;
}

/* استجابة الشاشات الصغيرة */
@media (max-width: 720px) {
  .tabs { top: 76px; padding: 6px; }
  .tab { padding: 10px 14px; font-size: 14px; }
  .monitor-grid { grid-template-columns: 1fr; }
  .settings-form .field-row { grid-template-columns: 1fr; }
  .availability-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ===== الوضع الليلي ===== */
[data-theme="dark"] .tab.active { background: linear-gradient(135deg, var(--brand), #0891b2); }
[data-theme="dark"] .dsc-stat,
[data-theme="dark"] .mc-patient { background: var(--surface-2); }
[data-theme="dark"] .dept-status-card.flag-no_response { background: linear-gradient(180deg, #3a1518, var(--surface)); }
[data-theme="dark"] .mc-card.no_response { background: linear-gradient(180deg, #3a1518, var(--surface)); }
[data-theme="dark"] .settings-form .field input,
[data-theme="dark"] .settings-form .field input:focus { background: var(--surface); color: var(--ink); }
[data-theme="dark"] .final-tag.pending { background: #422006; color: var(--amber); }
[data-theme="dark"] .flag-mark.pending { background: #422006; color: var(--amber); }
[data-theme="dark"] .availability-bar.out .av-dot { background: var(--red); }
