/* =========================
   ROOT VARIABLES
   ========================= */
:root{
  --bg:#eef2f6;
  --card:#f7f9fc;
  --panel:#ffffff;
  --muted:#6b7280;
  --text:#0f172a;

  --border:#e5e7eb;
  --border2:#d1d5db;

  --accent:#2563eb;
  --accentSoft:#eaf1ff;

  --ok:#16a34a;
  --danger:#dc2626;

  --shadow:0 10px 26px rgba(15,23,42,.08);
  --shadow2:0 16px 40px rgba(15,23,42,.14);

  --radius:16px;

  --fieldBg:#e2e8f0;
  --fieldBg2:#dbe3ee;
  --fieldBorder:#cbd5e1;
}

/* =========================
   RESET & BASE
   ========================= */
*{box-sizing:border-box;margin:0;padding:0}

body{
  font-family:"Cairo",system-ui;
  background:var(--bg);
  color:var(--text);
  font-size:14px;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

/* =========================
   HEADER
   ========================= */
header{
  background:var(--panel);
  border-bottom:1px solid var(--border);
}

.nav{
  max-width:1100px;
  margin:auto;
  padding:12px 16px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  min-width:0;
}

.logoLink,
.brandTitleLink{
  text-decoration:none;
  color:inherit;
}

.logo{
  width:38px;
  height:38px;
  border-radius:14px;
  background:linear-gradient(135deg,#2563eb,#1d4ed8);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  letter-spacing:.4px;
  box-shadow:0 10px 22px rgba(37,99,235,.25);
}

.brandText{min-width:0}

.title{
  font-weight:800;
  line-height:1.2;
}

.subtitle{
  font-size:12px;
  color:var(--muted);
  line-height:1.35;
}

.pill{
  background:#f8fafc;
  border:1px solid var(--border);
  border-radius:999px;
  padding:7px 12px;
  display:flex;
  gap:8px;
  align-items:center;
  color:#334155;
  font-size:12px;
  box-shadow:0 6px 18px rgba(15,23,42,.05);
}

.dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--ok);
}

.sep{opacity:.5}

/* =========================
   MAIN
   ========================= */
main{
  max-width:1100px;
  margin:auto;
  width:100%;
  padding:18px 12px 26px;
}

h1{
  font-size:20px;
  margin-bottom:6px;
  font-weight:800;
}

.desc{
  font-size:13px;
  color:var(--muted);
  max-width:720px;
  line-height:1.7;
}

/* =========================
   TOOLBAR
   ========================= */
.toolbar{
  margin:16px 0 12px;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:space-between;
  align-items:center;
}

.search{
  flex:1;
  min-width:260px;
}

.search input{
  width:100%;
  border-radius:999px;
  border:1px solid var(--border2);
  padding:10px 14px;
  background:var(--panel);
  outline:none;
}

.filters{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

select{
  border-radius:999px;
  border:1px solid var(--border2);
  padding:9px 12px;
  background:var(--panel);
}

.counter{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:999px;
  padding:7px 12px;
  font-size:12px;
  color:#334155;
}

/* =========================
   LIST
   ========================= */
.box{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}

.head{
  display:grid;
  grid-template-columns:2.4fr 1.4fr 110px;
  gap:10px;
  background:#f0f4fb;
  padding:10px 14px;
  font-size:12px;
  color:#64748b;
  border-bottom:1px solid var(--border);
}

ul{list-style:none}

li{
  position:relative;
  border-bottom:1px solid var(--border);
  background:var(--panel);
}

li:nth-child(even){background:#fbfcff}
li:hover{background:#f4f7ff}
li.open{
  background:#f2f7ff;
  box-shadow:var(--shadow2);
  z-index:2;
}

li::before{
  content:"";
  position:absolute;
  left:0;top:0;
  height:100%;
  width:5px;
  background:#cbd5e1;
}

li.hdRow::before{background:var(--ok)}
li.sdRow::before{background:var(--danger)}
li.typeRow::before{background:#7c3aed}

.row{
  display:grid;
  grid-template-columns:2.4fr 1.4fr 110px;
  gap:10px;
  padding:12px 14px;
  align-items:center;
  cursor:pointer;
}

.left{
  display:flex;
  gap:12px;
  align-items:center;
  min-width:0;
}

.avatar{
  width:40px;
  height:40px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--accentSoft);
  color:var(--accent);
  font-weight:800;
  border:1px solid #dbe7ff;
}

.leftText{min-width:0}

.name{
  font-weight:800;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.org{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.badges{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.badge{
  border:1px solid var(--border);
  border-radius:999px;
  padding:4px 10px;
  font-size:11px;
  font-weight:600;
}

.hd{background:#dcfce7;color:#166534;border-color:#bbf7d0}
.sd{background:#fee2e2;color:#b91c1c;border-color:#fecaca}
.b24{background:#dbeafe;color:#1d4ed8;border-color:#bfdbfe}
.sched{background:#fef3c7;color:#92400e;border-color:#fde68a}
.type{background:#ede9fe;color:#5b21b6;border-color:#ddd6fe}

.toggle{text-align:right}

.btn{
  border:1px solid var(--border2);
  border-radius:999px;
  padding:8px 14px;
  background:var(--panel);
  font-weight:600;
}

/* =========================
   DETAILS
   ========================= */
.details{display:none;padding:14px 16px}
li.open .details{display:block}

.detailsCard{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  box-shadow:0 10px 24px rgba(15,23,42,.06);
}

.field{
  display:grid;
  grid-template-columns:120px 1fr;
  gap:12px;
  margin-bottom:12px;
}

.label{
  font-weight:700;
  font-size:12px;
  color:#475569;
}

.inputWrap{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--fieldBorder);
  background:var(--fieldBg);
  border-radius:999px;
  padding:6px 8px;
}

.text{
  flex:1;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-family:ui-monospace, monospace;
}

.iconBtn{
  width:28px;
  height:28px;
  border-radius:999px;
  border:1px solid var(--border2);
  background:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}

.iconBtn svg{
  width:15px;
  height:15px;
}

/* =========================
   SPLIT
   ========================= */
.splitBox{
  border:1px solid var(--border);
  background:var(--fieldBg2);
  border-radius:18px;
  padding:12px;
}

.splitGrid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
}

.miniLabel{
  font-size:11px;
  font-weight:700;
  margin-bottom:6px;
}

.note{
  margin-top:12px;
  font-size:11px;
  color:var(--muted);
}

.note span{
  background:#eef2ff;
  color:#1d4ed8;
  border-radius:999px;
  padding:4px 10px;
  font-weight:700;
}

/* =========================
   LOADER (واضح وفي المنتصف)
   ========================= */
.loaderOverlay{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(15,23,42,.45);
  z-index:2147483647;
}

@supports (backdrop-filter: blur(6px)){
  .loaderOverlay{backdrop-filter:blur(6px);}
}

.loaderCard{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:20px;
  box-shadow:var(--shadow2);
  padding:18px 22px;
  display:flex;
  align-items:center;
  gap:14px;
  min-width:260px;
}

.spinner{
  width:26px;
  height:26px;
  border-radius:50%;
  border:4px solid rgba(37,99,235,.25);
  border-top-color:var(--accent);
  animation:spin .8s linear infinite;
}

.loaderText{
  font-size:13px;
  font-weight:800;
  color:#0f172a;
}

@keyframes spin{
  to{transform:rotate(360deg);}
}

/* =========================
   FOOTER
   ========================= */
footer{
  border-top:1px solid var(--border);
  background:var(--panel);
  padding:12px 16px;
  font-size:12px;
  color:var(--muted);
  text-align:center;
}

/* =========================
   RESPONSIVE
   ========================= */
@media(max-width:900px){
  .splitGrid{grid-template-columns:repeat(2,1fr)}
}

@media(max-width:720px){
  .head{display:none}
  .row{grid-template-columns:1fr 110px}
  .field{grid-template-columns:1fr}
  .splitGrid{grid-template-columns:1fr}
}

/* ✅ Fix overflow on mobile (fields stay inside the card) */
.detailsCard,
.details,
.splitBox{
  overflow: hidden;
}

.field,
.miniField{
  min-width: 0;
}

.inputWrap{
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.text{
  min-width: 0;
  max-width: 100%;
}

/* ✅ Stronger mobile rules */
@media (max-width: 720px){
  .details{ padding: 12px 12px; }
  .detailsCard{ padding: 12px; }

  .field{ gap: 8px; }
  .inputWrap{ padding: 6px 8px; }

  /* keep the copy icon pinned to the end */
  .iconBtn{ flex: 0 0 28px; }

  /* keep URL in one line but clipped nicely */
  .text{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* =========================
   ✅ SAFE MOBILE HEADER FIX (ONLY HEADER)
   ========================= */
@media (max-width: 640px){
  .nav{
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  .brand{
    flex: 1 1 100%;
    min-width: 0;
  }

  .pill{
    flex: 1 1 100%;
    width: 100%;
    justify-content: space-between;
  }
}
