/* ============================================================================
   Account module — My-Account styles.
   Enqueued on the account page by starlab_account_assets() (after the WC module
   CSS). Markup: stock WC navigation + the theme override
   inc/woocommerce/Account/parts/edit-account.php.
   ============================================================================ */

/* ── Layout ───────────────────────────────────────────────────────────────────
   The cabinet page is a 3/9 grid (inc/woocommerce/Account/parts/page.php): the
   sidebar navigation on the left, the endpoint content (single column) on the
   right. Columns come from the theme grid (.row > .col-lg-3 / .col-lg-9). */
.account-layout__content {
  min-width: 0; /* let wide tables/inputs shrink inside the flex column */
}

/* Desktop: keep the sidebar in view while the content scrolls. The offset tracks
   the live header height (--masthead-h, published by template.js) and shrinks by
   the panel height when the masthead auto-hides on scroll-down
   (body.is-masthead-collapsed) — same mechanism as the checkout summary, with a
   matching top transition so the two move in lock-step instead of snapping. */
@media only screen and (min-width: 993px) {
  .account-layout {
    --account-nav-gap: 24px;
    --account-nav-top: calc(var(--masthead-h, 221px) + var(--account-nav-gap));
  }

  body.is-masthead-collapsed .account-layout {
    --account-nav-top: calc(var(--masthead-h, 221px) - var(--masthead-panel-h, 65px) + var(--account-nav-gap));
  }

  .account-layout__nav {
    position: sticky;
    top: var(--account-nav-top);
    align-self: flex-start;
    transition: top 0.3s;
  }
}

/* ── Navigation (sidebar menu) ────────────────────────────────────────────────
   A quiet vertical menu: muted links that tint on hover; the current endpoint
   (.is-active) gets a soft accent background, accent text and a left accent bar
   (inset box-shadow — no layout shift). Account/index.js toggles .is-active on
   click (tabs-without-reload). */
.account-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 14px 20px;

  font-weight: 500;
  color: var(--color-gray-dark);
  text-decoration: none;

  border-radius: 8px;
  transition:
    color 0.16s ease,
    background-color 0.16s ease;
}

.account-nav__icon {
  flex-shrink: 0;
  font-size: 20px;
}

.account-nav__item:hover {
  color: var(--color-black);
  background-color: var(--color-black-trans);
}

.account-nav__item.is-active {
  font-weight: 600;
  color: var(--color-accent);
  background-color: var(--color-accent-trans);
}

/* Content region while a tab is being fetched (tabs-without-reload). */
.woocommerce-MyAccount-content {
  transition: opacity 0.16s ease;
}

.woocommerce-MyAccount-content.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Edit-account (Профіль) ──────────────────────────────────────────────────
   Single column. Each logical group is a <fieldset class="account-group"> with a
   <legend> heading; each field inside is an .account-field block (<p
   class="legend"> caption + the control). Delivery group hosts the shared NP
   picker (styled by the checkout-* rules in _Common/index.css). The groups stack
   in one column inside the page's content side (col-lg-9). Each group is a card
   styled to match the checkout steps (.checkout-card): 32px padding, 1px gray
   border, 8px radius. Spacing is gap-driven all the way down: the form spaces the
   cards, each card (fieldset) spaces its rows, each row spaces label↔control — no
   margins. Flexing the fieldset also makes the legend a normal in-flow item, so
   it no longer breaks the card's top border. */
.woocommerce-EditAccountForm {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.account-group {
  display: flex;
  flex-direction: column;
  gap: 16px;

  padding: 24px 32px 32px 32px;
  border: 1px solid var(--color-gray);
  border-radius: 8px;
}

.account-group__legend {
  float: none;
  padding: 0 16px;
  font-size: 20px;
  font-weight: 600;
  color: var(--color-black);
}

@media only screen and (max-width: 768px) {
  .account-group__legend {
    font-size: 17px;
  }
}

.account-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Two fields per row inside a group (mirrors the checkout .checkout-fields grid);
   the group's flex gap separates this grid from the legend / other rows. */
.account-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media only screen and (max-width: 576px) {
  .account-fields {
    grid-template-columns: 1fr;
  }
}

.woocommerce-EditAccountForm .legend {
  font-weight: 600;
  margin-bottom: 0;
}

/* WC-JS adds a show-password toggle to password fields (form has the
   .woocommerce-EditAccountForm class); it renders a Dashicons glyph with no
   front-end font — a stray "°". Hide it. */
.woocommerce-EditAccountForm .show-password-input {
  display: none;
}

/* On the stacked (mobile) layout the nav sits above the content; add a gap. */
@media only screen and (max-width: 992px) {
  .account-layout__nav {
    margin-bottom: 24px;
  }
}

/* ── Orders (Історія замовлень) ──────────────────────────────────────────────
   Accordion order cards (markup: Account/parts/orders.php). The collapsed header
   is a full-width button; the body height is animated via max-height, and an
   inner wrapper carries the padding + divider so they are fully clipped while
   collapsed. Open/closed is Alpine's .is-open on the card. */
.account-orders {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-order {
  border: 1px solid var(--color-gray);
  border-radius: 8px;
  overflow: hidden;
}

.account-order__head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;

  padding: 20px 24px;
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.account-order__id {
  font-weight: 600;
  color: var(--color-black);
}

.account-order__date {
  font-size: 14px;
  color: var(--color-gray-dark);
}

.account-order__total {
  font-weight: 600;
  color: var(--color-black);
}

.account-order__status {
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--color-gray-dark);
  background: var(--color-black-trans);
}

.account-order__status--completed {
  color: #1f9d57;
  background: #1f9d5715;
}

.account-order__status--processing {
  color: var(--color-accent);
  background: var(--color-accent-trans);
}

.account-order__status--on-hold,
.account-order__status--pending {
  color: #a9750a;
  background: #a9750a15;
}

.account-order__status--cancelled,
.account-order__status--failed,
.account-order__status--refunded {
  color: #c0392b;
  background: #c0392b15;
}

.account-order__thumbs {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-order__thumb {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--color-gray);
  border-radius: 6px;
  background: var(--color-white);
}

.account-order__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.account-order__thumb--more {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-gray-dark);
}

.account-order__toggle {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--color-gray-dark);
  transition: transform 0.3s ease;
}

.account-order.is-open .account-order__toggle {
  transform: rotate(180deg);
}

/* Collapsing body — max-height animation; the inner wrapper owns padding/divider
   so nothing shows while collapsed. */
.account-order__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.account-order.is-open .account-order__body {
  max-height: 2000px;
}

.account-order__inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  border-top: 1px solid var(--color-gray);
}

.account-order__items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-order__item {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: 12px;
}

.account-order__item-img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--color-gray);
  border-radius: 6px;
  background: var(--color-white);
}

.account-order__item-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Single line — truncate a long name so each item stays one compact row
   (min-width:0 lets the 1fr grid cell shrink enough for the ellipsis). */
.account-order__item-name {
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-order__item-qty {
  color: var(--color-gray-dark);
}

.account-order__item-total {
  font-weight: 600;
  white-space: nowrap;
}

.account-order__meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--color-gray);
}

.account-order__meta-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 16px;
  font-size: 14px;
}

.account-order__meta-label {
  color: var(--color-gray-dark);
}

.account-order__meta-row--total {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-black);
}

.account-order__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.account-order__details-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
}

.account-order__details-link:hover {
  text-decoration: underline;
}

.account-orders-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.account-orders__pagination {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

@media only screen and (max-width: 576px) {
  .account-order__head {
    flex-wrap: wrap;
    padding: 16px;
  }

  .account-order__thumbs {
    display: none;
  }

  .account-order__toggle {
    margin-left: auto;
  }

  .account-order__inner {
    padding: 16px;
  }

  .account-order__item {
    grid-template-columns: 40px 1fr auto;
  }

  .account-order__item-qty {
    display: none;
  }
}
