/* My Account */
.woocommerce-account .cwf-container,
.cwf-myaccount-page .cwf-container {
  max-width: var(--cwf-container-width, 1280px);
}

.cwf-myaccount-layout {
  display: grid;
  grid-template-columns: var(--cwf-myaccount-nav-width, 260px) 1fr;
  gap: var(--cwf-section-spacing, 32px);
  align-items: start;
}

.cwf-myaccount-layout.cwf-nav-top {
  grid-template-columns: 1fr;
}

@media (max-width: 1024px) {
  .cwf-myaccount-layout {
    grid-template-columns: 1fr;
  }
}

/* Neutralize WooCommerce default My Account floats/widths inside our grid layout.
   Woo core sets .woocommerce-MyAccount-navigation{float:left;width:30%} and
   .woocommerce-MyAccount-content{float:right;width:68%} which collapses our
   260px nav column (truncated labels, wrapped "Log out"). */
.cwf-myaccount-layout .woocommerce-MyAccount-navigation {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
  min-width: 0;
}

.cwf-myaccount-layout .woocommerce-MyAccount-content {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
  min-width: 0;
}

.cwf-myaccount-nav {
  background: var(--cwf-card-bg, #fff);
  border: 1px solid var(--cwf-border, #e2e8f0);
  border-radius: var(--cwf-radius, 12px);
  padding: 12px;
  position: sticky;
  top: 24px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.cwf-myaccount-nav__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cwf-nav-top .cwf-myaccount-nav__list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

/* The dropdown toggle is retired: mobile/tablet use a fixed bottom bar.
   Kept hidden defensively (cached JS, third-party toggles). */
.cwf-myaccount-nav__toggle,
.woocommerce-MyAccount-navigation-toggle,
button[class*="MyAccount-navigation-toggle"] {
  display: none !important;
}

/* Mobile/tablet: in-flow responsive grid menu at the top.
   No dropdown, no scrolling containers, no fixed/sticky positioning.
   Desktop sidebar layout above is untouched. */
@media (max-width: 1024px) {
  .cwf-myaccount-nav {
    position: static;
    max-width: none;
    border: 1px solid var(--cwf-border, #e2e8f0);
    border-radius: var(--cwf-radius, 12px);
    background: var(--cwf-card-bg, #fff);
    box-shadow: var(--cwf-shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
    padding: 12px;
    overflow: visible;
  }

  .cwf-myaccount-nav__list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: auto;
    min-width: 0;
  }

  .cwf-myaccount-nav__item {
    min-width: 0;
  }

  .cwf-myaccount-nav__link {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 68px;
    padding: 10px 6px;
    font-size: 12px;
    line-height: 1.25;
    text-align: center;
  }

  .cwf-myaccount-nav__icon svg {
    width: 22px;
    height: 22px;
  }

  .cwf-myaccount-nav__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Standard mobile and very narrow screens: 2 columns, compact spacing. */
@media (max-width: 640px) {
  .cwf-myaccount-nav__list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 380px) {
  .cwf-myaccount-nav {
    padding: 8px;
  }

  .cwf-myaccount-nav__list {
    gap: 6px;
  }

  .cwf-myaccount-nav__link {
    min-height: 60px;
    padding: 8px 4px;
    font-size: 11px;
    gap: 4px;
  }

  .cwf-myaccount-nav__icon svg {
    width: 20px;
    height: 20px;
  }
}

.cwf-myaccount-nav__item {
  margin: 0;
}

.cwf-myaccount-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--cwf-btn-radius, 10px);
  color: var(--cwf-muted, #64748b);
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  min-width: 0;
}

.cwf-myaccount-nav__link:hover {
  background: var(--cwf-background, #f8fafc);
  color: var(--cwf-text, #0f172a);
}

.cwf-myaccount-nav__item.is-active .cwf-myaccount-nav__link,
.cwf-myaccount-nav__link:focus {
  background: var(--cwf-primary, #4f46e5);
  color: #fff;
}

.cwf-myaccount-nav__icon {
  display: flex;
  opacity: 0.8;
  flex-shrink: 0;
}

.cwf-myaccount-nav__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cwf-welcome {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
}

@media (max-width: 640px) {
  .cwf-welcome {
    grid-template-columns: 1fr;
  }
}

.cwf-welcome__title {
  font-size: var(--cwf-h2-size, 24px);
  font-weight: 800;
  margin: 0 0 8px;
}

.cwf-welcome__text {
  margin: 0 0 8px;
}

.cwf-avatar {
  border-radius: 50%;
  border: 3px solid var(--cwf-border, #e2e8f0);
}

.cwf-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

@media (max-width: 768px) {
  .cwf-stats-grid {
    grid-template-columns: 1fr;
  }
}

.cwf-stat-card {
  background: var(--cwf-card-bg, #fff);
  border: 1px solid var(--cwf-border, #e2e8f0);
  border-radius: var(--cwf-radius, 12px);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.cwf-stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--cwf-background, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cwf-primary, #4f46e5);
  flex-shrink: 0;
}

.cwf-stat-card__value {
  font-weight: 700;
  font-size: 14px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cwf-stat-card__content {
  min-width: 0;
  flex: 1 1 auto;
}

.cwf-stat-card__label {
  font-size: 12px;
  color: var(--cwf-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.cwf-orders-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cwf-quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.cwf-addresses-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .cwf-addresses-grid {
    grid-template-columns: 1fr;
  }
}

.cwf-address-card {
  border: 1px solid var(--cwf-border, #e2e8f0);
  border-radius: var(--cwf-radius, 12px);
  padding: 18px;
  background: var(--cwf-background, #f8fafc);
}

.cwf-address-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cwf-address-card__title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cwf-form .cwf-fields-grid {
  margin-bottom: 16px;
}

.cwf-fieldset {
  border: 1px solid var(--cwf-border, #e2e8f0);
  border-radius: var(--cwf-radius, 12px);
  padding: 18px;
  margin: 20px 0;
}

.cwf-fieldset legend {
  font-weight: 700;
  padding: 0 8px;
  font-size: 14px;
}

.cwf-form__actions {
  margin-top: 20px;
}

.cwf-pagination {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: space-between;
}

/* My Account content area */
.woocommerce-MyAccount-content {
  min-width: 0;
}

.woocommerce-MyAccount-content .cwf-card {
  margin-bottom: 20px;
}

/* Downloads list-view table */
.cwf-downloads-card {
  padding: 0;
  overflow: hidden;
}

.cwf-downloads-card > .cwf-card__title {
  padding: 20px 20px 0;
  margin-bottom: 12px;
}

.cwf-dl-tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cwf-dl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.cwf-dl-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cwf-muted, #64748b);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--cwf-border, #e2e8f0);
  background: var(--cwf-background, #f8fafc);
  white-space: nowrap;
}

.cwf-dl-table td {
  padding: 12px;
  border-bottom: 1px solid var(--cwf-border, #e2e8f0);
  vertical-align: middle;
}

.cwf-dl-row:last-child td {
  border-bottom: none;
}

.cwf-dl-file {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.cwf-dl-thumbwrap {
  flex-shrink: 0;
  display: flex;
}

.cwf-dl-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--cwf-border, #e2e8f0);
  display: block;
}

.cwf-dl-name {
  font-weight: 600;
  overflow-wrap: anywhere;
  min-width: 0;
}

.cwf-dl-col--action {
  text-align: right;
  white-space: nowrap;
}

.cwf-dl-col--action .cwf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Stacked rows on tablet and below: no horizontal overflow, all data kept */
@media (max-width: 900px) {
  .cwf-dl-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .cwf-dl-table,
  .cwf-dl-table tbody,
  .cwf-dl-table tr,
  .cwf-dl-table td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .cwf-dl-table tr.cwf-dl-row {
    border-bottom: 2px solid var(--cwf-border, #e2e8f0);
    padding: 6px 12px 10px;
  }

  .cwf-dl-table tr.cwf-dl-row:last-child {
    border-bottom: none;
  }

  .cwf-dl-table td {
    border: none;
    padding: 7px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }

  .cwf-dl-table td::before {
    content: attr(data-title);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cwf-muted, #64748b);
    flex-shrink: 0;
  }

  .cwf-dl-table td > *:not(.cwf-dl-file),
  .cwf-dl-table td > a {
    text-align: right;
    min-width: 0;
  }

  .cwf-dl-table .cwf-dl-file {
    justify-content: flex-end;
    text-align: right;
  }

  .cwf-dl-table .cwf-dl-col--action::before {
    display: none;
  }

  .cwf-dl-table .cwf-dl-col--action {
    text-align: left;
  }

  .cwf-dl-table .cwf-dl-col--action .cwf-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Very small screens */
@media (max-width: 420px) {
  .cwf-dl-table {
    font-size: 13px;
  }

  .cwf-dl-thumb {
    width: 36px;
    height: 36px;
  }

  .cwf-downloads-card > .cwf-card__title {
    padding: 16px 16px 0;
  }

  .cwf-dl-table tr.cwf-dl-row {
    padding-left: 8px;
    padding-right: 8px;
  }
}
