/* =========================================================
   Doctory Admin Panel — Styles
   ========================================================= */
:root {
  --admin-bg: #0f172a;
  --admin-sidebar: #111827;
  --admin-panel: #ffffff;
  --admin-border: rgba(15, 23, 42, 0.08);
  --admin-text: #0f172a;
  --admin-muted: #64748b;
  --admin-primary: #0ea5a4;
  --admin-primary-dark: #0f766e;
  --admin-danger: #dc2626;
  --admin-radius: 14px;
  --admin-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --sidebar-w: 280px;
  --topbar-h: 64px;
  --font: "Cairo", "Tajawal", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: #f1f5f9;
  color: var(--admin-text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
code { background: #e2e8f0; padding: 2px 6px; border-radius: 6px; font-size: 12px; }

/* CRITICAL: without this, the [hidden] attribute is overridden by the
   display:grid/flex rules below (author CSS beats the UA stylesheet),
   so #loginScreen / #adminShell / #loadingOverlay stay visible forever
   regardless of the JS toggling element.hidden = true/false. */
[hidden] { display: none !important; }

/* ===== Login ===== */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(14,165,164,.25), transparent 40%),
              linear-gradient(135deg, #0f172a, #1e293b);
}

.login-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}

.login-card__brand { text-align: center; margin-bottom: 28px; }
.login-card__logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #0ea5a4, #1b3a6b);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 24px; margin: 0 auto 12px;
}
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card p { color: var(--admin-muted); font-size: 14px; }
.login-form { display: grid; gap: 16px; }
.login-note { margin-top: 16px; font-size: 12px; color: var(--admin-muted); text-align: center; }

/* ===== Shell ===== */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--admin-sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar__logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #0ea5a4, #1b3a6b);
  display: grid; place-items: center; font-weight: 800;
}
.sidebar__brand strong { display: block; font-size: 16px; }
.sidebar__brand small { color: #94a3b8; font-size: 12px; }
.sidebar__nav { padding: 16px 12px; flex: 1; display: grid; gap: 4px; align-content: start; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: none; background: transparent;
  color: #cbd5e1; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 600; text-align: right; width: 100%;
  transition: .15s ease;
}
.sidebar__link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar__link.is-active { background: rgba(14,165,164,.18); color: #5eead4; }
.sidebar__icon { font-size: 18px; }
.sidebar__foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.06); }
.session-info small { display: block; color: #94a3b8; margin-top: 4px; word-break: break-all; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.topbar__burger {
  display: none; border: none; background: #f1f5f9;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.topbar__title { font-weight: 700; flex: 1; }
.content { padding: 28px; padding-bottom: 100px; }

/* ===== Components ===== */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 { font-size: 28px; margin-bottom: 4px; }
.page-head p { color: var(--admin-muted); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: none;
  font-weight: 700; font-size: 14px; cursor: pointer; transition: .15s ease;
}
.btn--primary { background: var(--admin-primary); color: #fff; }
.btn--primary:hover { background: var(--admin-primary-dark); }
.btn--ghost { background: #fff; border: 1px solid var(--admin-border); color: var(--admin-text); }
.btn--ghost:hover { background: #f8fafc; }
.btn--danger { background: var(--admin-danger); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn-icon {
  width: 36px; height: 36px; border: 1px solid var(--admin-border);
  background: #fff; border-radius: 10px; cursor: pointer;
}
.btn-icon--danger:hover { background: #fef2f2; border-color: #fecaca; }

.input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid #cbd5e1; background: #fff; font-size: 14px;
}
.input:focus { outline: 2px solid rgba(14,165,164,.25); border-color: var(--admin-primary); }
.input--sm { padding: 8px 10px; font-size: 13px; }
.textarea { resize: vertical; min-height: 90px; }

.field { display: grid; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: #334155; }
.field small { font-size: 12px; color: var(--admin-muted); line-height: 1.5; }
.field--check { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.field--full { grid-column: 1 / -1; }
.field--color { grid-template-columns: 1fr auto; align-items: end; }
.field--color input[type=color] { width: 48px; height: 42px; border: none; background: none; cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.panel {
  background: var(--admin-panel); border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border); padding: 22px;
  box-shadow: var(--admin-shadow);
}
.panel h3 { font-size: 16px; margin-bottom: 16px; }
.panel__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-stack { display: grid; gap: 20px; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.stats-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: var(--admin-radius); padding: 20px;
  border: 1px solid var(--admin-border); box-shadow: var(--admin-shadow);
}
.stat-card__value { display: block; font-size: 32px; font-weight: 800; color: var(--admin-primary-dark); }
.stat-card__label { color: var(--admin-muted); font-size: 13px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.notes-list { padding-right: 18px; color: var(--admin-muted); line-height: 1.8; font-size: 14px; }

.toolbar { margin-bottom: 16px; }

.table-wrap {
  background: #fff; border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border); overflow: auto;
  box-shadow: var(--admin-shadow);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 14px 16px; text-align: right; border-bottom: 1px solid #f1f5f9; }
.data-table th { background: #f8fafc; font-size: 12px; color: var(--admin-muted); }
.table-actions { display: flex; gap: 6px; }

.cards-grid { display: grid; gap: 14px; }
.cards-grid--3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.item-card {
  background: #fff; border: 1px solid var(--admin-border); border-radius: var(--admin-radius);
  padding: 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
}
.item-card__icon { font-size: 28px; }

.split-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; }
.list-nav { display: grid; gap: 6px; max-height: 520px; overflow: auto; }
.list-nav__item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--admin-border); background: #fff;
  border-radius: 10px; cursor: pointer; font-size: 13px;
}
.list-nav__item.is-active { border-color: var(--admin-primary); background: #ecfeff; }
.list-nav__item span { color: var(--admin-muted); font-size: 12px; }

.tags-editor { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tag-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1f5f9; border-radius: 999px; padding: 6px 8px 6px 12px; font-size: 13px;
}

.links-editor { display: grid; gap: 10px; margin: 16px 0; }
.link-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; }

.info-dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; }
.info-dl dt { color: var(--admin-muted); }

.theme-preview {
  border-radius: 16px; overflow: hidden; border: 1px solid var(--admin-border);
  background: var(--pv-paper, #fbfaff);
}
.pv-navbar {
  background: var(--pv-ink, #1b3a6b); color: #fff; padding: 14px 18px; font-weight: 700;
}
.pv-hero { padding: 24px; }
.pv-hero small { color: var(--admin-muted); }
.pv-hero h2 { margin: 8px 0; color: var(--pv-ink); }
.pv-hero p { color: var(--admin-muted); font-size: 13px; margin-bottom: 16px; }
.pv-btn {
  background: var(--pv-accent); color: #fff; border: none; padding: 10px 18px;
  border-radius: 999px; font-weight: 700;
}

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.55); }
.modal__dialog {
  position: relative; background: #fff; border-radius: 20px; width: min(520px, 100%);
  max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.2);
}
.modal__dialog--wide { width: min(860px, 100%); }
.modal__head, .modal__foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid #f1f5f9;
}
.modal__foot { border-bottom: none; border-top: 1px solid #f1f5f9; justify-content: flex-end; gap: 10px; }
.modal form { padding: 22px; }

/* ===== Save bar ===== */
.save-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120%);
  background: #0f172a; color: #fff; padding: 14px 18px; border-radius: 999px;
  display: flex; align-items: center; gap: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.25);
  transition: transform .25s ease; z-index: 50;
}
.save-bar.is-visible { transform: translateX(-50%) translateY(0); }

/* ===== Toast ===== */
.toast-box { position: fixed; top: 20px; left: 20px; z-index: 200; display: grid; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--admin-border); padding: 12px 16px;
  border-radius: 12px; box-shadow: var(--admin-shadow); opacity: 0; transform: translateY(-8px);
  transition: .25s ease; min-width: 260px; font-size: 14px;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--success { border-color: #86efac; background: #f0fdf4; }
.toast--error { border-color: #fecaca; background: #fef2f2; }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.8);
  display: grid; place-content: center; gap: 12px; z-index: 300;
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid #e2e8f0; border-top-color: var(--admin-primary);
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .split-layout, .panel-grid, .form-grid, .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed; right: 0; transform: translateX(100%);
    transition: transform .25s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .topbar__burger { display: grid; place-items: center; }
  .stats-grid { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 1fr; }
}

/* ===== Doctor Images Upload ===== */
.doc-images {
  border: 1px dashed var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 12px;
  margin-bottom: 10px;
  background: #f8fafc;
}
.doc-images__empty {
  color: var(--admin-muted);
  font-size: 13px;
  margin: 4px 0;
  text-align: center;
}
.doc-images__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.doc-images__item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--admin-border);
  background: #fff;
}
.doc-images__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.doc-images__del {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}
.doc-images__del:hover { background: var(--admin-danger); }
.doc-images__upload {
  display: flex;
  align-items: center;
  gap: 10px;
}
.doc-images__upload small {
  color: var(--admin-muted);
  font-size: 12px;
}
