:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --text: #0b1324;
  --muted: #64748b;
  --brand: #0ea5e9;
  --brand-2: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #e2e8f0;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.12);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-width: 250px;
  --ring: 0 0 0 4px rgba(14, 165, 233, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 520px at -10% -20%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(1200px 520px at 110% -10%, rgba(34, 197, 94, 0.10), transparent 60%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: var(--text);
  font-family: "Cairo", "Sora", sans-serif;
}
body.login-view {
  overflow: auto;
  min-height: 100vh;
}

body.en { font-family: "Sora", "Cairo", sans-serif; }
body.ar { font-family: "Cairo", "Sora", sans-serif; }

html[dir="rtl"] body { direction: rtl; }
html[dir="ltr"] body { direction: ltr; }

a { color: inherit; text-decoration: none; }

.app {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

html[dir="rtl"] .app {
  flex-direction: row-reverse;
  direction: rtl;
}

body.ar .app {
  flex-direction: row-reverse;
  direction: rtl;
}

.app.rtl-app {
  flex-direction: row-reverse;
  direction: rtl;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.25s ease;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  display: none;
  z-index: 25;
}
.sidebar-backdrop.show { display: block; }

.fab-menu {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, var(--brand), #38bdf8);
  color: #fff;
  font-size: 22px;
  display: none;
  box-shadow: var(--shadow);
  z-index: 40;
}

.app.rtl-app .sidebar { order: 2; }
.app.rtl-app .content { order: 1; }

html[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
  right: 0;
  left: auto;
}

html[dir="rtl"] .content {
  margin-left: 0;
}

body.ar .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
  right: 0;
  left: auto;
}
body.ar .content { margin-left: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid rgba(14, 165, 233, 0.08);
}

.brand-info small { color: var(--muted); display: block; margin-top: 2px; }

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
}

.nav-section {
  margin: 18px 6px 8px;
  color: rgba(15, 23, 42, 0.55);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.nav a,
.nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  margin: 4px 6px;
  font-weight: 600;
  position: relative;
  white-space: nowrap;
  line-height: 1.35;
}
.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav a.active,
.nav a:hover,
.nav .nav-link.active,
.nav .nav-link:hover {
  background: rgba(14, 165, 233, 0.10);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.10);
  transform: translateX(4px);
}

html[dir="rtl"] .nav a.active,
html[dir="rtl"] .nav a:hover,
html[dir="rtl"] .nav .nav-link.active,
html[dir="rtl"] .nav .nav-link:hover {
  transform: translateX(-3px);
}
body.ar .nav a.active,
body.ar .nav a:hover {
  transform: translateX(-3px);
}

.nav a.active::before,
.nav .nav-link.active::before {
  content: "";
  position: absolute;
  inset: 6px auto 6px 6px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}
html[dir="rtl"] .nav a.active::before {
  inset: 6px 6px 6px auto;
}
body.ar .nav a.active::before {
  inset: 6px 6px 6px auto;
}

.nav-ico {
  font-size: 16px;
  width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
html[dir="rtl"] .nav-ico,
body.ar .nav-ico {
  margin-left: 2px;
}

.content { padding: 26px; }
.content { min-width: 0; height: 100vh; overflow-y: auto; flex: 1 1 auto; }
.content {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.page-anim .content {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.page-anim .content.is-ready {
  opacity: 1;
  transform: translateY(0);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  position: static;
}

.topbar .title { font-size: 22px; font-weight: 800; }
.topbar-brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { height: 28px; width: auto; display: block; object-fit: contain; }

.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.topbar-search { flex: 1 1 auto; max-width: 420px; }
.topbar-search .input { width: 100%; }

.sidebar-toggle {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  display: none;
}
.sidebar-collapse {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease;
  font-weight: 600;
  min-height: 40px;
}

.btn:hover { transform: translateY(-1px); background: #f8fafc; box-shadow: var(--shadow-soft); }
.btn:focus { outline: none; box-shadow: var(--ring); }

.btn.primary { background: linear-gradient(135deg, var(--brand), #38bdf8); border: none; color: #fff; }
.btn.success { background: linear-gradient(135deg, var(--brand-2), #4ade80); border: none; color: #fff; }
.btn.danger { background: linear-gradient(135deg, #ef4444, #f97316); border: none; color: #fff; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: floatIn 0.5s ease both;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.12);
}

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  font-size: 14px;
  vertical-align: middle;
}

.table th { color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; }
.table tr:hover td { background: rgba(14,165,233,0.04); }

.table-modern {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.table-modern thead th {
  background: linear-gradient(180deg, #f8fafc, #ffffff);
}
.table-modern tbody tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.02);
}
.table-modern tbody tr:hover td {
  background: rgba(14, 165, 233, 0.08);
}

.modal {
  border: none;
  padding: 0;
  background: transparent;
}
.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: min(92vw, 420px);
  padding: 16px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-body { display: grid; gap: 8px; }
.confirm-modal .modal-title { font-weight: 700; }
.confirm-modal .confirm-message { font-size: 14px; color: var(--text); }

/* Collapsible panels */
.accordion {
  display: grid;
  gap: 12px;
}
.accordion details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
  content: "▾";
  font-size: 14px;
  color: var(--muted);
  transition: transform .2s ease;
}
.accordion details[open] summary::after { transform: rotate(-180deg); }
.accordion .panel-body {
  padding: 0 16px 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.06);
}

.badge.active { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.badge.inactive { background: rgba(239, 68, 68, 0.15); color: #dc2626; }

.form-group { display: grid; gap: 10px; margin-bottom: 14px; }

.label { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

.input, .select, .textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: box-shadow 0.2s ease, border 0.2s ease;
  min-height: 44px;
}

.color-input {
  height: 44px;
  padding: 6px;
}

html[dir="rtl"] .input,
html[dir="rtl"] .select,
html[dir="rtl"] .textarea {
  text-align: right;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgba(14, 165, 233, 0.4);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-delete { display: inline-block; margin: 0; }
.inline-delete .btn { margin: 0; }
.actions .inline-delete { display: inline-flex; }
.actions .inline-delete .btn { min-height: 36px; }

.hours-row {
  display: grid;
  grid-template-columns: 110px repeat(2, minmax(0, 1fr)) 90px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 10px;
}
html[dir="rtl"] .hours-row { grid-template-columns: 90px repeat(2, minmax(0, 1fr)) 110px; }
.hours-row .day-name { font-weight: 700; }
.hours-row .closed { display: flex; align-items: center; gap: 8px; }
@media (max-width: 720px) {
  .hours-row {
    grid-template-columns: 1fr;
  }
}

.file {
  border: 1px dashed var(--border);
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
}
.file input[type="file"] { width: 100%; }

.upload-card { display: grid; gap: 16px; }
.upload-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upload-preview {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(140px 120px at 20% 20%, rgba(14, 165, 233, 0.12), transparent 60%),
    radial-gradient(140px 120px at 80% 20%, rgba(34, 197, 94, 0.12), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.upload-preview .frame {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(34, 197, 94, 0.12));
  box-shadow: var(--shadow-soft);
}
.upload-preview img {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  border: 1px solid var(--border);
  object-fit: cover;
  box-shadow: var(--shadow-soft);
  display: none;
}
.upload-preview img.is-visible { display: block; }
.upload-tips { display: grid; gap: 8px; }
.upload-tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 800; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }

.hero {
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(34, 197, 94, 0.08));
  border: 1px solid rgba(15, 23, 42, 0.06);
  animation: floatIn 0.45s ease both;
}

.lang-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.lang-toggle a {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}

.lang-toggle a.active { background: rgba(14, 165, 233, 0.12); color: var(--text); }

.flash {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.1);
  margin-bottom: 16px;
}
.flash.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.table-wrap { overflow-x: auto; }

.table-search {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.table-search .input { max-width: 260px; }
.table td::before {
  content: attr(data-label);
  font-weight: 700;
  color: var(--muted);
  display: none;
  margin-bottom: 6px;
}

.table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.table-tools .select {
  background: #fff;
}
.table-tools .table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.table-tools .table-info {
  font-size: 12px;
  color: var(--muted);
}
.table-tools .table-pagination {
  display: inline-flex;
  gap: 6px;
}
.btn.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.sortable { cursor: pointer; user-select: none; }
.sortable::after { content: "↕"; font-size: 11px; color: var(--muted); margin-right: 6px; }
html[dir="rtl"] .sortable::after { margin-right: 0; margin-left: 6px; }

@keyframes floatIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseSoft {
  0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.2); }
  70% { box-shadow: 0 0 0 10px rgba(14, 165, 233, 0); }
  100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

.btn.primary { animation: pulseSoft 4s ease infinite; }

/* Login */
.login-page {
  min-height: 100vh;
  padding: 28px 18px;
  display: grid;
  place-items: center;
}
.login-wrap {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  align-items: stretch;
}
.login-intro {
  background:
    radial-gradient(500px 220px at 20% 0%, rgba(14, 165, 233, 0.22), transparent 62%),
    radial-gradient(500px 220px at 100% 20%, rgba(34, 197, 94, 0.18), transparent 60%),
    linear-gradient(145deg, #ffffff, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 28px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.login-brand-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}
.login-brand-sub {
  color: var(--muted);
  font-size: 13px;
}
.login-title {
  margin: 0 0 10px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}
.login-copy {
  margin: 0 0 14px;
  color: #334155;
  line-height: 1.7;
}
.login-points {
  margin: 0;
  padding-inline-start: 20px;
  display: grid;
  gap: 8px;
  color: #0f172a;
}
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 10px;
}
.login-lang {
  justify-self: end;
  margin-bottom: 6px;
}
html[dir="rtl"] .login-lang,
body.ar .login-lang {
  justify-self: start;
}
.login-head {
  margin: 4px 0 0;
  font-size: 24px;
}
.login-sub {
  margin: 0 0 8px;
  color: var(--muted);
}
.login-form {
  margin-top: 2px;
}
.login-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
}

@media (max-width: 1100px) {
  .app { display: block; }
  html[dir="rtl"] .app { display: block; }
  body.ar .app { display: block; }
  .app.rtl-app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; left: 0; right: auto; transform: translateX(-105%); width: min(82vw, 280px); z-index: 30; box-shadow: var(--shadow); }
  html[dir="rtl"] .sidebar { inset: 0 0 0 auto; right: 0; left: auto; transform: translateX(105%); }
  body.ar .sidebar { inset: 0 0 0 auto; right: 0; left: auto; transform: translateX(105%); }
  .app.rtl-app .sidebar { inset: 0 0 0 auto; right: 0; left: auto; transform: translateX(105%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; align-items: center; gap: 6px; }
  .sidebar-collapse { display: none; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .content { padding: 16px; }
  body.login-view { overflow: auto; }
  .login-page { padding: 14px; }
  .login-intro { padding: 18px; }
  .login-card { padding: 16px; border-radius: 18px; }
  .login-points { gap: 6px; font-size: 14px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .topbar > div:first-child { width: 100%; display: flex; align-items: center; justify-content: space-between; }
  .topbar .title { font-size: 18px; }
  .topbar-search { width: 100%; max-width: none; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .lang-toggle a { flex: 1 1 auto; text-align: center; }
  .table th, .table td { font-size: 13px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: #fff; }
  .table td { border: none; padding: 8px 6px; }
  .table td::before { display: block; }
  .fab-menu {
    display: inline-grid;
    place-items: center;
    bottom: calc(14px + env(safe-area-inset-bottom));
    right: 14px;
  }
  html[dir="rtl"] .fab-menu,
  body.ar .fab-menu {
    right: auto;
    left: 14px;
  }
}

/* Collapsible sidebar (desktop) */
body.sidebar-collapsed .sidebar {
  width: 76px;
  min-width: 76px;
  max-width: 76px;
  padding: 16px 10px;
}
body.sidebar-collapsed .brand-info,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .nav-text {
  display: none;
}
body.sidebar-collapsed .nav a {
  justify-content: center;
}
