/* ============================================================================
   Bahari Admin: the look of the staff dashboard.
   Colours live in the :root block right below.
   ========================================================================= */

:root {
  --purple: #8b5cf6;
  --purple-dark: #6d28d9;
  --purple-soft: #f5f3ff;
  --ocean: #0ea5e9;
  --deep: #0369a1;
  --sand: #fde68a;
  --coral: #f97316;
  --success: #22c55e;
  --success-dark: #15803d;
  --danger: #ef4444;
  --dark: #1e293b;
  --gray: #64748b;
  --gray-light: #94a3b8;
  --line: #e2e8f0;
  --light-bg: #f1f5f9;
  --white: #ffffff;
  --accent: var(--purple);
  --radius: 14px;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--dark); background: var(--light-bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
.muted { color: var(--gray); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* -------------------------------------------------------------- Top bar -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 16px;
  background: var(--purple);
  color: var(--white);
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { font-size: 13px; opacity: 0.95; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, 0.15); color: inherit; font-size: 18px; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.25); }
.menu-btn { display: none; }
.logout-btn { background: rgba(255, 255, 255, 0.15); color: var(--white); }
.logout-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* --------------------------------------------------------- Side menu -- */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 220px;
  flex: none;
  background: var(--white);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 0 24px;
}
.sidebar .group { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gray); padding: 18px 20px 6px; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  color: var(--gray);
  text-decoration: none;
  font-size: 14px;
}
.sidebar a .ic { font-size: 18px; width: 24px; text-align: center; flex: none; }
.sidebar a:hover { background: var(--light-bg); }
.sidebar a.on { background: var(--purple-soft); color: var(--purple-dark); font-weight: 700; }
.sidebar .drawer-head { display: none; }
.main { flex: 1; min-width: 0; overflow-x: hidden; padding: 24px; }
.drawer-backdrop { display: none; }

/* Medium screens: icons with small labels underneath. */
@media (max-width: 999px) and (min-width: 700px) {
  .sidebar { width: 92px; }
  .sidebar .group { text-align: center; padding: 16px 6px 4px; font-size: 10px; }
  .sidebar a { flex-direction: column; gap: 4px; padding: 10px 6px; font-size: 10.5px; text-align: center; }
}

/* Phones: the menu slides in from the left. */
@media (max-width: 699px) {
  .menu-btn { display: grid; }
  .topbar .who { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(290px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.22s;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    padding-top: 0;
  }
  .sidebar .drawer-head { display: block; background: var(--purple); color: var(--white); padding: 20px; }
  .menu-open .sidebar { transform: none; }
  .menu-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, 0.45); }
  .main { padding: 16px; }
}

/* ------------------------------------------------------- Page headings -- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; max-width: 760px; }
.page-head h2 { font-size: 20px; font-weight: 800; }
.page-head p { margin-top: 4px; color: var(--gray); font-size: 14px; }
.narrow { max-width: 760px; }

/* ---------------------------------------------------------------- Buttons -- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { filter: brightness(0.95); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.block { width: 100%; }
.btn-primary { background: var(--purple); color: var(--white); }
.btn-success { background: var(--success-dark); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-outline { background: var(--white); color: var(--purple-dark); border-color: var(--purple); }
.btn-outline-danger { background: var(--white); color: #b91c1c; border-color: var(--danger); }
.btn-outline-success { background: var(--white); color: var(--success-dark); border-color: var(--success); }
.btn-plain { background: transparent; color: var(--gray); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn.is-busy { color: transparent !important; }
.btn.is-busy::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: var(--white);
  animation: spin 0.8s linear infinite;
}
.btn-outline.is-busy::after, .btn-outline-danger.is-busy::after, .btn-outline-success.is-busy::after, .btn-plain.is-busy::after {
  border-color: var(--line);
  border-top-color: var(--purple);
}
.tool-btn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; font-size: 16px; display: grid; place-items: center; flex: none; }
.tool-btn:hover { background: var(--light-bg); }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 32px; height: 32px; margin: 32px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--purple); animation: spin 0.8s linear infinite; }

/* ----------------------------------------------------------------- Forms -- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--gray); }
.field .help { font-size: 12px; color: var(--gray); }
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: var(--white);
  font-size: 15px;
  outline: none;
}
.input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }
select.input { appearance: auto; }
.form-error { color: #b91c1c; font-size: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 38px; padding: 6px 16px; border-radius: 20px; border: 1.5px solid #cbd5e1; background: var(--white); font-weight: 600; font-size: 14px; }
.chip[aria-checked='true'] { background: var(--purple-soft); border-color: var(--purple); color: var(--purple-dark); }
.form-card { background: var(--white); border-radius: 16px; padding: 20px; max-width: 520px; display: flex; flex-direction: column; gap: 14px; }
.search { position: relative; max-width: 640px; margin-bottom: 16px; }
.search .input { padding-left: 40px; }
.search span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray); }

/* ------------------------------------------------------------------ Cards -- */
.item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  max-width: 760px;
  margin-bottom: 10px;
}
.item .name { font-weight: 700; }
.item .sub { color: var(--gray); font-size: 13px; word-break: break-word; }
.item .actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.item .actions .btn { flex: 1; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--sand); display: grid; place-items: center; font-size: 18px; flex: none; }
.avatar.ocean { background: var(--ocean); }
.avatar.purple { background: var(--purple); }
.amount { color: var(--coral); font-weight: 800; white-space: nowrap; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-sky { background: #e0f2fe; color: var(--deep); }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: var(--light-bg); color: var(--gray); }

.empty { text-align: center; color: var(--gray); padding: 40px 16px; max-width: 760px; }
.empty .big { display: block; font-size: 40px; margin-bottom: 8px; }

/* -------------------------------------------------------------- Overview -- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; max-width: 900px; }
@media (max-width: 420px) { .stats { gap: 10px; } .stat-card { padding: 12px; } }
.stat-card { background: var(--white); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.stat-card .ic { font-size: 24px; }
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.stat-card .label { font-size: 13px; color: var(--gray); }
.charts { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; max-width: 900px; }
@media (max-width: 860px) { .charts { grid-template-columns: 1fr; } }
.chart-card { background: var(--white); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.chart-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--gray); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 8px; height: 200px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bars .bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .bar b { font-size: 12px; color: var(--dark); margin-bottom: 4px; }
.bars .bar i { display: block; width: min(28px, 70%); min-height: 2px; border-radius: 6px 6px 0 0; background: var(--coral); }
.bar-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 6px; text-align: center; font-size: 12px; color: var(--gray); }
.donut { display: block; margin: 0 auto; width: 180px; height: 180px; }

/* ---------------------------------------------------------- Activity log -- */
.log-row { display: flex; align-items: center; gap: 12px; background: var(--white); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; max-width: 760px; }
.log-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); flex: none; }
.log-row time { font-size: 12px; color: var(--gray); white-space: nowrap; }

/* ------------------------------------------------------------- Log in -- */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; background: var(--white); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { text-align: center; }
.login-card .brand .big { font-size: 44px; }
.login-card h1 { font-size: 22px; font-weight: 800; }

/* ----------------------------------------------------- Pop-ups and toast -- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, 0.5); opacity: 0; transition: opacity 0.18s; }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; background: var(--white); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-title { font-size: 19px; font-weight: 800; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.secret { font-size: 20px; font-weight: 800; letter-spacing: 1px; background: var(--light-bg); border-radius: 10px; padding: 10px 14px; user-select: all; }
.sheet-handle { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(480px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 12px;
  color: var(--white);
  background: var(--dark);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: #b91c1c; }
.toast-success { background: var(--success-dark); }
.splash { flex: 1; display: grid; place-items: center; min-height: 100vh; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
