/* OnePlace Reusable Component Library */

/* App Header (Top bar for main screens) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-3);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.app-header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.app-header-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  flex: none;
}
.app-header-title-wrap {
  display: flex;
  flex-direction: column;
}
.app-header-appname {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.app-header-screen {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.2;
}
.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.search-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--sand);
  border: none;
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--duration-fast), transform var(--duration-fast);
}
.search-btn:active { transform: scale(0.94); }
.search-btn svg { width: 22px; height: 22px; }
.header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--tint-mint);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 600;
  margin: var(--space-2) auto var(--space-4);
  box-shadow: 0 1px 4px rgba(14, 107, 90, 0.06);
}
.status-pill svg {
  width: 18px;
  height: 18px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: var(--space-4); }
.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
}
.card-title-sm {
  font-size: var(--text-base);
}
.card-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-1);
}

/* Grouped Section Card (Profile/Settings style) */
.grouped-card {
  background: var(--tint-blue);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: var(--space-1) 0;
  margin-top: var(--space-3);
}
[data-theme='dark'] .grouped-card {
  background: var(--surface);
  border: 1px solid var(--line);
}
.grouped-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 16px var(--space-5);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.grouped-row + .grouped-row {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}
[data-theme='dark'] .grouped-row + .grouped-row {
  border-top: 1px solid var(--line);
}
.grouped-row:active {
  background: rgba(0, 0, 0, 0.03);
}
.grouped-row .icon-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}
.grouped-row .row-title {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--ink);
}
.grouped-row .row-sub {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 2px;
}
.grouped-row .chevron {
  color: var(--muted);
  font-size: 18px;
  margin-left: auto;
}

/* Lists */
.list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 16px var(--space-5);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item:hover { background: var(--sand); }
.list-item:active { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .sub {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-1);
}

/* Icon squares & circles */
.icon-sq {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--tint-mint);
  color: var(--primary);
}
.icon-sq.blue { background: var(--tint-blue); color: var(--secondary); }
.icon-sq.amber { background: var(--tint-amber); color: var(--warning); }
.icon-sq.red { background: var(--tint-red); color: var(--danger); }
.icon-sq.green { background: var(--tint-green); color: var(--success); }

.icon-circle {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.icon-circle.primary { background: var(--primary); color: #ffffff; }
.icon-circle.blue { background: var(--secondary); color: #ffffff; }
.icon-circle.soft-blue { background: var(--tint-blue); color: var(--secondary); }
.icon-circle.soft-mint { background: var(--tint-mint); color: var(--primary); }
.icon-circle.soft-coral { background: var(--tint-red); color: var(--danger); }
.icon-circle.slate { background: #E2E8F0; color: #475569; }
.icon-circle.clay { background: #FDE8E8; color: #9B2C2C; }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 26px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.chip-amber { background: var(--tint-amber); color: var(--chip-amber-ink, #b87d1a); }
.chip-red { background: var(--tint-red); color: var(--danger); }
.chip-green { background: var(--tint-green); color: var(--success); }
.chip-mint { background: var(--tint-mint); color: var(--primary); }
.chip-blue { background: var(--tint-blue); color: var(--secondary); }
.chip-neutral { background: var(--sand); color: var(--muted); }

/* Toggle */
.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--stone);
  border: none;
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease);
  flex: none;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  transition: transform var(--duration-normal) var(--ease);
}
.toggle[aria-checked='true'] { background: var(--primary); }
.toggle[aria-checked='true']::after { transform: translateX(22px); }
.toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Segmented Control */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--tint-blue);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-top: var(--space-3);
  margin-bottom: var(--space-4);
}
[data-theme='dark'] .segmented { background: var(--sand); }
.segmented button {
  min-height: 42px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
}
.segmented button[aria-selected='true'] {
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Floating Action Button (FAB) */
.fab {
  position: fixed;
  right: max(20px, calc(50% - 240px + 20px));
  bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(14, 107, 90, 0.35);
  z-index: var(--z-sticky);
  display: grid;
  place-items: center;
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.95); }

/* Persistent Tab Bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 100%);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: var(--z-tabbar);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: color var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.active {
  color: var(--primary);
  font-weight: 700;
}
.tabbar a svg {
  width: 24px;
  height: 24px;
}
.tabbar .badge {
  position: absolute;
  top: 8px;
  right: calc(50% - 14px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Checkbox ring for reminders */
.checkbox-ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--stone);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: transparent;
  transition: all var(--duration-fast) var(--ease);
  flex: none;
}
.checkbox-ring:hover { border-color: var(--primary); }
.checkbox-ring.done {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.checkbox-ring.done svg { width: 14px; height: 14px; }

/* Empty States */
.empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--muted);
}
.empty .art {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  background: var(--tint-blue);
  display: grid;
  place-items: center;
  color: var(--secondary);
}
.empty .art-green { background: var(--tint-mint); color: var(--primary); }
.empty .art-red { background: var(--tint-red); color: var(--danger); }
.empty h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-1);
}
.empty p {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  max-width: 280px;
  margin: 0 auto;
}

/* Modal Sheet & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: end center;
  z-index: var(--z-modal);
  animation: fade var(--duration-normal) var(--ease-out);
}
.modal-sheet {
  background: var(--surface);
  width: min(480px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-sheet);
  animation: slide-up var(--duration-normal) var(--ease-out);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.toast-region {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-toast);
  display: grid;
  gap: var(--space-2);
  width: min(440px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: slide-up var(--duration-normal) var(--ease-out);
  pointer-events: auto;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Skeletons */
.skeleton {
  border-radius: var(--radius-card);
  background: linear-gradient(90deg, var(--sand) 25%, var(--stone) 50%, var(--sand) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 90px;
}
.skeleton-line {
  display: inline-block;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--sand) 25%, var(--stone) 50%, var(--sand) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Flow Navbar */
.navbar {
  display: flex;
  align-items: center;
  min-height: 56px;
  margin: 0 calc(var(--space-5) * -1);
  padding: 0 var(--space-4);
}
.navbar .back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink);
  border-radius: 50%;
  transition: background var(--duration-fast);
}
.navbar .back:hover { background: var(--sand); }
.navbar h2 {
  flex: 1;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
  margin-right: 40px;
}