/* =========================================================================
   لوحة الإدارة — admin.css
   ========================================================================= */
html, body { overflow-x: hidden; }
@supports (overflow-x: clip) { html, body { overflow-x: clip; } }

/* ======================= شاشة تسجيل الدخول ======================= */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 26px 5%;
  background:
    radial-gradient(760px 420px at 85% -10%, rgba(18,135,146,.16), transparent 60%),
    radial-gradient(620px 400px at 10% 110%, rgba(198,161,91,.16), transparent 60%),
    var(--grad-deep);
  position: relative; overflow: hidden;
}
.login-screen::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 44px 44px;
}
.login-card {
  position: relative; z-index: 2; width: min(880px, 100%);
  display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--white); border-radius: 28px; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  background: var(--grad-deep); color: #E6F1F2; padding: 44px 38px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  position: relative; overflow: hidden;
}
.login-brand::after {
  content: ''; position: absolute; top: -70px; left: -70px; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(18,135,146,.4), transparent 70%);
}
.lb-logo { background: #fff; border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow-md); margin-bottom: 24px; position: relative; z-index: 2; }
.lb-logo img { height: 46px; width: auto; }
.login-brand h2 { color: #fff; font-size: 1.5rem; font-weight: 900; position: relative; z-index: 2; }
.login-brand p { color: #B7CFD4; font-size: .94rem; margin-top: 8px; position: relative; z-index: 2; }
.lb-chip {
  margin-top: 18px; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(198,161,91,.14); color: var(--gold-2); border: 1px solid rgba(198,161,91,.35);
  border-radius: var(--radius-pill); padding: 6px 14px; font-size: .78rem; font-weight: 700; position: relative; z-index: 2;
}
.login-form { padding: 44px 38px; display: flex; flex-direction: column; justify-content: center; }
.login-form h3 { font-size: 1.35rem; font-weight: 900; }
.lf-sub { color: var(--muted); font-size: .92rem; margin: 6px 0 24px; }
.login-form .form-group { margin-bottom: 16px; }
.pass-wrap { position: relative; }
.pass-wrap .field { padding-left: 46px; }
.pass-toggle {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 10px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; transition: color .2s, background .2s;
}
.pass-toggle:hover { color: var(--brand-700); background: rgba(18,135,146,.08); }
.lf-hint { font-size: .8rem; color: var(--muted); margin-top: 16px; }
.lf-hint code { background: var(--bg-2); padding: 2px 7px; border-radius: 6px; direction: ltr; display: inline-block; }
.lf-back { margin-top: 14px; font-size: .88rem; font-weight: 700; color: var(--brand-700); display: inline-flex; align-items: center; gap: 6px; }
.lf-back:hover { text-decoration: underline; }

/* ======================= الهيكل العام ======================= */
.admin-shell { display: flex; min-height: 100vh; background: var(--bg); }

.sidebar {
  width: 264px; flex: 0 0 264px; background: var(--grad-deep); color: #CFE2E5;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.sb-brand { padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 10px; }
.sb-brand img { background: #fff; border-radius: 12px; padding: 8px 10px; height: 40px; width: fit-content; max-width: 100%; }
.sb-demo {
  align-self: flex-start; font-size: .72rem; font-weight: 800; color: var(--gold-2);
  background: rgba(198,161,91,.14); border: 1px solid rgba(198,161,91,.35);
  padding: 3px 11px; border-radius: var(--radius-pill);
}
.sb-nav { padding: 16px 12px; display: grid; gap: 5px; flex: 1; }
.sb-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: right;
  padding: 12px 14px; border-radius: 13px; color: #C4D9DD; font-family: var(--font-head);
  font-weight: 700; font-size: .94rem; transition: all .25s ease; position: relative;
}
.sb-link svg { flex: 0 0 auto; opacity: .85; }
.sb-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-link.active { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-brand); }
.sb-badge {
  margin-inline-start: auto; background: rgba(255,255,255,.15); color: #fff;
  font-size: .75rem; padding: 1px 9px; border-radius: var(--radius-pill);
}
.sb-link.active .sb-badge { background: rgba(255,255,255,.25); }
.sb-foot { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 5px; }
.sb-foot .sb-link { color: #9DBDC2; }
.sb-foot .sb-link:hover { color: #fff; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); padding: 14px 26px;
  display: flex; align-items: center; gap: 16px;
}
.sb-toggle { display: none; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: #fff; align-items: center; justify-content: center; color: var(--deep); }
.at-title h1 { font-size: 1.18rem; font-weight: 900; }
.at-title p { font-size: .8rem; color: var(--muted); }
.at-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.at-admin {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: .88rem;
  color: var(--brand-700); background: rgba(18,135,146,.08); border-radius: var(--radius-pill); padding: 8px 15px;
}

.admin-content { padding: 26px; flex: 1; }
.view { display: none; animation: wpIn .4s cubic-bezier(.22,.61,.36,1); }
.view.active { display: block; }

/* ======================= بطاقات الإحصائيات ======================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border: 1px solid var(--line-2); border-radius: 18px; padding: 20px;
  box-shadow: var(--shadow-sm); display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden;
  transition: transform .3s ease, box-shadow .3s ease;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-card .st-icon {
  width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.stat-card .st-val { font-family: var(--font-head); font-weight: 900; font-size: 1.6rem; color: var(--deep); line-height: 1.1; }
.stat-card .st-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat-card.st-total .st-icon { background: var(--info-bg); color: var(--brand); }
.stat-card.st-today .st-icon { background: var(--gold-soft); color: #A87E2E; }
.stat-card.st-upcoming .st-icon { background: #E9F1F3; color: var(--deep); }
.stat-card.st-new .st-icon { background: #E4EEF8; color: #2E6DA8; }
.stat-card.st-confirmed .st-icon { background: var(--success-bg); color: var(--success); }
.stat-card.st-completed .st-icon { background: #EEF0F2; color: #4A5A63; }
.stat-card.st-cancelled .st-icon { background: var(--danger-bg); color: var(--danger); }

/* ======================= نظرة عامة ======================= */
.ov-row { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; }
.ov-card { padding: 24px; }
.ov-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ov-card-head h3 { font-size: 1.05rem; font-weight: 800; }
.ov-all { font-size: .84rem; font-weight: 700; color: var(--brand-700); }
.ov-all:hover { text-decoration: underline; }

.upcoming-item {
  display: flex; align-items: center; gap: 14px; padding: 13px 6px; border-bottom: 1px dashed var(--line);
}
.upcoming-item:last-child { border-bottom: 0; }
.upcoming-item .ui-date {
  flex: 0 0 74px; text-align: center; background: var(--bg-2); border-radius: 13px; padding: 8px 4px;
}
.upcoming-item .ui-date b { display: block; font-family: var(--font-head); font-size: .88rem; color: var(--deep); }
.upcoming-item .ui-date span { font-size: .7rem; color: var(--muted); }
.upcoming-item .ui-info { flex: 1; min-width: 0; }
.upcoming-item .ui-info b { font-family: var(--font-head); font-size: .93rem; color: var(--deep); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upcoming-item .ui-info span { font-size: .8rem; color: var(--muted); }
.upcoming-item .ui-time { font-family: var(--font-head); font-weight: 800; font-size: .86rem; color: var(--brand-700); direction: ltr; }
.upcoming-empty { text-align: center; color: var(--muted); padding: 26px 0; font-size: .92rem; }

.service-dist { display: grid; gap: 12px; }
.sd-row .sd-top { display: flex; justify-content: space-between; font-size: .84rem; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; }
.sd-bar { height: 9px; border-radius: 6px; background: var(--bg-2); overflow: hidden; }
.sd-bar i { display: block; height: 100%; border-radius: 6px; background: var(--grad-brand); transition: width .8s cubic-bezier(.22,.61,.36,1); }

/* ======================= جدول الحجوزات ======================= */
.bookings-panel { padding: 22px; }
.bp-toolbar { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.bp-search { position: relative; flex: 1; min-width: 240px; }
.bp-search svg { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.bp-search .field { padding-right: 42px; background: var(--bg); }
.bp-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip { cursor: pointer; user-select: none; transition: all .25s ease; }
.filter-chip:hover { border-color: var(--brand); color: var(--brand-700); }
.filter-chip.active { background: var(--grad-brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-brand); }
.bp-result { font-size: .84rem; color: var(--muted); margin-bottom: 10px; }

.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line-2); }
.admin-table { width: 100%; border-collapse: collapse; min-width: 1080px; font-size: .9rem; }
.admin-table thead th {
  background: var(--grad-deep); color: #DCEBEE; font-family: var(--font-head); font-weight: 700; font-size: .8rem;
  padding: 13px 12px; text-align: right; white-space: nowrap;
}
.admin-table tbody td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink-2); }
.admin-table tbody tr { transition: background .2s; }
.admin-table tbody tr:hover { background: rgba(18,135,146,.045); }
.admin-table tbody tr.demo-row .b-id { background: rgba(198,161,91,.16); }
.b-id { font-family: var(--font-head); font-weight: 800; font-size: .82rem; color: var(--brand-700); direction: ltr; background: var(--info-bg); padding: 4px 10px; border-radius: 8px; white-space: nowrap; display: inline-block; }
.b-name { font-weight: 800; color: var(--deep); }
.b-demo-tag { font-size: .66rem; font-weight: 800; color: #A87E2E; background: var(--gold-soft); padding: 2px 8px; border-radius: var(--radius-pill); margin-inline-start: 6px; }
.b-phone, .b-mail { direction: ltr; display: inline-block; }

.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 800; padding: 5px 12px; border-radius: var(--radius-pill); white-space: nowrap; }
.status-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-new { background: #E4EEF8; color: #2E6DA8; }
.st-confirmed { background: var(--success-bg); color: var(--success); }
.st-completed { background: #EEF0F2; color: #4A5A63; }
.st-cancelled { background: var(--danger-bg); color: var(--danger); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-act {
  width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  border: 1.4px solid var(--line); background: #fff; color: var(--muted); transition: all .22s ease;
}
.row-act:hover { transform: translateY(-2px); box-shadow: var(--shadow-xs); }
.row-act.act-view:hover { color: var(--brand); border-color: var(--brand); background: var(--info-bg); }
.row-act.act-confirm:hover { color: var(--success); border-color: var(--success); background: var(--success-bg); }
.row-act.act-edit:hover { color: #A87E2E; border-color: #C6A15B; background: var(--gold-soft); }
.row-act.act-cancel:hover { color: var(--warning); border-color: var(--warning); background: var(--warning-bg); }
.row-act.act-delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

.empty-state { text-align: center; color: var(--muted); padding: 48px 0 30px; }
.empty-state svg { color: #BFD6DA; margin-bottom: 12px; }

/* ======================= تقويم الإدارة ======================= */
.cal-panel { padding: 26px; }
.cal-panel-head { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 18px; }
.cal-panel-head h3 { font-size: 1.15rem; font-weight: 900; min-width: 180px; text-align: center; }
.cal-nav-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
  color: var(--brand-700); display: flex; align-items: center; justify-content: center; transition: all .25s;
}
.cal-nav-btn:hover:not(:disabled) { background: var(--brand); color: #fff; border-color: var(--brand); }
.cal-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.ad-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  border: 1px solid var(--line-2); border-radius: 16px; padding: 12px; background: var(--bg);
}
.ad-cal-dow { text-align: center; font-family: var(--font-head); font-weight: 800; font-size: .78rem; color: var(--muted); padding: 7px 0; }
.ad-cal-day {
  aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--font-head); font-weight: 700; font-size: .9rem; color: var(--ink-2);
  background: var(--white); border: 1.5px solid var(--line-2); cursor: pointer; transition: all .22s ease;
}
.ad-cal-day:hover:not(.disabled) { border-color: var(--brand); color: var(--brand-700); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ad-cal-day.disabled { opacity: .4; cursor: not-allowed; background: var(--bg-2); }
.ad-cal-day.selected { background: var(--grad-brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-brand); }
.ad-cal-day .ac-count {
  font-size: .64rem; font-weight: 800; color: var(--brand-700); background: var(--info-bg);
  border-radius: 20px; padding: 1px 7px; line-height: 1.4;
}
.ad-cal-day.selected .ac-count { background: rgba(255,255,255,.25); color: #fff; }
.ad-cal-day.dr-avail { border-color: rgba(198,161,91,.55); }
.ad-cal-day.today:not(.selected) { border-color: var(--gold); color: #A87E2E; }
.cal-panel-legend { display: flex; justify-content: center; gap: 22px; margin: 16px 0 4px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.cal-panel-legend span { display: inline-flex; align-items: center; gap: 7px; }
.cal-panel-legend .lg-dot { width: 11px; height: 11px; border-radius: 4px; }

.day-bookings { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 18px; }
.day-bookings h4 { font-size: 1rem; font-weight: 800; margin-bottom: 8px; }
.db-hint { color: var(--muted); font-size: .88rem; }
.db-item {
  display: flex; align-items: center; gap: 14px; padding: 11px 4px; border-bottom: 1px dashed var(--line-2); flex-wrap: wrap;
}
.db-item .db-time { font-family: var(--font-head); font-weight: 800; color: var(--brand-700); direction: ltr; flex: 0 0 78px; }
.db-item .db-info { flex: 1; min-width: 180px; }
.db-item .db-info b { font-size: .93rem; color: var(--deep); }
.db-item .db-info span { font-size: .8rem; color: var(--muted); display: block; }
.db-empty { color: var(--muted); font-size: .9rem; padding: 8px 0; }

/* ======================= الإعدادات ======================= */
.settings-card { padding: 28px; max-width: 780px; }
.settings-card h3 { font-size: 1.2rem; font-weight: 900; }
.set-sub { color: var(--muted); font-size: .93rem; margin-top: 6px; }
.set-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.set-note {
  margin-top: 26px; display: flex; gap: 12px; align-items: flex-start;
  background: var(--warning-bg); border: 1px solid rgba(217,130,43,.4); border-radius: 14px; padding: 15px 18px;
  font-size: .88rem; color: #7A5A30;
}
.set-note svg { color: var(--warning); flex: 0 0 auto; margin-top: 3px; }
.set-note code { background: rgba(0,0,0,.05); padding: 2px 7px; border-radius: 6px; direction: ltr; display: inline-block; }

/* ======================= النوافذ المنبثقة ======================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150; background: rgba(6,36,43,.55); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 20px 4%;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white); border-radius: 22px; width: min(680px, 100%); max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .35s cubic-bezier(.22,.61,.36,1);
}
.modal-sm { width: min(430px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: #fff; z-index: 2;
}
.modal-head h3 { font-size: 1.1rem; font-weight: 900; }
.modal-close {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); background: #fff;
  color: var(--muted); font-size: 1.25rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.modal-body { padding: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item { background: var(--bg); border: 1px solid var(--line-2); border-radius: 13px; padding: 12px 15px; }
.detail-item .dk { font-size: .78rem; color: var(--muted); font-weight: 700; display: block; }
.detail-item .dv { font-family: var(--font-head); font-weight: 800; color: var(--deep); font-size: .95rem; margin-top: 3px; word-break: break-word; }
.detail-item.full { grid-column: 1 / -1; }
.detail-item .dv.dir { direction: ltr; text-align: left; }

.history-box { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; }
.history-box h5 { font-size: .95rem; font-weight: 800; margin-bottom: 10px; }
.history-item { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; font-size: .86rem; }
.history-item .hi-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: 0 0 auto; }
.history-item .hi-action { font-weight: 700; color: var(--ink-2); }
.history-item .hi-at { color: var(--muted); font-size: .78rem; direction: ltr; display: block; }

.edit-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.edit-slot {
  padding: 10px 6px; border-radius: 11px; border: 1.5px solid var(--line); background: #FBFDFD;
  font-family: var(--font-head); font-weight: 700; font-size: .86rem; color: var(--ink-2); direction: ltr;
  transition: all .22s ease;
}
.edit-slot:hover:not(:disabled):not(.selected) { border-color: var(--brand); color: var(--brand-700); }
.edit-slot.selected { background: var(--grad-brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-brand); }
.edit-slot:disabled { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.edit-slots-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: .88rem; padding: 14px 0; }

/* ======================= استجابة اللوحة ======================= */
@media (max-width: 1020px) {
  .sidebar { position: fixed; right: 0; transform: translateX(100%); visibility: hidden; transition: transform .3s ease, visibility 0s linear .3s; box-shadow: var(--shadow-lg); width: 264px; }
  .sidebar.open { transform: none; visibility: visible; transition: transform .3s ease; }
  .sb-toggle { display: flex; }
  .admin-main { width: 100%; }
  .ov-row { grid-template-columns: 1fr; }
  .login-card { grid-template-columns: 1fr; }
  .login-brand { padding: 30px 30px; }
}

@media (max-width: 720px) {
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 12px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .at-admin { display: none; }
  .bp-toolbar { flex-direction: column; align-items: stretch; }
  .detail-grid { grid-template-columns: 1fr; }
  .edit-slots { grid-template-columns: repeat(3, 1fr); }

  /* تحويل الجدول إلى بطاقات */
  .table-wrap { border: 0; overflow: visible; }
  .admin-table, .admin-table thead, .admin-table tbody, .admin-table tr, .admin-table th, .admin-table td { display: block; min-width: 0; }
  .admin-table thead { display: none; }
  .admin-table { border-spacing: 0; }
  .admin-table tbody tr {
    background: var(--white); border: 1px solid var(--line-2); border-radius: 16px;
    padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow-xs);
  }
  .admin-table tbody td {
    border: 0; padding: 7px 2px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  }
  .admin-table tbody td::before {
    content: attr(data-label); font-family: var(--font-head); font-weight: 700; font-size: .78rem; color: var(--muted);
  }
  .admin-table tbody td.row-actions-cell::before { display: none; }
  .admin-table tbody td.row-actions-cell { justify-content: flex-start; }
}

@media (max-width: 460px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .login-form { padding: 30px 24px; }
  .login-brand { padding: 24px 22px; }
  .edit-slots { grid-template-columns: repeat(2, 1fr); }
}
