/* منظومة شبكات المياه والصرف الصحي - سرت */
:root {
  --brand: #0f4c92;
  --brand-2: #1e6fd9;
  --side-w: 330px;
  --top-h: 58px;
}
* { font-family: 'Cairo', system-ui, sans-serif; }
html, body { height: 100%; margin: 0; }
body { background: #eef2f7; overflow: hidden; }
.ltr { direction: ltr; text-align: left; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  height: var(--top-h);
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  position: relative; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-title { font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.brand-sub { font-size: .72rem; opacity: .85; }
.edit-tools { display: flex; gap: 6px; }

/* ---------- التخطيط ---------- */
.layout { display: flex; height: calc(100% - var(--top-h)); }
.sidebar {
  width: var(--side-w); flex: 0 0 var(--side-w);
  background: #fff; overflow-y: auto;
  border-left: 1px solid #dde3ea;
  display: flex; flex-direction: column;
}
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #dfe7ef; }

.side-section { padding: 10px 14px; border-bottom: 1px solid #eef1f5; }
.side-title { font-weight: 700; font-size: .85rem; color: #34495e; margin-bottom: 6px; }
.side-title i { color: var(--brand-2); }
.credit { margin-top: auto; padding: 10px; text-align: center; font-size: .72rem; color: #8a96a3; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 12px 14px; background: #f7f9fc; border-bottom: 1px solid #eef1f5; }
.stat { background: #fff; border: 1px solid #e3e8ef; border-radius: 10px; padding: 8px 10px; }
.stat .v { font-weight: 800; font-size: 1.15rem; color: #1b2b3c; }
.stat .l { font-size: .7rem; color: #6c7a89; }
.stat .chip { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 4px; }

.legend-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .85rem; cursor: pointer; user-select: none; }
.legend-row input { margin: 0; }
.legend-swatch { width: 34px; height: 9px; border-radius: 6px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.legend-row .cnt { margin-right: auto; font-size: .72rem; color: #8a96a3; }
.basemap-switch { display: flex; gap: 4px; margin-top: 8px; }
.basemap-switch .btn { flex: 1; font-size: .75rem; }

.list-group-item { cursor: pointer; font-size: .85rem; padding: 7px 4px; border-color: #f0f2f5; }
.list-group-item:hover { background: #f4f8fe; }
.li-sub { font-size: .72rem; color: #7b8794; }
.li-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 12px; }

/* ---------- صناديق على الخريطة ---------- */
.coord-box {
  position: absolute; bottom: 8px; left: 8px; z-index: 800;
  background: rgba(255,255,255,.92); border-radius: 8px; padding: 2px 10px;
  font-size: .75rem; direction: ltr; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.hint-bar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 900; background: #1b2b3c; color: #fff; border-radius: 12px;
  padding: 8px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: 94%;
  font-size: .85rem;
}
.hint-bar .hint-text { opacity: .9; }
.map-picking .leaflet-container { cursor: crosshair !important; }

/* ---------- الأنابيب: حركة الجريان ---------- */
.flow-dash { animation: flowMove 1.1s linear infinite; }
@keyframes flowMove { to { stroke-dashoffset: -20; } }

.flow-arrow-wrap { background: none; border: none; }
.flow-arrow { width: 100%; height: 100%; animation: arrowBlink 1.2s ease-in-out infinite; filter: drop-shadow(0 0 2px rgba(0,0,0,.55)); }
.flow-arrow svg { width: 100%; height: 100%; display: block; }
@keyframes arrowBlink {
  0%, 100% { opacity: .3; }
  40%      { opacity: 1; }
}

/* ---------- أيقونات المحطات ---------- */
.st-icon-wrap { background: none; border: none; }
.st-icon { position: relative; width: 56px; height: 64px; display: flex; flex-direction: column; align-items: center; }
.st-badge {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--c); border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; position: relative; z-index: 2;
}
.st-badge svg { width: 28px; height: 28px; }
.st-code {
  margin-top: 3px; background: #fff; color: #1b2b3c; font-weight: 800; font-size: .72rem;
  padding: 0 7px; border-radius: 8px; border: 1px solid var(--c); white-space: nowrap; direction: ltr;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.st-icon .pulse {
  position: absolute; top: 0; left: 6px; width: 44px; height: 44px; border-radius: 12px;
  border: 3px solid var(--c); animation: pulse 2s ease-out infinite; z-index: 1;
}
.st-icon:not(.active) .pulse { display: none; }
.st-icon.stopped .st-badge, .st-icon.maintenance .st-badge { filter: grayscale(.6); }
.st-icon.planned .st-badge, .st-icon.construction .st-badge { border-style: dashed; }
@keyframes pulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.8); opacity: 0; } }

/* ---------- محرر المسار ---------- */
.vx-wrap { background: none; border: none; }
.vx { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #ff7a00; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.vx.first { border-color: #198754; width: 18px; height: 18px; margin: -2px; }
.vx.last { border-color: #dc3545; width: 18px; height: 18px; margin: -2px; }
.vx-mid { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,122,0,.5); border: 2px solid #fff; }

/* ---------- النوافذ المنبثقة ---------- */
.leaflet-popup-content { margin: 12px 14px; min-width: 260px; font-size: .82rem; }
.pp-title { font-weight: 800; font-size: .98rem; color: #1b2b3c; margin-bottom: 2px; }
.pp-sub { color: #6c7a89; font-size: .75rem; margin-bottom: 8px; }
.pp-table { width: 100%; border-collapse: collapse; }
.pp-table td { padding: 3px 4px; border-bottom: 1px dashed #e7ebf0; }
.pp-table td:first-child { color: #6c7a89; white-space: nowrap; width: 42%; }
.pp-table td:last-child { font-weight: 600; }
.pp-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.pp-actions .btn { font-size: .74rem; padding: 2px 8px; }
.type-chip { display: inline-block; width: 22px; height: 8px; border-radius: 4px; vertical-align: middle; margin-left: 4px; }

/* ---------- العارض ---------- */
.viewer-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.viewer-svg { background: #fbfcfe; border: 1px solid #e3e8ef; border-radius: 12px; padding: 8px; }
.viewer-svg svg { width: 100%; height: auto; display: block; }
.spec-table td { padding: 4px 6px; font-size: .85rem; }
.spec-table td:first-child { color: #6c7a89; }
.spec-table td:last-child { font-weight: 700; }

/* ---------- تسجيل الدخول ---------- */
.login-page { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f4c92, #1e6fd9 60%, #5fb0ff); overflow: auto; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); margin: 20px; }
.login-logo { text-align: center; margin-bottom: 10px; }

/* ---------- الجوال ---------- */
@media (max-width: 991.98px) {
  .sidebar { position: absolute; top: var(--top-h); bottom: 0; right: 0; z-index: 1030; transform: translateX(100%); transition: transform .25s; box-shadow: -4px 0 18px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .edit-tools span, .brand-sub { display: none; }
  .viewer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 575.98px) {
  .brand-title { font-size: .9rem; }
}
