/**
 * AIEO Checkout Layout — body-class-gated rules for the four toggles
 * exposed by AIEO_DMM_Checkout_Layout.
 *
 * Every rule is scoped to a body class so the styles do nothing on
 * unrelated pages and behave additively when several toggles are on.
 *
 * @package ai-eshop-optimizer
 * @since   5.5
 */

/* =========================================================================
   1. Hide company field entirely (.aieo-checkout-hide-company)
   ========================================================================= */

/* Block checkout — billing AND shipping forms (location='address' renders
   the company field in both forms). The wc-block-components-address-form__company
   wrapper holds the label + input as a single row. */
.aieo-checkout-hide-company .wc-block-components-address-form__company,
.aieo-checkout-hide-company [class*="-form__company"] {
    display: none !important;
}

/* Classic checkout — fallback for any shortcode-based legacy flow. */
.aieo-checkout-hide-company #billing_company_field,
.aieo-checkout-hide-company #shipping_company_field {
    display: none !important;
}

/* =========================================================================
   2. Company conditional with invoice (.aieo-checkout-company-in-invoice)
   ========================================================================= */

/* Hide by default; the JS extension reveals it when wants_invoice ticks. */
.aieo-checkout-company-in-invoice:not(.aieo-checkout-show-company)
  .wc-block-components-address-form__company,
.aieo-checkout-company-in-invoice:not(.aieo-checkout-show-company)
  [class*="-form__company"] {
    display: none !important;
}
.aieo-checkout-company-in-invoice:not(.aieo-checkout-show-company)
  #billing_company_field,
.aieo-checkout-company-in-invoice:not(.aieo-checkout-show-company)
  #shipping_company_field {
    display: none !important;
}

/* =========================================================================
   3. Hide side cart on checkout (.aieo-checkout-hide-side-cart)
   ========================================================================= */

/* Side-cart hide — covers BOTH layout modes used by the AIEO side-cart
   module:
     - Desktop: `.aieo-sc-trigger` is a fixed-position 56×56 circle on
       the right edge.
     - Mobile (≤720px): `.aieo-sc-floating-shell` becomes a full-width
       sticky bar at the bottom containing burger + search + chat +
       cart trigger. We have to hide the SHELL (not just the trigger)
       to remove the entire bar — otherwise burger/search/chat stay
       visible at the bottom even when the cart is gone, which is what
       the operator was seeing on mobile.
   Also keeps the legacy/alternative class names so older renderers
   stay covered. */
.aieo-checkout-hide-side-cart .aieo-sc-floating-shell,
.aieo-checkout-hide-side-cart .aieo-sc-trigger,
.aieo-checkout-hide-side-cart .aieo-sc-bar-burger,
.aieo-checkout-hide-side-cart .aieo-sc-bar-search,
.aieo-checkout-hide-side-cart .aieo-sc-bar-chat,
.aieo-checkout-hide-side-cart .aieo-sc-chat-desktop,
.aieo-checkout-hide-side-cart .aieo-side-cart-toggle,
.aieo-checkout-hide-side-cart [data-aieo-side-cart-trigger],
.aieo-checkout-hide-side-cart .aieo-sc-toggle,
.aieo-checkout-hide-side-cart .aieo-side-cart__toggle,
.aieo-checkout-hide-side-cart [data-aieo-sc-toggle] {
    display: none !important;
}

/* =========================================================================
   4. Distraction-free layout (.aieo-checkout-distraction-free)
   ----------------------------------------------------------------------------
   Hide the full header (nav, search, mini-cart, language switcher) and
   replace with a center-aligned logo + page title only. Footer becomes
   a tracking-only zone (we keep the copyright line + payment-method
   icons for trust signals, hide every nav link / column / newsletter).
   ========================================================================= */

/* Header — keep ONLY the logo. Operator spec.
   Strategy: hide every element inside the header that does NOT
   contain the logo in its descendants. The logo's ancestor chain is
   automatically preserved because each ancestor "contains" the
   logo and so doesn't match the hide rule. Sibling columns / nav /
   search / cart / language switcher all match (no logo descendant)
   and are hidden.
   `:has()` is supported in all current evergreen browsers — Chrome
   105+, Safari 15.4+, Firefox 121+, Edge 105+. */
.aieo-checkout-distraction-free header.wp-block-template-part {
    text-align: center !important;
    padding: 18px 16px !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #fff !important;
}

/* Hide every descendant that doesn't contain the logo. Direct
   children of the header AND nested cells / columns alike. The logo
   selector list covers BOTH WP core's site-logo block AND theme-
   specific class names (FF/roosterx-ff uses `.ff-header__logo` +
   `.ff-header__logo-link` instead of `.wp-block-site-logo`). */
.aieo-checkout-distraction-free header.wp-block-template-part *:not(:has(.wp-block-site-logo, .custom-logo-link, img.custom-logo, .ff-header__logo, .ff-header__logo-link, [class*="header__logo"], [class*="brand-logo"])):not(.wp-block-site-logo):not(.custom-logo-link):not(.custom-logo):not(img.custom-logo):not(.ff-header__logo):not(.ff-header__logo-link):not([class*="header__logo"]):not([class*="brand-logo"]) {
    display: none !important;
}

/* Centre whatever surviving wrapper holds the logo. */
.aieo-checkout-distraction-free header.wp-block-template-part :is(.wp-block-columns, .wp-block-group, .wp-block-row) {
    justify-content: center !important;
    text-align: center !important;
    flex: 0 0 auto !important;
}

/* Make the logo display nicely centered. */
.aieo-checkout-distraction-free header .wp-block-site-logo,
.aieo-checkout-distraction-free header .custom-logo-link,
.aieo-checkout-distraction-free header img.custom-logo,
.aieo-checkout-distraction-free header .ff-header__logo,
.aieo-checkout-distraction-free header .ff-header__logo-link,
.aieo-checkout-distraction-free header [class*="header__logo"] {
    display: inline-block !important;
    margin: 0 auto !important;
    text-align: center !important;
}

/* FF brand header — the black line that runs across the row is
   produced by `.ff-header__row--top::before` (full-width). The logo
   wrapper "caps" the line via its white background, but the FF theme
   only sets `padding-right` on `.ff-header__logo-link` (so on the
   normal layout the right gap is intentional but the left gap doesn't
   need one because the logo sits hard-left). When we centre the
   logo for distraction-free checkout, the asymmetry shows: line
   touches the F of FEMME on the left while a gap remains on the
   right. Mirror the right padding on the left so the line caps
   symmetrically. */
.aieo-checkout-distraction-free header .ff-header__logo-link {
    padding-left: var(--wp--preset--spacing--3) !important;
    padding-right: var(--wp--preset--spacing--3) !important;
}

/* Hide breadcrumb above the page title — same reason. */
.aieo-checkout-distraction-free .ff-breadcrumb-row,
.aieo-checkout-distraction-free .wp-block-breadcrumbs {
    display: none !important;
}

/* Page title ("Ταμείο") stays — we just centre and tighten it. */
.aieo-checkout-distraction-free main .wp-block-post-title {
    text-align: center !important;
    margin-top: 18px !important;
    margin-bottom: 18px !important;
}

/* Header announcement bar — usually carries promo copy that distracts
   on /checkout. Hide it. */
.aieo-checkout-distraction-free [class*="header-announcement"],
.aieo-checkout-distraction-free [data-aieo-announcement],
.aieo-checkout-distraction-free .wp-block-template-part[data-slug="header-announcement"] {
    display: none !important;
}

/* Footer — hide every nav / column / newsletter / copy block, keep only
   tracking scripts (which live in <head> or are noscript pixels in
   <body>, neither of which match these rules). We also keep a tiny
   copyright line for trust by NOT hiding inline text inside <small>. */
.aieo-checkout-distraction-free footer.wp-block-template-part > *:not(.aieo-checkout-keep) {
    display: none !important;
}
.aieo-checkout-distraction-free footer.wp-block-template-part {
    text-align: center !important;
    padding: 14px 16px !important;
    background: #f9fafb !important;
    color: #6b7280 !important;
    font-size: 12px !important;
    border-top: 1px solid #e5e7eb !important;
    min-height: 40px !important;
}

/* DECOUPLED — distraction-free no longer auto-hides the side cart.
   The two concerns are independent:
     - `.aieo-checkout-distraction-free` strips header nav / search /
        cart-icon-in-header / footer, leaves the floating side-cart
        trigger alone (so customers can still review their cart).
     - `.aieo-checkout-hide-side-cart` (separate toggle) hides the
        side-cart trigger specifically.
   Operator chooses each independently. */

/* =========================================================================
   5. Landing message (.aieo-checkout-landing-message)
   ----------------------------------------------------------------------------
   Styled callout above the checkout form. Default look is a soft
   accent border + light tint — non-aggressive, reads as a friendly
   note rather than an alert. Operator can fully restyle via theme CSS.
   ========================================================================= */

.aieo-checkout-landing-message {
    --aieo-clm-bg:     #fcf0f1;   /* operator can override via theme/customiser */
    --aieo-clm-border: #f46767;
    --aieo-clm-text:   #1e293b;
    --aieo-clm-link:   #f46767;

    /* Width is handled by the `alignwide` class on the wrapper — it triggers
       the theme's breakout rule (botiga: `.no-sidebar .entry-content .alignwide`
       → margin: 20px calc(25% - 15vw); width:auto), the SAME rule that sizes
       the checkout/cart rows below, so the banner lines up with them. */
    margin: 0 auto 24px;
    padding: 16px 20px;
    background: var(--aieo-clm-bg);
    /* Square border, full perimeter — operator spec. */
    border: 2px solid var(--aieo-clm-border);
    border-radius: 6px;
    color: var(--aieo-clm-text);
    font-size: 15px;
    line-height: 1.6;
}
/* Inherit alignment / formatting from the rich-editor output —
   wp_editor saves <p>, <strong>, <em>, alignments etc. */
.aieo-checkout-landing-message p { margin: 0 0 8px; }
.aieo-checkout-landing-message p:last-child { margin-bottom: 0; }
.aieo-checkout-landing-message strong { font-weight: 700; }
.aieo-checkout-landing-message em { font-style: italic; }
.aieo-checkout-landing-message a { color: var(--aieo-clm-link); text-decoration: underline; }
.aieo-checkout-landing-message .has-text-align-center { text-align: center; }
.aieo-checkout-landing-message .has-text-align-right  { text-align: right; }
.aieo-checkout-landing-message .has-text-align-left   { text-align: left; }

@media (max-width: 600px) {
    .aieo-checkout-landing-message {
        font-size: 14px;
        padding: 14px 16px;
        margin-bottom: 16px;
    }
}

/* Mobile-specific tightening — header reserved height shrinks */
@media (max-width: 600px) {
    .aieo-checkout-distraction-free header.wp-block-template-part {
        padding: 12px 12px !important;
    }
    .aieo-checkout-distraction-free header.wp-block-template-part .custom-logo,
    .aieo-checkout-distraction-free header.wp-block-template-part img.custom-logo {
        max-height: 32px !important;
        width: auto !important;
    }
}
