/* ============================================================================
   Vedatricks Integration Hub — Admin design system
   shadcn-inspired: semantic HSL tokens, one radius scale, subtle borders,
   accessible focus rings, light + dark. Brand: Manrope + #7BC142 green.
   ========================================================================== */

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

:root {
  /* palette (HSL channels, consumed via hsl(var(--x))) */
  --background: 240 20% 99%;
  --foreground: 240 10% 8%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 8%;
  --popover: 0 0% 100%;
  --muted: 240 5% 96%;
  --muted-foreground: 240 4% 44%;
  --subtle: 240 6% 90%;
  --border: 240 6% 90%;
  --input: 240 6% 88%;
  --ring: 96 48% 46%;

  --primary: 96 48% 46%;            /* #7BC142 family */
  --primary-hover: 96 52% 40%;
  --primary-foreground: 0 0% 100%;
  --primary-soft: 96 45% 94%;

  --success: 142 55% 42%;
  --success-soft: 142 55% 94%;
  --warning: 38 92% 48%;
  --warning-soft: 38 92% 94%;
  --danger: 0 72% 51%;
  --danger-soft: 0 72% 96%;
  --info: 214 80% 52%;
  --info-soft: 214 80% 95%;

  --radius: 0.6rem;
  --radius-sm: 0.4rem;
  --radius-lg: 0.85rem;

  --shadow-sm: 0 1px 2px 0 hsl(240 10% 10% / 0.04);
  --shadow: 0 1px 3px 0 hsl(240 10% 10% / 0.06), 0 1px 2px -1px hsl(240 10% 10% / 0.05);
  --shadow-md: 0 4px 12px -2px hsl(240 10% 10% / 0.10), 0 2px 6px -2px hsl(240 10% 10% / 0.06);
  --shadow-lg: 0 12px 32px -8px hsl(240 10% 10% / 0.16);

  --sidebar-w: 244px;
  --topbar-h: 60px;
  --content-max: 1200px;
}

:root[data-theme="dark"] {
  --background: 240 10% 6%;
  --foreground: 240 10% 96%;
  --card: 240 9% 9%;
  --card-foreground: 240 10% 96%;
  --popover: 240 9% 10%;
  --muted: 240 6% 14%;
  --muted-foreground: 240 5% 60%;
  --subtle: 240 5% 18%;
  --border: 240 5% 18%;
  --input: 240 5% 22%;
  --ring: 96 46% 52%;
  --primary: 96 46% 50%;
  --primary-hover: 96 50% 56%;
  --primary-foreground: 240 10% 6%;
  --primary-soft: 96 30% 16%;
  --success-soft: 142 40% 14%;
  --warning-soft: 38 50% 14%;
  --danger-soft: 0 45% 16%;
  --info-soft: 214 45% 16%;
  --shadow-sm: 0 1px 2px 0 hsl(0 0% 0% / 0.3);
  --shadow: 0 1px 3px 0 hsl(0 0% 0% / 0.4);
  --shadow-md: 0 6px 16px -4px hsl(0 0% 0% / 0.5);
  --shadow-lg: 0 16px 40px -8px hsl(0 0% 0% / 0.6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
::selection { background: hsl(var(--primary) / 0.2); }
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; border-radius: var(--radius-sm); }
/* Default icon size — specific component rules (.btn/.stat__icon/etc.) override this */
svg { width: 18px; height: 18px; flex: none; }
.card__head > svg { color: hsl(var(--muted-foreground)); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: hsl(var(--subtle)); border-radius: 99px; border: 2px solid hsl(var(--background)); }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.5); }

/* ---------- App shell ---------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  display: flex; flex-direction: column;
  padding: 16px 12px;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; }
.sidebar__logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--primary-hover)));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow);
}
.sidebar__brand b { font-size: 14.5px; letter-spacing: -0.02em; }
.sidebar__brand span { display: block; font-size: 11px; color: hsl(var(--muted-foreground)); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground)); padding: 14px 10px 6px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground)); font-weight: 600; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav__item svg { width: 17px; height: 17px; flex: none; }
.nav__item:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.nav__item.is-active { background: hsl(var(--primary-soft)); color: hsl(var(--primary-hover)); }
:root[data-theme="dark"] .nav__item.is-active { color: hsl(var(--primary)); }
.nav__item .badge { margin-left: auto; }
.sidebar__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid hsl(var(--border)); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 0 clamp(16px, 3vw, 32px);
  background: hsl(var(--background) / 0.8); backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}
.topbar h1 { font-size: 16px; }
.topbar__sub { color: hsl(var(--muted-foreground)); font-size: 13px; font-weight: 500; }
.topbar__spacer { flex: 1; }
.content { padding: clamp(18px, 3vw, 32px); max-width: var(--content-max); width: 100%; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; background: hsl(var(--muted)); color: hsl(var(--foreground));
  transition: background .12s, border-color .12s, box-shadow .12s, opacity .12s; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: hsl(var(--subtle)); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: hsl(var(--primary-hover)); }
.btn--outline { background: transparent; border-color: hsl(var(--border)); }
.btn--outline:hover { background: hsl(var(--muted)); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: hsl(var(--muted)); }
.btn--danger { background: hsl(var(--danger)); color: #fff; }
.btn--danger:hover { background: hsl(var(--danger) / 0.88); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn--icon { width: 34px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }

/* ---------- Cards -------------------------------------------------------- */
.card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__head { padding: 18px 20px; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center; gap: 12px; }
.card__head h3 { font-size: 15px; }
.card__head .sub { color: hsl(var(--muted-foreground)); font-size: 12.5px; font-weight: 500; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }

/* ---------- Stat tiles --------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm); }
.stat__top { display: flex; align-items: center; justify-content: space-between; color: hsl(var(--muted-foreground)); }
.stat__top span { font-size: 12.5px; font-weight: 600; }
.stat__icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.stat__icon svg { width: 16px; height: 16px; }
.stat__val { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 10px; }
.stat__val small { font-size: 15px; color: hsl(var(--muted-foreground)); font-weight: 600; }
.stat--accent .stat__icon { background: hsl(var(--primary-soft)); color: hsl(var(--primary-hover)); }

/* ---------- Tables ------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: hsl(var(--muted-foreground)); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.03em; padding: 11px 16px; border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; }
.tbl td { padding: 13px 16px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: hsl(var(--muted) / 0.5); }
.tbl .mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.tbl .strong { font-weight: 600; }

/* ---------- Badges ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: hsl(var(--success-soft)); color: hsl(var(--success)); }
.badge--warning { background: hsl(var(--warning-soft)); color: hsl(var(--warning)); }
.badge--danger  { background: hsl(var(--danger-soft));  color: hsl(var(--danger)); }
.badge--info    { background: hsl(var(--info-soft));    color: hsl(var(--info)); }
.badge--primary { background: hsl(var(--primary-soft)); color: hsl(var(--primary-hover)); }

/* ---------- Forms -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: hsl(var(--muted-foreground)); }
.input, .select, textarea.input {
  height: 38px; width: 100%; padding: 0 12px; font-family: inherit; font-size: 13.5px;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input)); border-radius: var(--radius-sm); transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; line-height: 1.5; }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394969c' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; cursor: pointer; }

/* ---------- Misc --------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; letter-spacing: -0.02em; }
.page-head p { color: hsl(var(--muted-foreground)); font-size: 13.5px; margin: 4px 0 0; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.muted { color: hsl(var(--muted-foreground)); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: hsl(var(--muted));
  padding: 2px 6px; border-radius: 5px; border: 1px solid hsl(var(--border)); }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: hsl(var(--muted)); display: grid; place-items: center;
  color: hsl(var(--muted-foreground)); font-weight: 700; font-size: 12px; }
.sep { height: 1px; background: hsl(var(--border)); margin: 16px 0; }

.empty { text-align: center; padding: 48px 24px; color: hsl(var(--muted-foreground)); }
.empty__icon { width: 46px; height: 46px; border-radius: 12px; background: hsl(var(--muted)); display: grid;
  place-items: center; margin: 0 auto 14px; color: hsl(var(--muted-foreground)); }
.empty__icon svg { width: 22px; height: 22px; }
.empty h4 { color: hsl(var(--foreground)); font-size: 15px; margin-bottom: 4px; }

/* alerts / flash */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500;
  border: 1px solid hsl(var(--border)); margin-bottom: 16px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert--success { background: hsl(var(--success-soft)); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.alert--danger { background: hsl(var(--danger-soft)); color: hsl(var(--danger)); border-color: hsl(var(--danger) / 0.3); }
.alert--info { background: hsl(var(--info-soft)); color: hsl(var(--info)); border-color: hsl(var(--info) / 0.3); }

/* toast */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; background: hsl(var(--popover)); border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-lg); border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; font-weight: 500;
  min-width: 240px; animation: toastIn .18s ease; }
.toast svg { width: 18px; height: 18px; }
.toast--success svg { color: hsl(var(--success)); }
.toast--danger svg { color: hsl(var(--danger)); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* modal */
.modal-bg { position: fixed; inset: 0; background: hsl(240 10% 4% / 0.45); display: none; place-items: center; z-index: 90; padding: 20px; }
.modal-bg.open { display: grid; }
.modal { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; animation: toastIn .18s ease; }
.modal__head { padding: 18px 20px; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center; }
.modal__head h3 { font-size: 16px; }
.modal__head .btn { margin-left: auto; }
.modal__body { padding: 20px; }
.modal__foot { padding: 14px 20px; border-top: 1px solid hsl(var(--border)); display: flex; justify-content: flex-end; gap: 8px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, hsl(var(--primary-soft)), transparent), hsl(var(--background)); }
.login__card { width: 100%; max-width: 380px; }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; }
.login__brand .sidebar__logo { width: 44px; height: 44px; font-size: 20px; }

/* responsive */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; width: var(--sidebar-w); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar__menu { display: inline-flex !important; }
}
.topbar__menu { display: none; }
