/* ==========================================================================
   Smarttcargo admin portal
   Layered on top of app.css - same tokens, same type scale, denser layout.
   ========================================================================== */

/* ------------------------------------------------------------------ auth */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-weak-50);
  position: relative;
  overflow: hidden;
}
.auth::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto -10%;
  height: 560px;
  background: radial-gradient(50% 55% at 50% 40%, var(--primary-alpha-10), transparent 70%);
  pointer-events: none;
}
.auth__card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-white-0);
  border: 1px solid var(--stroke-soft-200);
  border-radius: var(--radius-20);
  padding: 32px;
  box-shadow: var(--shadow-medium);
}
.auth__brand { display: flex; justify-content: center; margin-bottom: 24px; }
.auth__foot { margin-top: 24px; text-align: center; font-size: 13px; color: var(--text-soft-400); }
.auth__foot a { color: var(--text-sub-600); }
.auth__foot a:hover { color: var(--text-strong-950); }

/* ----------------------------------------------------------------- shell */

.admin-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }

.admin-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: var(--bg-weak-50);
  border-right: 1px solid var(--stroke-soft-200);
  overflow-y: auto;
}
.admin-sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 20px; }

.admin-nav__section {
  padding: 16px 10px 6px;
  font-size: 11px;
  letter-spacing: 0.22px;
  text-transform: uppercase;
  color: var(--text-soft-400);
  font-weight: 500;
}
.admin-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding-inline: 10px;
  border-radius: var(--radius-8);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub-600);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.admin-nav__link:hover { background: var(--bg-hover); color: var(--text-strong-950); }
.admin-nav__link[aria-current="page"] {
  background: var(--bg-white-0);
  color: var(--text-strong-950);
  box-shadow: var(--shadow-button);
}
.admin-nav__link svg { flex-shrink: 0; color: var(--icon-soft-400); }
.admin-nav__link[aria-current="page"] svg { color: var(--primary-base); }
.admin-nav__spacer { margin-top: auto; }

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

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: 24px;
  background: color-mix(in srgb, var(--bg-white-0) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--stroke-soft-200);
}
.admin-topbar__title { font-size: 16px; font-weight: 500; letter-spacing: -0.176px; }
.admin-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.admin-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  background: var(--bg-weak-50);
  border: 1px solid var(--stroke-soft-200);
}
.admin-user__avatar {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-base);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.admin-user__name { font-size: 13px; font-weight: 500; }

.admin-content { padding: 24px; flex: 1; }
.admin-page { display: none; }
.admin-page[data-active="true"] { display: block; }

.sidebar-toggle { display: none; }

/* Same reasoning as the controls block in app.css - these are clicked, not
   read. Table cells stay selectable so tracking numbers can be copied. */
.tab,
.admin-nav__link,
.sidebar-toggle {
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 1000px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease);
    box-shadow: var(--shadow-large);
  }
  .admin-sidebar[data-open="true"] { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .admin-content { padding: 16px; }
  .admin-topbar { padding-inline: 16px; }
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: #17171766;
  opacity: 0;
  visibility: hidden;
  /* visibility is transitioned, so it lingers as `visible` for the whole
     fade-out. Without this a full-screen scrim keeps taking every click in
     that window, and its own close handler fires instead of the control the
     user aimed at. pointer-events is not transitioned, so it flips at once. */
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), visibility var(--duration-base);
}
.sidebar-scrim[data-open="true"] { opacity: 1; visibility: visible; pointer-events: auto; }

/* ------------------------------------------------------------- stat tiles */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.tile {
  background: var(--bg-white-0);
  border: 1px solid var(--stroke-soft-200);
  border-radius: var(--radius-12);
  padding: 16px;
  box-shadow: var(--shadow-button);
}
.tile__label { font-size: 12px; color: var(--text-sub-600); display: flex; align-items: center; gap: 6px; }
.tile__value { font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -0.16px; margin-top: 6px; }
.tile__dot { width: 8px; height: 8px; border-radius: 50%; }

/* ----------------------------------------------------------------- table */

.table-wrap {
  background: var(--bg-white-0);
  border: 1px solid var(--stroke-soft-200);
  border-radius: var(--radius-12);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 860px; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.22px;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-soft-400);
  padding: 12px 16px;
  background: var(--bg-weak-50);
  border-bottom: 1px solid var(--stroke-soft-200);
  white-space: nowrap;
}
.table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--stroke-soft-200);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; transition: background var(--duration-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--bg-weak-50); }
.table__mono { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.table__sub { font-size: 12px; color: var(--text-soft-400); margin-top: 2px; }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke-soft-200);
  background: var(--bg-white-0);
}
.toolbar .input, .toolbar .select { height: 36px; box-shadow: none; }
.toolbar__search { flex: 1; min-width: 200px; max-width: 340px; }

/* ----------------------------------------------------------------- forms */

.form-section { margin-bottom: 28px; }
.form-section__title {
  font-size: 12px;
  letter-spacing: 0.48px;
  text-transform: uppercase;
  color: var(--text-soft-400);
  font-weight: 500;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--stroke-soft-200);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid--full > .field--wide { grid-column: 1 / -1; }

.form-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--stroke-soft-200);
  background: var(--bg-white-0);
}

.input-with-button { display: flex; gap: 8px; }
.input-with-button .input { flex: 1; }

/* ---------------------------------------------------------------- drawer */

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #17171766;
  opacity: 0;
  visibility: hidden;
  /* visibility is transitioned, so it lingers as `visible` for the whole
     fade-out. Without this a full-screen scrim keeps taking every click in
     that window, and its own close handler fires instead of the control the
     user aimed at. pointer-events is not transitioned, so it flips at once. */
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), visibility var(--duration-base);
}
.drawer-scrim[data-open="true"] { opacity: 1; visibility: visible; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 75;
  width: min(640px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-white-0);
  border-left: 1px solid var(--stroke-soft-200);
  box-shadow: var(--shadow-large);
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease);
}
.drawer[data-open="true"] { transform: translateX(0); }
.drawer__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--stroke-soft-200);
}
.drawer__body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer__close {
  margin-left: auto;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--stroke-soft-200);
  background: var(--bg-white-0);
  border-radius: var(--radius-8);
  cursor: pointer;
  color: var(--text-sub-600);
}
.drawer__close:hover { background: var(--bg-weak-50); color: var(--text-strong-950); }

/* ----------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 4px; padding: 3px; background: var(--bg-weak-50); border-radius: var(--radius-10); }
.tab {
  flex: 1;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-8);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub-600);
  cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--bg-white-0);
  color: var(--text-strong-950);
  box-shadow: var(--shadow-button);
}
.tab-panel { display: none; }
.tab-panel[data-active="true"] { display: block; }

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 40px));
  /* The container sits above everything at z-index 200. Clicks pass through
     it to whatever is underneath; the toasts themselves stay clickable. */
  pointer-events: none;
}
.toast { pointer-events: auto; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-10);
  background: var(--bg-white-0);
  border: 1px solid var(--stroke-soft-200);
  box-shadow: var(--shadow-medium);
  font-size: 14px;
  animation: toast-in var(--duration-base) var(--ease-out);
}
.toast--success { border-left: 3px solid var(--success-base); }
.toast--error { border-left: 3px solid var(--error-base); }
.toast--info { border-left: 3px solid var(--info-base); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- modal */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #17171766;
  opacity: 0;
  visibility: hidden;
  /* visibility is transitioned, so it lingers as `visible` for the whole
     fade-out. Without this a full-screen scrim keeps taking every click in
     that window, and its own close handler fires instead of the control the
     user aimed at. pointer-events is not transitioned, so it flips at once. */
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), visibility var(--duration-base);
}
.modal-scrim[data-open="true"] { opacity: 1; visibility: visible; pointer-events: auto; }
.modal {
  width: 100%;
  max-width: 400px;
  background: var(--bg-white-0);
  border-radius: var(--radius-16);
  padding: 24px;
  box-shadow: var(--shadow-large);
}

/* --------------------------------------------------------------- misc */

.skeleton {
  height: 14px;
  border-radius: var(--radius-4);
  background: linear-gradient(90deg, var(--bg-weak-50), var(--bg-soft-200), var(--bg-weak-50));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-soft-400);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-4);
}
.copy-btn:hover { color: var(--primary-base); }

.enquiry {
  border: 1px solid var(--stroke-soft-200);
  border-radius: var(--radius-12);
  padding: 16px;
  background: var(--bg-white-0);
}
.enquiry[data-handled="true"] { opacity: 0.62; }
.enquiry__message {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-sub-600);
  margin-top: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Opt-out for the receiver notification, shown beside the event form. */
.notify-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--stroke-soft-200);
  border-radius: var(--radius-10);
  background: var(--bg-weak-50);
  cursor: pointer;
}
.notify-toggle input { margin-top: 2px; accent-color: var(--primary-base); flex-shrink: 0; }
.notify-toggle strong { display: block; font-size: 14px; font-weight: 500; }
.notify-toggle em {
  display: block;
  font-style: normal;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-soft-400);
  margin-top: 2px;
}
.notify-toggle:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }

/* Opt-out for the receiver notification, shown beside the event form. */
.notify-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--stroke-soft-200);
  border-radius: var(--radius-10);
  background: var(--bg-weak-50);
  cursor: pointer;
}
.notify-toggle input { margin-top: 2px; accent-color: var(--primary-base); flex-shrink: 0; }
.notify-toggle strong { display: block; font-size: 14px; font-weight: 500; }
.notify-toggle em {
  display: block;
  font-style: normal;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-soft-400);
  margin-top: 2px;
}
.notify-toggle:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }
