/* ===================================================
   Movmart Admin — premium dashboard styles
   =================================================== */
:root {
  --red: #e30613;
  --red-2: #b8040f;
  --black: #0d0d0d;
  --gray: #f6f6f7;
  --gray-2: #ececee;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f8f9fb;
  --card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10);
  --radius: 12px;
  --sidebar-w: 240px;
  --green: #16a34a;
  --blue: #2563eb;
  --orange: #ea580c;
  --purple: #7c3aed;
  --transition: 0.22s cubic-bezier(.4,.0,.2,1);
}

* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 6px; }
body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

/* ============ Layout ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  color: #fff;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform var(--transition);
}
.sidebar .brand {
  display: flex; gap: 10px; align-items: center;
  padding: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand img { width: 38px; height: 38px; background: #fff; border-radius: 8px; padding: 4px; object-fit: contain; }
.sidebar .brand .name { font-weight: 800; font-size: 16px; }
.sidebar .brand .name b { color: var(--red); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav a.active { background: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(227,6,19,0.4); }
.nav a svg { width: 18px; height: 18px; }
.nav .group-title {
  text-transform: uppercase; letter-spacing: 0.6px;
  color: rgba(255,255,255,0.4);
  font-size: 11px; font-weight: 700;
  padding: 14px 14px 6px;
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-foot a { color: rgba(255,255,255,0.6); text-decoration: none; font-size: 13px; }

.main {
  margin-right: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 30;
  gap: 12px;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; }
.topbar .tools { display: flex; gap: 8px; align-items: center; }

.menu-btn {
  display: none;
  background: var(--gray); border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 10px;
  cursor: pointer; align-items: center; justify-content: center;
}
.menu-btn svg { width: 22px; height: 22px; }

.content { padding: 24px; flex: 1; }

/* ============ Cards ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card h2, .card h3 { margin-top: 0; }
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h3 {
  margin: 0; font-size: 17px; font-weight: 800;
  border-right: 4px solid var(--red); padding-right: 10px;
}

/* ============ Stat tiles ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; gap: 14px; align-items: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat .icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat .icon svg { width: 24px; height: 24px; color: #fff; }
.stat.red    .icon { background: var(--red); }
.stat.blue   .icon { background: var(--blue); }
.stat.green  .icon { background: var(--green); }
.stat.orange .icon { background: var(--orange); }
.stat.purple .icon { background: var(--purple); }
.stat .label { color: var(--muted); font-size: 13px; margin: 0; }
.stat .value { font-size: 26px; font-weight: 800; margin: 2px 0 0; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  background: var(--red); color: #fff;
  border: none; border-radius: 9px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: var(--transition);
  font-family: inherit;
}
.btn:hover { background: var(--red-2); }
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-dark { background: var(--black); }
.btn-dark:hover { background: #2a2a2a; }
.btn-outline { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn-outline:hover { background: var(--red); color: #fff; }
.btn-ghost { background: var(--gray); color: var(--text); }
.btn-ghost:hover { background: var(--gray-2); }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

/* ============ Forms ============ */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 13px; font-weight: 700; color: var(--text); }
.form-row .hint { font-size: 12px; color: var(--muted); }

input[type=text], input[type=password], input[type=url], input[type=email],
input[type=date], input[type=number], input[type=color], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227,6,19,0.18);
}
input[type=color] { padding: 4px; height: 40px; cursor: pointer; }
input[type=file] { padding: 6px; font-family: inherit; }
textarea { resize: vertical; min-height: 90px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.data { width: 100%; border-collapse: collapse; min-width: 600px; }
table.data th, table.data td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); font-size: 14px; }
table.data th { background: var(--gray); font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(227,6,19,0.04); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.green  { background: #dcfce7; color: #166534; }
.badge.gray   { background: var(--gray-2); color: var(--muted); }
.badge.red    { background: #fee2e2; color: #991b1b; }
.badge.orange { background: #ffedd5; color: #9a3412; }

/* ============ Flash messages ============ */
.flash {
  padding: 12px 16px; border-radius: 10px;
  margin-bottom: 14px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.flash.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash.info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ============ Image grid (admin) ============ */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; margin-top: 14px;
}
.thumb {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden; background: var(--gray);
  aspect-ratio: 3 / 4;
  cursor: grab;
  transition: var(--transition);
}
.thumb.sortable-ghost { opacity: 0.4; }
.thumb.sortable-chosen { border-color: var(--red); transform: scale(1.02); }
.thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumb .order { position: absolute; top: 6px; right: 6px; background: var(--black); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.thumb .del {
  position: absolute; top: 6px; left: 6px;
  background: var(--red); color: #fff; border: 0;
  width: 26px; height: 26px; border-radius: 50%;
  cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.thumb .del:hover { background: var(--red-2); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  background: var(--gray);
  cursor: pointer;
  transition: var(--transition);
  min-height: 160px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--red); background: rgba(227,6,19,0.05); }
.dropzone svg { width: 44px; height: 44px; color: var(--red); margin-bottom: 10px; display: block; }
.dropzone p { margin: 4px 0; }
.dropzone .hint { color: var(--muted); font-size: 13px; }

/* ============ QR cards ============ */
.qr-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; margin-top: 14px;
}
.qr-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--card);
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.qr-canvas-wrap { text-align: center; }
.qr-canvas-wrap canvas {
  width: 240px; height: 240px; max-width: 100%;
  border: 4px solid var(--red);
  border-radius: 12px;
  background: #fff;
  padding: 6px;
}
.qr-meta .label { font-weight: 700; margin-bottom: 4px; }
.qr-url {
  font-family: monospace; font-size: 12px;
  background: var(--gray); padding: 6px 10px;
  border-radius: 6px; word-break: break-all;
  color: var(--muted);
}
.qr-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ Login page ============ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--black), #1a1a1a);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 18px;
  padding: 36px 30px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-card img { width: 100px; height: 100px; margin: 0 auto 16px; border-radius: 14px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card h1 b { color: var(--red); }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .btn { justify-content: center; padding: 12px; }

/* ============ Empty state ============ */
.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 15px;
}
.empty .icon-circle {
  width: 70px; height: 70px;
  background: var(--gray); border-radius: 50%;
  margin: 0 auto 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--red);
}
.empty .icon-circle svg { width: 32px; height: 32px; }

/* Responsive */
@media (max-width: 880px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

/* Phone-frame iframe preview — fills the column width */
.phone-frame-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.phone-frame {
  width: 100%;
  aspect-ratio: 9 / 17;
  border: 14px solid #1a1a1a;
  border-radius: 40px;
  background: #1a1a1a;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.phone-frame::before {
  content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  width: 80px; height: 8px; background: #000; border-radius: 4px; z-index: 2;
}
.phone-frame iframe {
  width: 100%; height: 100%; border: 0; display: block;
  background: #fff; border-radius: 26px;
}
.save-status-saving { color: #b97a00 }
.save-status-saved  { color: #2c8a3a }
.save-status-error  { color: var(--red, #d1202b) }
