/* =========================================================
   COMPONENTS — TABBED PANEL
   Shared tab navigation used by management/history panels.
   ========================================================= */

/* =========================================================
   TABBED PANEL — TAB LIST
   ========================================================= */

.panel-tabs {
  display: flex;
  flex: 0 0 auto;

  gap: var(--space-2);

  margin-top: var(--space-3);
  padding-bottom: var(--space-3);

  overflow-x: auto;
  overflow-y: hidden;

  border-bottom: 1px solid var(--color-border);

  scrollbar-width: none;
}

.panel-tabs::-webkit-scrollbar {
  display: none;
}

/* =========================================================
   TABBED PANEL — TAB BUTTON
   ========================================================= */

.panel-tab {
  flex: 0 0 auto;

  min-height: 2.35rem;

  padding: var(--space-2) var(--space-4);

  border: 0;
  border-radius: var(--radius-pill);

  background: transparent;

  color: var(--color-text-muted);

  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.1;

  white-space: nowrap;

  cursor: pointer;
}

/* =========================================================
   TABBED PANEL — ACTIVE TAB
   ========================================================= */

.panel-tab.is-active {
  background: var(--color-surface-raised);
  color: var(--color-text);
}

/* =========================================================
   TABBED PANEL — CONTENT
   ========================================================= */

.panel-content {
  flex: 1;

  min-height: 0;

  margin-top: var(--space-3);

  overflow-x: hidden;
  overflow-y: auto;

  overscroll-behavior-y: auto;
}

/* =========================================================
   ARCHIVED HISTORY — CONTENT-SPECIFIC ADJUSTMENT

   History needs a small right gutter because its content
   includes timelines and read-only detail rows.
   ========================================================= */

/* =========================================================
   COLLECTION HISTORY — PANEL CONTENT VARIANT
   ========================================================= */

.collection-history-content {
  padding-right: var(--space-2);
  padding-left: var(--space-2);
}

/* =========================================================
   ARCHIVED HISTORY — TAB DETAILS
   Compact read-only label/value presentation.
   ========================================================= */

.collection-history-tab-section {
  display: grid;
  gap: var(--space-3);
}

/* =========================================================
   COMPONENTS — READ-ONLY DETAIL LIST

   Reusable label/value presentation for historical,
   summary, and other read-only information.
   ========================================================= */

.detail-list {
  display: grid;
}

/* =========================================================
   DETAIL LIST — ROW
   ========================================================= */

.detail-row {
  display: grid;

  grid-template-columns:
    minmax(8rem, 0.65fr)
    minmax(0, 1fr);

  align-items: center;

  gap: var(--space-4);

  padding-block: var(--space-3);

  border-bottom: 1px solid var(--color-border);
}

.detail-row:last-child {
  border-bottom: 0;
}

/* =========================================================
   DETAIL LIST — LABEL
   ========================================================= */

.detail-label {
  color: var(--color-text-muted);

  font-size: var(--text-sm);
}

/* =========================================================
   DETAIL LIST — VALUE
   ========================================================= */

.detail-value {
  color: var(--color-text);

  font-size: var(--text-sm);
  font-weight: 700;

  text-align: right;

  overflow-wrap: anywhere;
}

/* =========================================================
   COMPONENTS — EMPTY STATE
   ========================================================= */

.empty-state {
  margin: 0;

  padding-block: var(--space-4);

  color: var(--color-text-muted);

  font-size: var(--text-sm);
}

/* =========================================================
   DETAIL LIST — MOBILE
   ========================================================= */

@media (max-width: 520px) {
  .detail-row {
    grid-template-columns:
      minmax(6.5rem, 0.75fr)
      minmax(0, 1fr);

    gap: var(--space-3);

    padding-block: var(--space-2);
  }
}

/* =========================================================
   COMPONENTS — TIMELINE

   Reusable chronological event presentation for inventory,
   storage, and other historical activity.
   ========================================================= */

.timeline {
  display: grid;
}

/* =========================================================
   TIMELINE — ITEM
   ========================================================= */

.timeline-item {
  display: grid;

  grid-template-columns:
    auto
    minmax(0, 1fr);

  gap: var(--space-3);

  position: relative;

  padding-bottom: var(--space-4);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

/* =========================================================
   TIMELINE — MARKER
   ========================================================= */

.timeline-marker {
  position: relative;

  width: 0.65rem;
  height: 0.65rem;

  margin-top: 0.3rem;

  border: 2px solid var(--color-accent);
  border-radius: 50%;

  background: var(--color-surface-raised);
}

.timeline-marker::after {
  content: "";

  position: absolute;

  top: calc(100% + 0.25rem);
  left: 50%;

  width: 1px;
  height: calc(100% + var(--space-4));

  background: var(--color-border);

  transform: translateX(-50%);
}

.timeline-item:last-child .timeline-marker::after {
  display: none;
}

/* =========================================================
   TIMELINE — CONTENT
   ========================================================= */

.timeline-content {
  display: grid;

  gap: 0.25rem;

  min-width: 0;
}

/* =========================================================
   TIMELINE — HEADER
   ========================================================= */

.timeline-header {
  display: flex;

  align-items: baseline;
  justify-content: space-between;

  gap: var(--space-3);
}

.timeline-header strong {
  color: var(--color-text);

  font-size: var(--text-sm);
  font-weight: 700;
}

.timeline-date {
  flex: 0 0 auto;

  color: var(--color-text-muted);

  font-size: var(--text-xs);
}

/* =========================================================
   TIMELINE — BODY
   ========================================================= */

.timeline-summary,
.timeline-note {
  margin: 0;

  color: var(--color-text-muted);

  font-size: var(--text-sm);
  line-height: 1.45;
}

.timeline-note {
  color: var(--color-text);
}

/* =========================================================
   TIMELINE — MOBILE
   ========================================================= */

@media (max-width: 520px) {
  .timeline-header {
    align-items: flex-start;
    flex-direction: column;

    gap: 0.15rem;
  }
}

/* =========================================================
   COMPONENTS — ICONS
   Shared visual treatment for inline interface glyphs.
   ========================================================= */

.ui-icon {
  flex: 0 0 auto;

  width: 1.125rem;
  height: 1.125rem;

  display: block;
}

/* =========================================================
   ICON ACTION CONTROLS

   Buttons with icons use one predictable internal layout.
   Text and icon remain vertically centered as a single unit.
   ========================================================= */

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: var(--space-2);
}

.primary-action .ui-icon,
.secondary-action .ui-icon {
  flex: 0 0 auto;

  width: 1.125rem;
  height: 1.125rem;

  display: block;

  pointer-events: none;
}

.primary-action > span,
.secondary-action > span {
  display: inline-flex;
  align-items: center;

  line-height: 1;
}

.primary-action > .action-content,
.secondary-action > .action-content {
  display: inline-flex;
  flex: 0 0 auto;
  width: auto !important;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.action-content > .ui-icon {
  display: block;
  flex: 0 0 auto;
  margin: 0;
}

/* Keep legacy and generated icon/text buttons centered even before their
   markup is migrated to action-content. Child width rules must never spread
   the glyph and label to opposite edges of a full-width mobile control. */
button:has(> .ui-icon) {
  align-items: center;
  justify-content: center;
}

button:has(> .ui-icon) > .ui-icon,
button:has(> .ui-icon) > span {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

button:has(> .ui-icon) > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* =========================================================
   COMPONENTS — VIEW TOGGLE ICONS
   Keeps Grid / Compact controls compact and aligned.
   ========================================================= */
/* =========================================================
   VIEW TOGGLE ICON ALIGNMENT
   ========================================================= */

.view-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: var(--space-2);
}

.view-toggle-button .ui-icon {
  flex: 0 0 auto;

  width: 1rem;
  height: 1rem;

  display: block;

  pointer-events: none;
}

.view-toggle-button > span {
  display: inline-flex;
  align-items: center;

  line-height: 1;
}

/* =========================================================
   MANAGEMENT TAB ICON ALIGNMENT
   ========================================================= */

.manage-tab,
.panel-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: var(--space-2);
}

.manage-tab .ui-icon,
.panel-tab .ui-icon {
  flex: 0 0 auto;

  width: 1rem;
  height: 1rem;

  display: block;

  pointer-events: none;
}

.manage-tab > span,
.panel-tab > span {
  display: inline-flex;
  align-items: center;

  line-height: 1;
}

/* =========================================================
   COLLECTION MANAGE ICON
   ========================================================= */

.collection-row-manage-arrow .ui-icon {
  width: 1rem;
  height: 1rem;

  display: block;
}

/* =========================================================
   AUTHENTICATION
   Shared presentation for Treehouse account entry pages.
   ========================================================= */

.auth-page {
  min-height: 100vh;
}

.auth-main {
  display: grid;
  place-items: center;

  min-height: calc(100vh - 3.5rem);

  padding: var(--space-6) var(--space-4);
}

.auth-card {
  width: min(100%, 30rem);

  padding: clamp(1.5rem, 5vw, 2.5rem);

  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);

  background: var(--color-surface);
}

.auth-heading {
  margin-bottom: var(--space-6);
}

.auth-heading h1 {
  margin-bottom: var(--space-2);
}

.auth-heading p:last-child {
  color: var(--color-text-muted);
}

.auth-form {
  display: grid;

  gap: var(--space-4);
}

.auth-field {
  display: grid;

  gap: var(--space-2);
}

.auth-field label {
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  min-height: var(--control-height);

  padding: var(--space-3) var(--space-4);

  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);

  background: var(--color-surface-soft);
  color: var(--color-text);

  font: inherit;

  box-sizing: border-box;
}

.auth-field input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.auth-submit {
  width: 100%;
}

.auth-status {
  min-height: 1.4em;

  margin: 0;

  color: var(--color-text-muted);
}

.auth-footer {
  margin-top: var(--space-5);

  padding-top: var(--space-4);

  border-top: 1px solid var(--color-border);

  color: var(--color-text-muted);
  text-align: center;
}

.auth-footer p {
  margin: 0;
}

/* =========================================================
   AUTH FIELD HELP
   ========================================================= */

.auth-field-help {
  margin: 0;

  color: var(--color-text-muted);

  font-size: var(--text-sm);
}
