/* ==========================================================================
   IMS My Account – Custom Dashboard & Navigation
   ========================================================================== */

/* ---- Override WordPress constrained layout on account page ---- */
.woocommerce-account .wp-block-post-content,
.woocommerce-account .wp-block-group > .wp-block-post-content,
.woocommerce-account .entry-content {
    max-width: 100% !important;
    margin-left: 24px !important;
    margin-right: 24px !important;
}

.woocommerce-account main .woocommerce {
    max-width: 100% !important;
}

/*
 * Collapse the extra vertical gap above the `.woocommerce` wrapper.
 *
 * The post-content WordPress renders for the My Account page looks
 * like:
 *
 *     <div.entry-content.wp-block-post-content.is-layout-constrained>
 *         <p></p>                        ← empty filter-injected <p>
 *         <div class="woocommerce">…
 *
 * Two sources of whitespace stack up between the page title and
 * the dashboard:
 *   1. The empty <p> from WooCommerce's content filter still
 *      renders its block-margin even though it has no text.
 *   2. The constrained layout applies
 *      `:where(.is-layout-constrained) > * + *` block-gap to every
 *      sibling after the first, so `.woocommerce` picks up an extra
 *      `--wp--style--block-gap` margin.
 *
 * Zero both so the heading sits right above the sidebar nav /
 * dashboard greeting, with their own internal spacing taking over.
 */
.woocommerce-account .wp-block-post-content > p:empty {
    display: none;
}

.woocommerce-account .wp-block-post-content > .woocommerce {
    margin-top: 0 !important;
}

/* ---- Layout ---- */
.ims-my-account {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ---- Sidebar Navigation ---- */
.ims-my-account__sidebar {
    padding-top: 0.25rem;
}

/*
 * Align the my-account page title with the sidebar's left edge.
 *
 * The title is a `wp:post-title` block rendered as a direct child of
 * the constrained <main> group in templates/page-my-account.html. The
 * sidebar lives inside `.entry-content`, which the override at the
 * top of this file forces to `max-width: 100%; margin: 0 24px;`, and
 * inside that `.ims-my-account` is constrained to 1400px with
 * `margin: 0 auto; padding: 0 2rem;`. To make the heading line up
 * flush with the sidebar's left edge regardless of viewport width,
 * we mirror that exact positioning chain on the title:
 *
 *   width: calc(100% - 48px)  → mimic post-content's 24px side margins
 *   max-width: 1400px         → mimic .ims-my-account's max-width
 *   margin: 0 auto            → centre at wide viewports the same way
 *   padding-left: 2rem        → mimic .ims-my-account's inner padding
 *
 * The block styling (font-size / font-weight / margin-bottom) is set
 * on the `wp:post-title` block in the template; this rule only owns
 * horizontal placement.
 */
.woocommerce-account main .wp-block-post-title {
    box-sizing: border-box;
    width: calc(100% - 48px) !important;
    max-width: 1400px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 2rem !important;
    padding-right: 2rem !important;
}

.ims-account-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ims-account-nav__item {
    margin: 0;
}

.ims-account-nav__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 0.935rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.ims-account-nav__link:hover {
    background: #f3f4f6;
    color: #111827;
}

.ims-account-nav__link.is-active,
.ims-account-nav__item.is-active > .ims-account-nav__link {
    font-weight: 700;
    color: #111827;
    background: #f3f4f6;
}

.ims-account-nav__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #6b7280;
}

.ims-account-nav__link.is-active .ims-account-nav__icon,
.ims-account-nav__item.is-active .ims-account-nav__icon {
    color: #111827;
}

/* ---- Dashboard ---- */
.ims-dashboard__greeting h2 {
    font-size: 1.65rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.ims-dashboard__subtext {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0 0 1.75rem 0;
}

.ims-dashboard__subtext a {
    color: #6b7280;
    text-decoration: underline;
}

.ims-dashboard__subtext a:hover {
    color: #111827;
}

.ims-dashboard__overview-label {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 1rem 0;
}

/* ---- Stat Cards ---- */
.ims-dashboard__stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.ims-dashboard__stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-align: center;
    background: #fff;
}

.ims-dashboard__stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

.ims-dashboard__stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #9ca3af;
    text-transform: uppercase;
}

/* ---- Recent Orders ---- */
.ims-dashboard__recent-orders {
    margin-bottom: 2rem;
}

.ims-dashboard__recent-orders h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.75rem 0;
}

.ims-dashboard__orders-list {
    display: flex;
    flex-direction: column;
}

.ims-dashboard__order-row {
    display: grid;
    grid-template-columns: 100px 1fr 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid #f3f4f6;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s ease;
}

.ims-dashboard__order-row:hover {
    background: #fafafa;
}

.ims-dashboard__order-row:last-child {
    border-bottom: none;
}

.ims-dashboard__order-number {
    font-weight: 600;
    color: #111827;
    font-size: 0.9rem;
}

.ims-dashboard__order-date {
    color: #6b7280;
    font-size: 0.88rem;
}

.ims-dashboard__order-total {
    font-weight: 600;
    color: #111827;
    font-size: 0.9rem;
}

.ims-dashboard__order-status {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.ims-dashboard__order-status--completed {
    background: #dcfce7;
    color: #166534;
}

.ims-dashboard__order-status--processing {
    background: #dbeafe;
    color: #1e40af;
}

.ims-dashboard__order-status--on-hold {
    background: #fef9c3;
    color: #854d0e;
}

.ims-dashboard__order-status--pending {
    background: #fef9c3;
    color: #854d0e;
}

.ims-dashboard__order-status--cancelled,
.ims-dashboard__order-status--refunded,
.ims-dashboard__order-status--failed {
    background: #f3f4f6;
    color: #6b7280;
}

/* ---- Quick Links ---- */
.ims-dashboard__quick-links {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 0.5rem;
}

.ims-dashboard__quick-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    color: #374151;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ims-dashboard__quick-link:hover {
    border-color: #9ca3af;
    background: #f9fafb;
    color: #111827;
}

.ims-dashboard__quick-link svg {
    flex-shrink: 0;
    color: #6b7280;
}

/* ---- General WooCommerce Account Content Overrides ---- */
.ims-my-account__content .woocommerce-MyAccount-content {
    padding: 0;
}

.ims-my-account__content .woocommerce-orders-table {
    width: 100%;
    border-collapse: collapse;
}

.ims-my-account__content .woocommerce-orders-table th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.ims-my-account__content .woocommerce-orders-table td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
    color: #374151;
}

.ims-my-account__content .woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ims-my-account__content .woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

.ims-my-account__content .woocommerce-orders-table .woocommerce-orders-table__cell-order-actions {
    vertical-align: middle;
}

.ims-my-account__content .woocommerce-address-fields .form-row,
.ims-my-account__content .woocommerce-EditAccountForm .form-row {
    margin-bottom: 1rem;
}

.ims-my-account__content .woocommerce-address-fields label,
.ims-my-account__content .woocommerce-EditAccountForm label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.25rem;
}

.ims-my-account__content .woocommerce-address-fields input[type="text"],
.ims-my-account__content .woocommerce-address-fields input[type="email"],
.ims-my-account__content .woocommerce-address-fields input[type="tel"],
.ims-my-account__content .woocommerce-address-fields select,
.ims-my-account__content .woocommerce-EditAccountForm input[type="text"],
.ims-my-account__content .woocommerce-EditAccountForm input[type="email"],
.ims-my-account__content .woocommerce-EditAccountForm input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #111827;
    transition: border-color 0.15s ease;
}

.ims-my-account__content .woocommerce-address-fields input:focus,
.ims-my-account__content .woocommerce-EditAccountForm input:focus,
.ims-my-account__content .woocommerce-address-fields select:focus {
    outline: none;
    border-color: #374151;
    box-shadow: 0 0 0 2px rgba(55, 65, 81, 0.1);
}

.ims-my-account__content button[type="submit"],
.ims-my-account__content .button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ims-my-account__content button[type="submit"]:hover,
.ims-my-account__content .button:hover {
    background: #374151;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .ims-my-account {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .ims-my-account__sidebar {
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 1rem;
    }

    .ims-account-nav__list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .ims-account-nav__link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .ims-account-nav__icon {
        display: none;
    }

    .ims-dashboard__stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .ims-dashboard__order-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .ims-dashboard__quick-links {
        grid-template-columns: repeat(2, 1fr);
    }

    .ims-dashboard__greeting h2 {
        font-size: 1.35rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .ims-my-account {
        grid-template-columns: 200px 1fr;
        gap: 2rem;
    }
}

/* ====================================================================
   Address Book
   ==================================================================== */

/* ---- List view ---- */
.ims-address-book__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ims-address-book__intro {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

.ims-address-book__add-btn {
    white-space: nowrap;
}

.ims-address-book__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.ims-address-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    transition: border-color 0.15s ease;
}

.ims-address-card:hover {
    border-color: #9ca3af;
}

.ims-address-card__label {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    margin-bottom: 0.75rem;
    background: #f3f4f6;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #374151;
    align-self: flex-start;
}

.ims-address-card__name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
    margin-bottom: 0.15rem;
}

.ims-address-card__company {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.15rem;
}

.ims-address-card__address {
    font-size: 0.85rem;
    color: #374151;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.ims-address-card__phone {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.ims-address-card__actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
}

.ims-address-card__edit,
.ims-address-card__delete {
    font-size: 0.82rem;
    font-weight: 500;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: color 0.15s ease;
}

.ims-address-card__edit {
    color: #374151;
    text-decoration: none;
}

.ims-address-card__edit:hover {
    color: #111827;
    text-decoration: underline;
}

.ims-address-card__delete {
    color: #dc2626;
}

.ims-address-card__delete:hover {
    color: #991b1b;
}

.ims-address-card__note {
    font-size: 0.82rem;
    font-style: italic;
    color: #6b7280;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px dashed #e5e7eb;
}

/* ---- Empty state ---- */
.ims-address-book__empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.ims-address-book__empty svg {
    margin-bottom: 1rem;
    color: #d1d5db;
}

.ims-address-book__empty h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 0.25rem;
}

.ims-address-book__empty p {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

/* ---- Form view ---- */
.ims-address-form__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ims-address-form__header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.ims-address-form__back {
    font-size: 0.85rem;
    color: #6b7280;
    text-decoration: none;
}

.ims-address-form__back:hover {
    color: #111827;
    text-decoration: underline;
}

.ims-address-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.ims-address-form select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #111827;
    background: #fff;
    transition: border-color 0.15s ease;
}

.ims-address-form select:focus {
    outline: none;
    border-color: #374151;
    box-shadow: 0 0 0 2px rgba(55, 65, 81, 0.1);
}

/* ---- Responsive overrides ---- */
@media (max-width: 768px) {
    .ims-address-book__grid {
        grid-template-columns: 1fr;
    }

    .ims-address-form__row {
        grid-template-columns: 1fr;
    }

    .ims-address-book__header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ====================================================================
   Quotes – List & Accordion
   ==================================================================== */

/* ---- Empty state ---- */
.ims-quotes__empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.ims-quotes__empty svg {
    margin-bottom: 1rem;
    color: #d1d5db;
}

.ims-quotes__empty h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 0.25rem;
}

.ims-quotes__empty p {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 1.25rem;
}

.ims-quotes__browse-btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    background: #111827;
    color: #fff;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease;
}

.ims-quotes__browse-btn:hover {
    background: #374151;
    color: #fff;
}

/* ---- Header ---- */
.ims-quotes__header {
    margin-bottom: 1.25rem;
}

.ims-quotes__intro {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

/* ---- Quote card / accordion trigger ---- */
.ims-quotes__list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ims-quote-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.ims-quote-card:hover {
    border-color: #d1d5db;
}

.ims-quote-card__header {
    display: grid;
    grid-template-columns: 90px 1fr 1fr auto 28px;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 0.85rem 1.1rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: inherit;
    transition: background 0.12s ease;
}

.ims-quote-card__header:hover {
    background: #fafafa;
}

.ims-quote-card__ref {
    font-weight: 600;
    color: #111827;
    font-size: 0.9rem;
}

.ims-quote-card__date {
    color: #6b7280;
    font-size: 0.88rem;
}

.ims-quote-card__items {
    color: #6b7280;
    font-size: 0.88rem;
}

.ims-quote-card__status {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.ims-quote-card__status--pending {
    background: #fef9c3;
    color: #854d0e;
}

.ims-quote-card__status--reviewed {
    background: #dbeafe;
    color: #1e40af;
}

.ims-quote-card__status--quoted {
    background: #e0e7ff;
    color: #3730a3;
}

.ims-quote-card__status--accepted,
.ims-quote-card__status--completed {
    background: #dcfce7;
    color: #166534;
}

.ims-quote-card__status--processing {
    background: #dbeafe;
    color: #1e40af;
}

.ims-quote-card__status--declined,
.ims-quote-card__status--expired {
    background: #f3f4f6;
    color: #6b7280;
}

.ims-quote-card__chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.ims-quote-card__header[aria-expanded="true"] .ims-quote-card__chevron {
    transform: rotate(180deg);
}

/* ---- Expandable panel ---- */
.ims-quote-card__panel {
    padding: 0 1.1rem 1.1rem;
    border-top: 1px solid #f3f4f6;
}

.ims-quote-card__panel[hidden] {
    display: none;
}

.ims-quote-card__table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
}

.ims-quote-card__table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid #e5e7eb;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.ims-quote-card__table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.88rem;
    color: #374151;
}

.ims-quote-card__table td a {
    color: #111827;
    text-decoration: none;
    font-weight: 500;
}

.ims-quote-card__table td a:hover {
    text-decoration: underline;
}

.ims-quote-card__col-qty {
    text-align: center;
    width: 60px;
}

.ims-quote-card__sku {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
    color: #6b7280;
}

.ims-quote-card__notes {
    margin-top: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #374151;
    line-height: 1.5;
}

.ims-quote-card__notes strong {
    margin-right: 0.35rem;
}

/* ---- Pagination ---- */
.ims-quotes__pagination {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.ims-quotes__page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ims-quotes__page-link:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.ims-quotes__page-link--active {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.ims-quotes__page-link--active:hover {
    background: #374151;
    border-color: #374151;
    color: #fff;
}

/* ---- Quotes responsive ---- */
@media (max-width: 768px) {
    .ims-quote-card__header {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem 1rem;
    }

    .ims-quote-card__chevron {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .ims-quote-card__items {
        grid-column: 1 / -1;
    }

    .ims-quote-card__table th:nth-child(2),
    .ims-quote-card__table td:nth-child(2) {
        display: none;
    }
}

/* ---- Hide default WooCommerce account nav (we override it) ---- */
.woocommerce-MyAccount-navigation {
    display: none !important;
}
