/**
 * EXIM — Account header shortcode styles
 *
 * Self-contained: every rule is prefixed `.exim-acct` so no selector
 * leaks into the rest of the site (this file runs in the <header>,
 * next to other theme widgets). Brand palette:
 *
 *   primary   #005daa  (buttons, hover accents)
 *   secondary #78D648  (avatar gradient end, menu indicator)
 *
 * Works with or without EXIM's My Account styles loaded — no shared
 * design tokens required.
 */

/* ------------------------------------------------------------------------
 * Container
 * ---------------------------------------------------------------------- */
.exim-acct {
    --acct-primary:       #005daa;
    --acct-primary-dark:  #00467f;
    --acct-primary-50:    #e6f0f7;
    --acct-secondary:     #78D648;
    --acct-text:          #1f2937;
    --acct-muted:         #6b7280;
    --acct-border:        #e5e7eb;
    --acct-card:          #ffffff;
    --acct-radius:        8px;
    --acct-shadow:        0 2px 6px rgba(0,0,0,0.06), 0 16px 28px rgba(0,0,0,0.08);

    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.2;
    color: var(--acct-text);
}

/* ------------------------------------------------------------------------
 * Logged-out state — single icon link
 *
 * Sized to match the logged-in avatar (34×34) so the header doesn't
 * reflow when the auth state changes. Circular button with a user
 * icon; hover fills it in the primary brand colour.
 * ---------------------------------------------------------------------- */
.exim-acct__icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--acct-primary);
    background: transparent;
    border: 1px solid var(--acct-primary);
    text-decoration: none !important;
    transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
    cursor: pointer;
}
.exim-acct__icon-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 1;
}
.exim-acct__icon-btn:hover,
.exim-acct__icon-btn:focus-visible {
    background: var(--acct-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,93,170,0.25);
    outline: none;
}
.exim-acct__icon-btn:active {
    transform: translateY(1px);
}

/* ------------------------------------------------------------------------
 * Logged-in state — trigger (avatar + greeting + caret)
 * ---------------------------------------------------------------------- */
.exim-acct__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.exim-acct__trigger:hover,
.exim-acct__trigger[aria-expanded="true"] {
    background: var(--acct-primary-50);
    border-color: var(--acct-primary-50);
}

.exim-acct__avatar {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    letter-spacing: 0.3px;
    background-image: linear-gradient(135deg, var(--acct-primary) 0%, var(--acct-primary-dark) 100%);
    text-transform: uppercase;
}
.exim-acct__avatar--lg {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    font-size: 14px;
}

.exim-acct__label {
    font-weight: 600;
    font-size: 13px;
    color: var(--acct-text);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exim-acct__caret {
    font-size: 14px !important;
    width: 14px !important;
    height: 14px !important;
    color: var(--acct-muted);
    line-height: 1;
    transition: transform 0.15s ease;
}
.exim-acct__trigger[aria-expanded="true"] .exim-acct__caret {
    transform: rotate(180deg);
}

/* Compact variant on logged-in: hide greeting label, keep avatar only */
.exim-acct--in.exim-acct--compact .exim-acct__label,
.exim-acct--in.exim-acct--compact .exim-acct__caret {
    display: none;
}

/* ------------------------------------------------------------------------
 * Dropdown menu
 * ---------------------------------------------------------------------- */
.exim-acct__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    background: var(--acct-card);
    border: 1px solid var(--acct-border);
    border-radius: 10px;
    box-shadow: var(--acct-shadow);
    padding: 0;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    overflow: hidden;
}
.exim-acct.is-open .exim-acct__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Menu header card — repeat the profile at the top of the dropdown so
 * the user always sees who they are currently signed in as. Rendered
 * as an <a> linking to the dashboard so the standalone "My account"
 * row can stay out of the menu list. Uses a tiny green accent bar on
 * the left to tie back to the secondary brand color, plus a chevron
 * on the right to hint at the clickable affordance. */
.exim-acct__menu-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f6f9fc 0%, #ffffff 100%);
    border-bottom: 1px solid var(--acct-border);
    position: relative;
    color: var(--acct-text);
    text-decoration: none !important;
    transition: background 0.15s ease;
}
.exim-acct__menu-head::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--acct-secondary);
}
.exim-acct__menu-head:hover {
    background: linear-gradient(135deg, #eaf1f9 0%, #f7fafd 100%);
}
.exim-acct__menu-head:hover .exim-acct__menu-head-chevron {
    color: var(--acct-primary);
    transform: translateX(2px);
}
.exim-acct__menu-head-text { min-width: 0; flex: 1; }
.exim-acct__menu-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--acct-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.exim-acct__menu-email {
    font-size: 12px;
    color: var(--acct-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.exim-acct__menu-head-chevron {
    font-size: 16px !important;
    width: 16px !important;
    height: 16px !important;
    color: var(--acct-muted);
    line-height: 1;
    flex: 0 0 16px;
    transition: color 0.15s ease, transform 0.15s ease;
}

/* Menu items list */
.exim-acct__list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}
.exim-acct__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--acct-text);
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    transition: background 0.12s ease, color 0.12s ease;
}
.exim-acct__item .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: var(--acct-muted);
    flex: 0 0 16px;
    line-height: 1;
}
.exim-acct__item-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.exim-acct__item:hover {
    background: var(--acct-primary-50);
    color: var(--acct-primary-dark);
}
.exim-acct__item:hover .dashicons {
    color: var(--acct-primary);
}

/* Red pill count badge for Order History (pending orders). Hidden
 * automatically when there are none — the PHP side only renders the
 * element when the count is > 0. */
.exim-acct__item-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 7px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    letter-spacing: 0;
    flex: 0 0 auto;
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.3);
}
.exim-acct__item:hover .exim-acct__item-badge {
    background: #dc2626;
}

/* Logout row — separator + danger-on-hover */
.exim-acct__logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--acct-muted);
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    border-top: 1px solid var(--acct-border);
    background: #fafbfc;
    transition: color 0.12s ease, background 0.12s ease;
}
.exim-acct__logout .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}
.exim-acct__logout:hover {
    color: #991b1b;
    background: #fef2f2;
}

/* ------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */
@media (max-width: 640px) {
    /* Hide greeting on tiny screens, show avatar only. */
    .exim-acct__label,
    .exim-acct__caret {
        display: none;
    }
    .exim-acct__trigger {
        padding: 2px;
    }
    /* Menu spans wider so touch targets stay comfortable. */
    .exim-acct__menu {
        right: -8px;
        min-width: 240px;
    }
    /* Logged-out: keep the icon size identical so the header layout
     * doesn't shift between states on small screens either. */
    .exim-acct__icon-btn {
        width: 36px;
        height: 36px;
    }
}
