/*
 * Account Widget — Functional Styles
 * ====================================
 * Structural styles only. Colors, fonts and spacing belong in your theme CSS
 * or account-widget-theme.css.
 */

/* ── Wrapper ────────────────────────────────────────────────────────────────── */

.awe-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ── Trigger ────────────────────────────────────────────────────────────────── */

.awe-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
}

.awe-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

/* SVG size is always driven by CSS, never by width/height attributes on the
   file. !important ensures uploaded SVGs with hardcoded dimensions
   (e.g. width="800px") cannot blow out the layout. The Elementor icon size
   control overrides these via a more specific selector. */
.awe-trigger-icon svg {
    width: 22px !important;
    height: 22px !important;
    display: block;
    max-width: 100%;
    overflow: visible;
}

/* Font icon libraries (Font Awesome, Dashicons, Elementor icons etc) */
.awe-trigger-icon i,
.awe-trigger-icon [class*="fa-"],
.awe-trigger-icon [class*="eicon-"] {
    font-size: 22px;
    line-height: 1;
    display: block;
}

.awe-trigger-avatar {
    display: block;
    /* Radius controlled by Elementor "Avatar Border Radius" in Trigger style tab */
    border-radius: 50%;
    object-fit: cover;
}

/* Chevron — hidden on desktop, shown in mobile accordion mode */
.awe-accordion-chevron {
    display: none;
    align-items: center;
    margin-left: auto;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

/* ── Desktop float dropdown ─────────────────────────────────────────────────── */

.awe-dropdown {
    position: absolute;
    top: 100%;
    z-index: 9999;
    min-width: 200px;
    /* Offset from trigger — controlled by --awe-dropdown-offset custom property.
       Default 8px; overridden by Elementor "Offset from Trigger" slider. */
    margin-top: var(--awe-dropdown-offset, 8px);
    /* Hidden via [hidden] attribute */
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Invisible hover bridge fills the gap between trigger and dropdown so the
   mouse can travel from one to the other without the dropdown closing.
   Height matches --awe-dropdown-offset + a little extra for diagonal movement. */
.awe-wrapper:has([data-awe-dropdown]):not(.awe-in-mobile-menu)::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(var(--awe-dropdown-offset, 8px) + 4px);
    pointer-events: auto;
    z-index: 9998;
    /* Visible only for debugging — remove the comment below to see it:
    background: rgba(255,0,0,0.15); */
}

/* Alignment — JS applies one of these when opening */
.awe-dropdown--align-right  { right: 0; left: auto; }
.awe-dropdown--align-left   { left: 0;  right: auto; }
.awe-dropdown--align-center {
    left: 50%; right: auto;
    transform: translateX(-50%) translateY(-6px);
}
.awe-dropdown--align-center.awe-dropdown--open {
    transform: translateX(-50%) translateY(0);
}

.awe-dropdown--open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Nav menu <li> is the positioning context */
li.awe-menu-item-li {
    position: relative;
}

/* Hide the placeholder WP rendered — our widget replaces it */
li.awe-menu-item-li > a.awe-menu-placeholder {
    display: none !important;
}

/* ── Mobile accordion mode ──────────────────────────────────────────────────── */
/*
 * When JS detects our widget is inside the Elementor hamburger menu
 * (.elementor-nav-menu--dropdown), it adds .awe-in-mobile-menu to .awe-wrapper.
 *
 * Behaviour:
 *  - .awe-wrapper becomes full-width block so trigger spans the nav item width
 *  - .awe-trigger becomes full-width so it fills the row and the chevron
 *    can sit flush right (just like Elementor's own submenu arrows)
 *  - .awe-dropdown is static, full-width, no shadow/transform — it pushes
 *    subsequent nav items down, exactly like a native Elementor submenu
 *  - Chevron rotates when expanded
 */

.awe-in-mobile-menu {
    display: block;
    width: 100%;
}

.awe-in-mobile-menu .awe-trigger {
    display: flex;
    width: 100%;
    /* Elementor mobile nav items are typically padded on the nav container,
       so we don't add padding here — inherit the nav's own item spacing. */
}

/* Show the chevron in mobile mode */
.awe-in-mobile-menu .awe-accordion-chevron {
    display: inline-flex;
}

/* Rotate chevron when open */
.awe-in-mobile-menu [aria-expanded="true"] .awe-accordion-chevron {
    transform: rotate(180deg);
}

/* Accordion dropdown — static, full width, no float */
.awe-in-mobile-menu .awe-dropdown {
    position: static;
    width: 100%;
    min-width: 0;
    margin: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: none;
    box-shadow: none;
    border-radius: 0;
    /* Hidden via [hidden] — display:block when open */
}

.awe-in-mobile-menu .awe-dropdown[hidden] {
    display: none;
}

.awe-in-mobile-menu .awe-dropdown--open {
    display: block;
}

/* In mobile accordion, user-info block should be simpler — no hover shadow etc */
.awe-in-mobile-menu .awe-dropdown-item--user-info {
    pointer-events: none;
}

/* ── Dropdown items ──────────────────────────────────────────────────────────── */

.awe-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
}

.awe-dropdown-item--user-info {
    gap: 10px;
    cursor: default;
    pointer-events: none;
}

.awe-dropdown-avatar {
    /* Size controlled by Elementor "Avatar Size" — default 40px */
    width: 40px;
    height: 40px;
    /* Radius controlled by Elementor "Avatar Border Radius" — default 50% */
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.awe-dropdown-user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.awe-dropdown-user-name,
.awe-dropdown-user-email {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.awe-dropdown-item--divider {
    display: block;
    height: 0;
    margin: 4px 0;
    padding: 0;
    border: none;
    border-top: 1px solid currentColor;
    /* opacity 0.15 gives a subtle tint from item text colour by default.
       When Elementor "Divider Color" is set, opacity is reset to 1 in the selector. */
    opacity: 0.15;
    pointer-events: none;
}

.awe-dropdown-item-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.awe-dropdown-item--link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */

.awe-modal[hidden] { display: none; }

.awe-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: awe-fade-in 0.18s ease;
}

.awe-modal.awe-modal--closing {
    animation: awe-fade-out 0.18s ease forwards;
}

@keyframes awe-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes awe-fade-out { from { opacity: 1; } to { opacity: 0; } }

.awe-modal-box {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    animation: awe-slide-up 0.18s ease;
    /* Default background — overridden by Elementor "Modal Background" colour control.
       Without a base value here the modal appears transparent on most themes. */
    background-color: #ffffff;
    /* Default padding — overridden by Elementor "Padding" control in Modal style tab. */
    padding: 32px;
}

@keyframes awe-slide-up {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Editor preview — dropdown shown inline ────────────────────────────────── */
/* In the Elementor editor the dropdown is rendered open and positioned statically
   so it's visible and styleable without needing to hover/click. */

.awe-dropdown--editor-preview {
    position: static !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
    margin-top: 4px;
    display: block !important;
}

/* ── Editor preview — modal shown inline ────────────────────────────────────── */
/* In the Elementor editor the modal is rendered without position:fixed so it
   sits visibly below the trigger and can be styled like any other element. */

.awe-modal--editor-preview {
    position: relative !important;
    inset: auto !important;
    padding: 0 !important;
    animation: none !important;
    display: block !important;
    background-color: transparent !important;
    z-index: 1;
}

.awe-modal--editor-preview .awe-modal-box {
    animation: none !important;
    max-height: none !important;
}

/* Editor state separator label */
.awe-editor-state-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    padding: 8px 0 4px;
    border-top: 1px dashed #ddd;
    margin-top: 8px;
    pointer-events: none;
    user-select: none;
}

.awe-modal-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 4px;
}

.awe-modal-close {
    position: absolute;
    top: 12px; right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    color: inherit;
    transition: color 0.15s ease, background-color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

/* ── Tabs ────────────────────────────────────────────────────────────────────── */

.awe-tabs { display: flex; }

.awe-tab-btn {
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

/* Hover state — overridden by Elementor "Hover" tab controls */
.awe-tab-btn:not(.awe-tab-btn--active):hover {
    opacity: 0.8;
}

/* Keyboard focus on tab buttons */
.awe-tab-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ── Forms ───────────────────────────────────────────────────────────────────── */

.awe-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
}

/* Floating label field group
   The input comes first in the HTML, label second.
   placeholder=" " (a single space) is required — :placeholder-shown
   detects whether the field is empty. */

.awe-field-group {
    position: relative;
    /* Explicit display:block ensures consistent height calculation across browsers */
    display: block;
}

.awe-label {
    position: absolute;
    left: 12px;
    /* Use px offset from top rather than 50% — more consistent across browsers.
       20px top padding on the input means the text sits at ~14px from top,
       so we position the label at 14px to sit in the middle of the input. */
    top: 14px;
    transform: none;
    font-size: 1em;
    pointer-events: none;
    transition: top 0.18s ease, font-size 0.18s ease;
    color: inherit;
    /* Background masks the border when label floats to the edge —
       set to match modal-box background via Elementor floating label bg control */
    background: transparent;
    padding: 0 2px;
    line-height: 1;
    white-space: nowrap;
    /* Ensure label sits above the input visually */
    z-index: 1;
}

/* Floated state — when focused or has a value */
.awe-field-group:focus-within .awe-label,
.awe-input:not(:placeholder-shown) + .awe-label {
    top: -0.5em;
    font-size: 0.75em;
}

.awe-input {
    display: block;
    width: 100%;
    /* Extra top padding gives the floating label room to sit on the top edge */
    padding: 20px 12px 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: inherit;
    box-sizing: border-box;
    background: transparent;
    /* Suppress default focus ring — we handle it below */
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Subtle focus ring — replaces the harsh browser default.
   Uses box-shadow so it respects border-radius.
   Falls back to a visible semi-transparent ring if currentColor is too light. */
.awe-input:focus {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
    outline: none;
}

.awe-remember-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.awe-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.875em;
}

.awe-forgot-row {
    display: flex;
}

.awe-forgot-link {
    font-size: 0.875em;
    text-decoration: none;
    transition: color 0.15s ease;
}

.awe-submit-btn {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

.awe-submit-btn:disabled { cursor: not-allowed; opacity: 0.6; }

.awe-submit-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ── Messages ────────────────────────────────────────────────────────────────── */

.awe-message { display: block; font-size: 0.875em; min-height: 1.2em; }
.awe-message:empty { display: none; }

/* Message states — default colours; overridden by Elementor controls in Modal > Messages */
.awe-message--error   { color: #c0392b; }
.awe-message--success { color: #27ae60; }

/* ── Screen reader only — visually hidden but accessible ────────────────────── */

.awe-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Body scroll lock ────────────────────────────────────────────────────────── */

body.awe-modal-open { overflow: hidden; }
