@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --text: #111827;
  --text-muted: #6b7280;
  --radius: 14px;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
}

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

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #111827;
  color: #f9fafb;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 15px;
  color: #9ca3af;
  margin: 0 0 14px;
  font-weight: 700;
}

.sidebar .db-path {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 18px;
  word-break: break-all;
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #d1d5db;
  margin-bottom: 4px;
  transition: background .15s;
}

.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }

.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  animation: navBadgePulse 1.4s infinite;
}

@keyframes navBadgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.sidebar .logout {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #1f2937;
}

.sidebar .logout button {
  width: 100%;
  background: transparent;
  border: 1px solid #374151;
  color: #d1d5db;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.sidebar .logout button:hover { background: #1f2937; }

/* ---------- Main content ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 60px;
}

.page-header {
  margin-bottom: 18px;
}
.page-header h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}

/* ---------- Flash messages ---------- */
.flash-list { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.card h3 { margin-top: 0; font-size: 16px; }
.card .muted { color: var(--text-muted); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Form elements ---------- */
label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
  margin-top: 10px;
}
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.checkbox-row input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.12); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Table ---------- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; }
th { color: var(--text-muted); font-weight: 600; background: #fafafa; }
tr:hover td { background: #fafcff; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* ---------- Metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 720px) { .metrics { grid-template-columns: 1fr 1fr; } }
.metric {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.metric .label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.metric .value { font-size: 20px; font-weight: 700; }
.metric .delta { font-size: 12px; color: var(--success); margin-top: 3px; }

/* ---------- Receipt / order item ---------- */
.order-item {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 900px) { .order-item { grid-template-columns: 1fr; } }
.order-item img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.order-item .field { margin-bottom: 4px; font-size: 13.5px; }
.order-item .field b { color: var(--text); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111827, #1f2937);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

/* ---------- Expander-like details ---------- */
details.exp {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
}
details.exp > summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
}
details.exp > summary::-webkit-details-marker { display: none; }
details.exp .exp-body { padding: 4px 18px 18px; }

/* ---------- Mobile sidebar toggle ---------- */
.mobile-topbar { display: none; }
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed;
    inset-inline-start: -260px;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: inset-inline-start .2s;
    width: 240px;
  }
  .sidebar.open { inset-inline-start: 0; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #111827;
    color: #fff;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .mobile-topbar button {
    background: transparent;
    border: 1px solid #374151;
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 18px;
  }
  .main { padding: 16px; }
}

pre.json-box {
  background: #0b1020;
  color: #d1fae5;
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12.5px;
  direction: ltr;
  text-align: left;
}
