/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --ink: #0B2B26;
  --primary: #0F6B64;
  --primary-dark: #0A4F4A;
  --primary-light: #14867D;
  --accent: #3B7FB8;
  --bg: #F3F6F5;
  --surface: #FFFFFF;
  --border: #DCE4E2;
  --text-muted: #5B6B68;
  --success: #2F8F5B;
  --warning: #B8860B;
  --danger: #B23A48;

  --radius-sharp: 4px;
  --radius-soft: 12px;
  --radius-full: 999px;

  --sidebar-width: 260px;
  --font-display: "Sora", "Cairo", sans-serif;
  --font-body: "Inter", "Cairo", sans-serif;
}
[data-bs-theme="dark"] {
  --ink: #E8EEEC;
  --primary: #14867D;
  --primary-dark: #0F6B64;
  --primary-light: #1A9D93;
  --accent: #5B9BD6;
  --bg: #12201E;
  --surface: #1A2C29;
  --border: #2C3F3C;
  --text-muted: #8FA19E;
  --danger: #D9707E;
  --warning: #D9A441;
  --success: #4CB37D;
}

[data-bs-theme="dark"] body { background: var(--bg); color: var(--ink); }
[data-bs-theme="dark"] .topbar { background: var(--surface); border-color: var(--border); }
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .stat-card,
[data-bs-theme="dark"] .auth-card { background: var(--surface); border-color: var(--border); }
[data-bs-theme="dark"] .global-search-dropdown { background: var(--surface); border-color: var(--border); }
[data-bs-theme="dark"] .search-result-item { color: var(--ink); }
[data-bs-theme="dark"] .search-result-item:hover { background: var(--bg); }
[data-bs-theme="dark"] .low-stock-row { background-color: rgba(217, 112, 126, 0.12); }
[data-bs-theme="dark"] .tooth-btn { background: var(--surface); border-color: var(--border); color: var(--ink); }
/* Arabic pages switch both faces to Cairo automatically */
html[lang="ar"] {
  --font-display: "Cairo", sans-serif;
  --font-body: "Cairo", sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}

h1, h2, h3, h4, h5, .page-title, .auth-brand {
  font-family: var(--font-display);
  font-weight: 600;
}

/* ==========================================================================
   App shell (sidebar + main content)
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark), var(--primary));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  min-height: 0; /* required for overflow to work inside a flex child */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-right: 4px;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 999px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.5rem 0.5rem 1.5rem;
}

/* Signature detail: active nav item gets a small scalloped "tooth cusp"
   notch instead of a plain highlight bar. */
.sidebar .nav-link {
  position: relative;
  color: rgba(255, 255, 255, 0.85);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-soft);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease;
}

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar .nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.sidebar .nav-link.active::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50% 50% 50% 0;
  rotate: 45deg;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 0.85rem;
  margin-top: 0.5rem;
  flex-shrink: 0; /* never let the footer shrink/scroll away */
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-soft);
  margin-bottom: 0.6rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name { font-weight: 600; font-size: 0.9rem; line-height: 1.2; }
.user-role { font-size: 0.75rem; color: rgba(255, 255, 255, 0.65); }

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.35rem;
  margin: 0;
}

.content {
  padding: 1.75rem;
  flex: 1;
}

/* ==========================================================================
   Cards & data (sharp corners = precision, on data-dense elements)
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-soft);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-soft);
  padding: 1.25rem;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

table, .table {
  border-radius: var(--radius-sharp);
}

input, select, textarea, .form-control {
  border-radius: var(--radius-sharp) !important;
}

/* ==========================================================================
   Buttons (soft rounded = approachable)
   ========================================================================== */
.btn {
  border-radius: var(--radius-soft);
  font-weight: 600;
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ==========================================================================
   Auth pages (login, password reset)
   ========================================================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary) 60%, var(--accent));
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(11, 43, 38, 0.25);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 1050;
    transition: left 0.2s ease;
  }
  .sidebar.show { left: 0; }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
/* ---------- Global search ---------- */
.global-search {
  width: 100%;
  max-width: 320px;
}

.global-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-soft);
  box-shadow: 0 12px 30px rgba(11, 43, 38, 0.15);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1060;
}

.search-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.85rem 0.25rem;
  font-weight: 600;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
}

.search-result-item:hover {
  background: var(--bg);
}

@media (max-width: 992px) {
  .global-search { max-width: 160px; }
}
/* ---------- Inventory low-stock highlight (softer than Bootstrap's default) ---------- */
.low-stock-row {
  background-color: rgba(178, 58, 72, 0.06);
  border-left: 3px solid var(--danger);
}
.low-stock-row td:first-child { padding-left: calc(0.75rem - 3px); }

/* ---------- Rounded table corners inside cards ---------- */
.card .table-responsive {
  border-radius: var(--radius-soft);
  overflow: hidden;
}
.card { overflow: hidden; }

/* ---------- Notification bell ---------- */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.notification-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
}
.notification-row:last-child { border-bottom: none; }
.notification-row:hover { background: var(--bg); }