/*
 * Platform admin panel. Same look as the shop app: the colour tokens come from
 * tokens.css (dark by default, light via data-theme), the type and component
 * shapes from app.css's conventions.
 *
 * The screens are written with Tailwind utility classes (bg-white,
 * text-slate-500, bg-emerald-100 …). Rather than rewrite every screen, the
 * "theme bridge" at the bottom maps those classes onto the tokens, so the
 * panel follows the theme. Selectors there start with :root to outrank the
 * Tailwind runtime, which injects its styles after this file.
 */

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  background: var(--background);
  color: var(--foreground);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--primary);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Every border in the theme colour (Tailwind's default and "border-border");
   it comes first so component rules below can still set their own. */
:root *,
:root ::before,
:root ::after {
  border-color: var(--border);
}

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

.p-sidebar {
  width: 248px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.p-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.p-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: var(--primary);
  box-shadow: var(--shadow-primary);
}

.p-brand-name {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.p-brand-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--foreground);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--ring);
}

.p-sidebar-foot {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.p-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.p-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--foreground);
}

/* ------------------------------------------------------------------ components */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-primary);
  transition: background 0.12s ease;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
}

/* Small pill button for inline actions. */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--foreground);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.action-btn:hover {
  background: var(--surface-hover);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn-danger {
  color: var(--danger-foreground);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.action-btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.field {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--background);
  color: var(--foreground);
}

.field:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 28%, transparent);
}

.field:disabled {
  opacity: 0.6;
}

/* Inputs written with utility classes only (forms in dialogs, login). */
:root input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
:root select,
:root textarea {
  background-color: var(--background);
  color: var(--foreground);
}

:root input::placeholder,
:root textarea::placeholder {
  color: var(--subtle);
}

:root option {
  background: var(--surface);
  color: var(--foreground);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

input[type="date"] {
  color-scheme: inherit;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--ring);
  border-radius: 50%;
  animation: p-spin 0.8s linear infinite;
}

@keyframes p-spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: 88vw;
  pointer-events: none;
}

/* Usage-versus-plan-limit meter. */
.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.meter-ok > span { background: var(--success); }
.meter-warn > span { background: var(--warning); }
.meter-over > span { background: var(--danger); }

/* Scrollbars that do not glare in the dark theme. */
* {
  scrollbar-color: var(--border) transparent;
}

/* ------------------------------------------------------------------ theme bridge */

/* Lines: the panel's "border-border" and white rings (timeline dots). */
:root .border-border { border-color: var(--border); }
:root .border-white { border-color: var(--surface); }

/* Surfaces */
:root .bg-white { background-color: var(--surface); }
:root .bg-bg { background-color: var(--background); }
:root .bg-slate-50 { background-color: var(--surface-sunken); }
:root .bg-slate-100 { background-color: var(--surface-hover); }
:root .hover\:bg-slate-50:hover { background-color: var(--surface-hover); }
:root .bg-black\/40 { background-color: rgb(0 0 0 / 0.6); }

/* Text */
:root .text-dark,
:root .text-slate-900,
:root .text-slate-800,
:root .text-slate-700,
:root .hover\:text-slate-800:hover { color: var(--foreground); }
:root .text-slate-600,
:root .text-slate-500 { color: var(--muted); }
:root .text-slate-400 { color: var(--subtle); }

/* Brand */
:root .text-primary { color: var(--ring); }
:root .bg-primary { background-color: var(--primary); }
:root .bg-primary\/10 { background-color: var(--primary-soft); }
:root .border-primary { border-color: var(--ring); }
:root .ring-primary,
:root .focus\:ring-primary:focus { --tw-ring-color: var(--ring); }

/* Status colours: soft background + readable foreground, per theme. */
:root .bg-emerald-50 { background-color: color-mix(in srgb, var(--success) 10%, transparent); }
:root .bg-emerald-100 { background-color: color-mix(in srgb, var(--success) 16%, transparent); }
:root .bg-emerald-600 { background-color: var(--success); }
:root .text-emerald-600,
:root .text-emerald-700 { color: var(--success-foreground); }

:root .bg-amber-50 { background-color: color-mix(in srgb, var(--warning) 10%, transparent); }
:root .bg-amber-100 { background-color: color-mix(in srgb, var(--warning) 16%, transparent); }
:root .text-amber-600,
:root .text-amber-700 { color: var(--warning-foreground); }

:root .bg-red-50 { background-color: color-mix(in srgb, var(--danger) 10%, transparent); }
:root .bg-red-100 { background-color: color-mix(in srgb, var(--danger) 16%, transparent); }
:root .bg-red-600 { background-color: var(--danger); }
:root .border-red-200 { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
:root .text-red-600,
:root .text-red-700 { color: var(--danger-foreground); }

:root .bg-sky-100 { background-color: var(--primary-soft); }
:root .text-sky-600,
:root .text-sky-700 { color: var(--ring); }

:root .bg-violet-50 { background-color: color-mix(in srgb, var(--accent-foreground) 10%, transparent); }
:root .bg-violet-100 { background-color: color-mix(in srgb, var(--accent-foreground) 16%, transparent); }
:root .text-violet-700 { color: var(--accent-foreground); }

/* ServisGet logotype (logo.js wordmark()): bold, upright, "Get" in brand blue, as in logo.png. */
.wordmark {
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.wordmark-get {
  color: var(--ring);
}

.wordmark-lg {
  font-size: 30px;
  line-height: 1.1;
}

/* The logo tile carries its own blue square and corners. */
.brand-mark,
.auth-logo,
.p-brand-mark {
  background: transparent;
}

.brand-mark svg,
.auth-logo svg,
.p-brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
