/*
  Pagebase UI Foundation
  ----------------------
  Reusable, view-agnostic CSS with consistent naming.
  Convention:
  - Prefix all classes with "pb-"
  - Component: .pb-component
  - Element: .pb-component__element
  - Modifier: .pb-component--variant
*/

:root {
  /* Colors */
  --pb-color-bg: #f4f1ec;
  --pb-color-surface: #fcfbf9;
  --pb-color-surface-muted: #f7f4ef;
  --pb-color-text: #24221e;
  --pb-color-text-muted: #676159;
  --pb-color-line: #d8d1c7;

  --pb-color-primary: #2f4340;
  --pb-color-primary-hover: #243533;
  --pb-color-primary-contrast: #eff4f3;

  --pb-color-success-bg: #e4ece9;
  --pb-color-success-text: #2d4642;
  --pb-color-warning-bg: #efe7dd;
  --pb-color-warning-text: #62584e;
  --pb-color-muted-bg: #f0ece6;
  --pb-color-muted-text: #5f584f;

  /* Radius */
  --pb-radius-sm: 8px;
  --pb-radius-md: 10px;
  --pb-radius-lg: 12px;
  --pb-radius-pill: 999px;

  /* Spacing */
  --pb-space-1: 4px;
  --pb-space-2: 8px;
  --pb-space-3: 12px;
  --pb-space-4: 16px;
  --pb-space-5: 20px;
  --pb-space-6: 24px;
  --pb-space-7: 32px;

  /* Typography */
  --pb-font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --pb-text-xs: 12px;
  --pb-text-sm: 13px;
  --pb-text-md: 14px;
  --pb-text-lg: 16px;
  --pb-text-xl: 20px;
  --pb-text-2xl: 30px;

  --pb-shadow-soft: 0 1px 0 rgba(52, 45, 35, 0.05);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--pb-font);
  color: var(--pb-color-text);
  background: var(--pb-color-bg);
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Layout */
.pb-container {
  width: min(1180px, calc(100% - 56px));
  margin: var(--pb-space-6) auto 48px;
}

.pb-stack {
  display: grid;
  gap: var(--pb-space-4);
}

.pb-row {
  display: flex;
  align-items: center;
  gap: var(--pb-space-3);
}

.pb-row--between {
  justify-content: space-between;
}

.pb-grid {
  display: grid;
  gap: var(--pb-space-4);
}

.pb-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pb-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Enskild skapa-/lägg-till-ruta: samma vertikala läge som grid-raden, centrerad i raden */
.pb-empty-center {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
}

.pb-empty-center .pb-create-tile {
  width: min(100%, 340px);
  min-height: unset;
  box-shadow: var(--pb-shadow-soft);
}

.pb-create-tile--solo {
  background: var(--pb-color-surface);
}

/* Surface / Panel */
.pb-surface {
  background: var(--pb-color-surface);
  border-radius: var(--pb-radius-lg);
  box-shadow: var(--pb-shadow-soft);
}

.pb-surface--muted {
  background: var(--pb-color-surface-muted);
}

.pb-panel {
  padding: var(--pb-space-4);
}

/* Media / Preview */
.pb-media {
  overflow: hidden;
  border-radius: var(--pb-radius-md);
  background: #f0ece6;
}

.pb-media__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* Generic card structure */
.pb-card {
  overflow: hidden;
}

.pb-card__head {
  padding: var(--pb-space-4);
  background: var(--pb-color-surface-muted);
}
.pb-card__head.white {
  background: #fff;
}

.pb-card__body {
  padding: var(--pb-space-4);
}

.pb-list {
  display: grid;
  gap: var(--pb-space-2);
}

.pb-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pb-space-3);
}

.pb-link {
  color: var(--pb-color-primary);
  font-size: var(--pb-text-sm);
  font-weight: 700;
}

.pb-link:hover {
  text-decoration: underline;
}

/* Knapp som ser ut som pb-link (t.ex. tabellrad utan href i förväg) */
.pb-link-btn {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: var(--pb-color-primary);
  font-size: var(--pb-text-sm);
  font-weight: 700;
  text-align: inherit;
}

.pb-link-btn:hover {
  text-decoration: underline;
}

.pb-form-inline {
  display: flex;
  align-items: end;
  gap: var(--pb-space-3);
  flex-wrap: wrap;
}

.pb-field--grow {
  flex: 1;
  min-width: 220px;
}

.pb-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--pb-space-2);
  flex-wrap: wrap;
}

.pb-section {
  overflow: hidden;
  border-radius: var(--pb-radius-lg);
  background: var(--pb-color-surface);
  box-shadow: var(--pb-shadow-soft);
}

.pb-section__head {
  padding: var(--pb-space-4);
  background: var(--pb-color-surface-muted);
}

.pb-meter {
  display: grid;
  gap: 6px;
  min-width: 130px;
}

.pb-meter__text {
  margin: 0;
  font-size: var(--pb-text-xs);
  color: var(--pb-color-text-muted);
}

.pb-meter__track {
  height: 6px;
  border-radius: var(--pb-radius-pill);
  background: #e4ddd2;
  overflow: hidden;
}

.pb-meter__fill {
  height: 100%;
  border-radius: var(--pb-radius-pill);
  background: var(--pb-color-primary);
}

.pb-meter__fill--high {
  background: #9a7f62;
}

.pb-split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--pb-space-4);
}

.pb-result-list {
  display: grid;
  gap: var(--pb-space-2);
}

.pb-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pb-space-3);
  padding: var(--pb-space-3);
  border-radius: var(--pb-radius-md);
  background: var(--pb-color-surface-muted);
}

.pb-result-meta {
  margin: 0;
  color: var(--pb-color-text-muted);
  font-size: var(--pb-text-xs);
}

.pb-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--pb-space-6);
}

.pb-auth__card {
  width: min(460px, 100%);
  padding: var(--pb-space-6);
}

.pb-auth__logo {
  height: 32px;
  width: auto;
  display: block;
  margin: 0 auto var(--pb-space-5);
}

.pb-auth__card > .pb-stack {
  gap: var(--pb-space-5);
}

.pb-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--pb-space-3);
  align-items: center;
}

.pb-divider::before,
.pb-divider::after {
  content: "";
  height: 1px;
  background: var(--pb-color-line);
}

.pb-divider span {
  color: var(--pb-color-text-muted);
  font-size: var(--pb-text-xs);
}

.pb-btn--google {
  background: #ffffff !important;
  border: 1px solid var(--pb-color-line) !important;
  color: #1f2937;
  min-height: 46px;
  font-weight: 700;
  box-shadow: none;
}

.pb-btn--google:hover {
  background: #f7f7f7;
  transform: none;
  box-shadow: none;
}

.pb-btn__icon {
  width: 18px;
  height: 18px;
  display: block;
}

/* Reusable create tile */
.pb-create-tile {
  min-height: 100%;
  align-content: center;
  justify-items: center;
  text-align: center;
  background: var(--pb-color-surface-muted);
}

.pb-create-tile__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--pb-radius-pill);
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  color: var(--pb-color-primary);
  background: var(--pb-color-success-bg);
}

.pb-create-tile__title {
  margin: 0;
  font-size: var(--pb-text-lg);
  font-weight: 700;
}

.pb-create-tile__text {
  margin: 0;
  color: var(--pb-color-text-muted);
  font-size: var(--pb-text-sm);
}

.pb-create-tile__action {
  min-height: 34px;
  padding: 0 12px;
}

/* Typography */
.pb-title-1 {
  margin: 0;
  font-size: var(--pb-text-2xl);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.pb-title-2 {
  margin: 0;
  font-size: var(--pb-text-xl);
  line-height: 1.25;
}

.pb-text {
  margin: 0;
  font-size: var(--pb-text-md);
}

.pb-text--muted {
  color: var(--pb-color-text-muted);
}

.pb-text--xs {
  font-size: var(--pb-text-xs);
}

/* Top Navigation */
.pb-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--pb-space-5);
  padding: 6px 0 var(--pb-space-4);
  border-bottom: 1px solid var(--pb-color-line);
}

.pb-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--pb-space-2);
  font-weight: 700;
}

.pb-nav__logo {
  height: 28px;
  width: auto;
  display: block;
}

.pb-nav__menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--pb-space-5);
}

.pb-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: var(--pb-space-2) 0;
  font-size: var(--pb-text-md);
  font-weight: 600;
  color: var(--pb-color-text-muted);
  border-bottom: 2px solid transparent;
}

.pb-nav__link:hover {
  color: var(--pb-color-text);
}

.pb-nav__link.is-active {
  color: var(--pb-color-text);
  border-bottom-color: var(--pb-color-text);
}

.pb-nav__icon {
  width: 16px;
  height: 16px;
  color: currentColor;
}

/* Buttons */
.pb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--pb-radius-pill);
  border: 1px solid transparent;
  font-size: var(--pb-text-sm);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  color: var(--pb-color-text);
  transition: background-color 0.16s ease, color 0.16s ease;
}

.pb-btn:focus-visible {
  outline: 2px solid var(--pb-color-primary);
  outline-offset: 2px;
}

.pb-btn--primary {
  background: var(--pb-color-primary);
  border-color: #23322f;
  color: var(--pb-color-primary-contrast);
}

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

.pb-btn--secondary {
  background: var(--pb-color-surface);
  border-color: var(--pb-color-line);
  color: #3a342d;
}

.pb-btn--secondary:hover {
  background: #f2ede6;
}

.pb-btn--ghost {
  background: transparent;
  color: var(--pb-color-text-muted);
}

.pb-btn--ghost:hover {
  color: var(--pb-color-text);
}

/* Inputs */
.pb-field {
  display: grid;
  gap: var(--pb-space-2);
}

.pb-label {
  font-size: var(--pb-text-sm);
  font-weight: 700;
}

.pb-input,
.pb-select,
.pb-textarea {
  width: 100%;
  border: 1px solid var(--pb-color-line);
  border-radius: var(--pb-radius-md);
  background: #fff;
  color: var(--pb-color-text);
  font: inherit;
  font-size: var(--pb-text-md);
  padding: 11px 12px;
}

.pb-input:focus,
.pb-select:focus,
.pb-textarea:focus {
  outline: none;
  border-color: #bfb6aa;
}

.pb-help {
  margin: 0;
  font-size: var(--pb-text-xs);
  color: var(--pb-color-text-muted);
}

.pb-error {
  margin: 0;
  font-size: var(--pb-text-xs);
  color: #8a5a43;
}

/* Badges */
.pb-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--pb-radius-pill);
  padding: 4px 8px;
  font-size: var(--pb-text-xs);
  font-weight: 700;
}

.pb-badge--success {
  background: var(--pb-color-success-bg);
  color: var(--pb-color-success-text);
}

.pb-badge--warning {
  background: var(--pb-color-warning-bg);
  color: var(--pb-color-warning-text);
}

.pb-badge--muted {
  background: var(--pb-color-muted-bg);
  color: var(--pb-color-muted-text);
}

/* Tables */
.pb-table-wrap {
  overflow: hidden;
  border-radius: var(--pb-radius-lg);
  background: var(--pb-color-surface);
  box-shadow: var(--pb-shadow-soft);
}

.pb-table-wrap--scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pb-table {
  width: 100%;
  border-collapse: collapse;
}

.pb-table th,
.pb-table td {
  text-align: left;
  padding: 12px 14px;
}

.pb-table th {
  font-size: var(--pb-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #736a5f;
  background: #faf8f4;
}

.pb-table tbody tr:hover {
  background: #f8f4ee;
}

/* Pagination (t.ex. kvitton) */
.pb-pagination {
  margin-top: var(--pb-space-4);
}

.pb-pagination__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--pb-space-3);
}

.pb-pagination__status {
  font-size: var(--pb-text-sm);
  font-weight: 600;
  color: var(--pb-color-text-muted);
  min-width: 8rem;
  text-align: center;
}

.pb-pagination__edge {
  font-size: var(--pb-text-sm);
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--pb-radius-sm);
  border: 1px solid var(--pb-color-line);
  background: var(--pb-color-surface-muted);
  color: var(--pb-color-text-muted);
}

.pb-pagination__edge--disabled {
  opacity: 0.55;
  cursor: default;
}

/* Modal */
.pb-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--pb-space-4);
  background: rgba(34, 31, 27, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pb-modal[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.pb-modal__panel {
  width: min(560px, 100%);
  border-radius: var(--pb-radius-lg);
  background: var(--pb-color-surface);
  padding: var(--pb-space-5);
  box-shadow: var(--pb-shadow-soft);
}

/* Utilities */
.pb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pb-mt-0 { margin-top: 0; }
.pb-mt-2 { margin-top: var(--pb-space-2); }
.pb-mt-3 { margin-top: var(--pb-space-3); }
.pb-mt-4 { margin-top: var(--pb-space-4); }

.pb-mb-1 { margin-bottom: var(--pb-space-2); }
.pb-mb-2 { margin-bottom: var(--pb-space-3); }

.pb-w-full { width: 100%; }
.pb-text-right { text-align: right; }

.pb-section-lead {
  margin: 0 0 var(--pb-space-5);
  max-width: 40rem;
}

/* Anchored menu / dropdown (reusable) */
.pb-menu {
  position: relative;
  justify-self: end;
}

.pb-menu__trigger {
  gap: var(--pb-space-2);
  max-width: min(100%, 18rem);
}

.pb-menu__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.pb-menu__caret {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--pb-color-text-muted);
  transition: transform 0.15s ease;
}

.pb-menu.is-open .pb-menu__caret {
  transform: rotate(180deg);
}

.pb-menu__panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  min-width: 200px;
  padding: var(--pb-space-2);
  border-radius: var(--pb-radius-md);
  background: var(--pb-color-surface);
  border: 1px solid var(--pb-color-line);
  box-shadow: 0 10px 40px rgba(34, 31, 27, 0.12);
}

.pb-menu.is-open .pb-menu__panel {
  display: block;
}

.pb-menu__item {
  display: block;
  width: 100%;
  padding: var(--pb-space-3) var(--pb-space-3);
  border-radius: var(--pb-radius-sm);
  font-size: var(--pb-text-sm);
  font-weight: 600;
  color: var(--pb-color-text);
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

a.pb-menu__item {
  text-decoration: none;
}

.pb-menu__item:hover {
  background: var(--pb-color-surface-muted);
}

/* Two-column settings / docs layout */
.pb-layout-split {
  display: grid;
  gap: var(--pb-space-6);
  grid-template-columns: 1fr;
  align-items: start;
}

.pb-layout-split__aside {
  position: static;
}

.pb-nav-rail {
  display: grid;
  gap: var(--pb-space-1);
}

.pb-nav-rail__link {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: var(--pb-radius-sm);
  font-size: var(--pb-text-md);
  font-weight: 600;
  color: inherit;
  border: 1px solid transparent;
  text-decoration: none;
}

.pb-nav-rail__link:hover {
  background: var(--pb-color-surface-muted);
}

.pb-nav-rail__link.is-active {
  background: rgba(47, 67, 64, 0.08);
  border-color: rgba(47, 67, 64, 0.22);
  font-weight: 700;
}

.pb-nav-rail__hint {
  display: block;
  margin-top: 2px;
  font-size: var(--pb-text-xs);
  font-weight: 500;
  color: var(--pb-color-text-muted);
}

/* Centered content column */
.pb-content-shell {
  width: 100%;
  max-width: 56rem;
  margin-inline: auto;
}

.pb-content-shell--lg {
  max-width: 64rem;
}

/* Hero row that stacks & centers on large screens */
@media (min-width: 64em) {
  .pb-hero-split-lg {
    flex-direction: column;
    align-items: center;
    gap: var(--pb-space-4);
  }

  .pb-hero-split-lg > .pb-stack {
    text-align: center;
    max-width: 38rem;
  }
}

@media (min-width: 48em) {
  .pb-intro-center-md {
    text-align: center;
    max-width: 36rem;
    margin-inline: auto;
  }
}

/* Selectable card grid (plans, tiers, etc.) */
.pb-pick-grid {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(19.5rem, 26rem));
  justify-content: center;
  width: 100%;
}

.pb-pick-card {
  position: relative;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  padding: 1.5rem 1.65rem;
  min-height: 14rem;
  box-sizing: border-box;
}

.pb-pick-card.pb-stack {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pb-pick-card:hover {
  box-shadow: 0 6px 28px rgba(34, 31, 27, 0.08);
}

.pb-pick-card.is-selected {
  box-shadow: 0 0 0 2px rgba(47, 67, 64, 0.35);
}

.pb-pick-card__badge {
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.pb-pick-card.is-selected .pb-pick-card__badge {
  opacity: 1;
}

.pb-pick-card__price {
  margin-top: auto;
  padding-top: 0.85rem;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--pb-color-text-muted);
}

/* Responsive */
@media (max-width: 1000px) {
  .pb-nav {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: var(--pb-space-3);
  }

  .pb-nav__menu {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .pb-menu {
    justify-self: start;
  }

  .pb-layout-split {
    grid-template-columns: 1fr;
  }

  .pb-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pb-split {
    grid-template-columns: 1fr;
  }

  .pb-form-inline {
    align-items: stretch;
  }
}

@media (max-width: 680px) {
  .pb-container {
    width: min(1180px, calc(100% - 28px));
    margin-top: 14px;
  }

  .pb-grid--2,
  .pb-grid--3 {
    grid-template-columns: 1fr;
  }

  .pb-pick-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 52rem) {
  .pb-layout-split {
    grid-template-columns: 13.5rem minmax(0, 1fr);
    gap: var(--pb-space-7);
  }

  /* Inställningar m.m.: bredare sidonav */
  .pb-layout-split--wide-nav {
    grid-template-columns: 18.5rem minmax(0, 1fr);
  }

  .pb-layout-split__aside {
    position: sticky;
    top: var(--pb-space-4);
  }
}
