@import url("./theme.css");

/*
  Configurator-only shared header styles.
  Keeps the main site mobile header identical (white background, dark icons/logo)
  without importing the full site stylesheet into configurator apps.
*/

@supports (padding: env(safe-area-inset-bottom)) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
  }
}

:root {
  /* Match key layout tokens from main site */
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;

  --t-fast: 120ms;
  --t-med: 180ms;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Header height matches the main site responsive rules */
  --header-height: 72px;
}

@media (max-width: 1024px) {
  :root {
    --header-height: 68px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --container-padding: clamp(16px, 5vw, 24px);
  }
}

/* Default: do not alter configurator desktop UI */
.header,
.mobile-nav,
.mobile-nav-overlay {
  display: none;
}

@media (max-width: 768px) {
  /* Hide configurator-specific header on mobile so the shared header is the only one */
  .config-header {
    display: none !important;
  }

  /* Header (mobile only) */
  .header {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav); /* Above viewerDock (1000) */
    box-sizing: border-box;
    padding-top: var(--safe-top, 0px);
    height: calc(var(--header-height) + var(--safe-top, 0px));
    overflow: visible;

    /* Light-only theme surfaces */
    background: var(--card);
    background-image: none;
    color: var(--text);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: 1px solid var(--border);
  }

  .header *,
  .header *::before,
  .header *::after {
    box-sizing: border-box;
  }

  .header.is-scrolled {
    background: var(--card);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--container-padding);
  }

  /* Shared injected header structure (assets/js/main.js) */
  .header__topbar,
  .header__search,
  .header__nav {
    display: none !important;
  }

  .header__main {
    height: var(--header-height);
    display: flex;
    align-items: center;
  }

  .header__main-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--container-padding);
  }

  .header__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
  }

  .header__logo-img {
    width: var(--logo-size-mobile, 56px);
    height: var(--logo-size-mobile, 56px);
    object-fit: contain;
    border-radius: var(--radius-sm);
    display: block;
  }

  /* Configurator: never show the desktop nav row inside the header on mobile */
  .header .nav {
    display: none !important;
  }

  /* Configurator: never show the global mobile bottom navigation */
  .mobile-bottom-nav {
    display: none !important;
  }

  /* WhatsApp styles removed */

  .logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-lg);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text, var(--heading));
    text-decoration: none;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .logo::before {
    content: "";
    width: var(--logo-size-mobile, 56px);
    height: var(--logo-size-mobile, 56px);
    flex: 0 0 auto;
    background-image: var(--logo-image, url("/assets/images/logo.png"));
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border-radius: var(--radius-sm);
  }

  /* Remove visible text fallback on mobile — keep aria-label for screen readers */
  .logo > span,
  .logo__word {
    display: none !important;
  }

  .logo__word {
    display: inline-flex;
    gap: 0;
    white-space: nowrap;
  }

  .logo__slim,
  .logo__kozijn {
    display: inline-block;
  }

  /* Fallback color if text-clip isn't supported */
  .logo__kozijn {
    /* Use solid black for the text logo instead of gradient */
    color: #000000;
  }

  @supports (-webkit-background-clip: text) {
    .logo__kozijn {
      /* Ensure solid black even when text-clip is supported */
      background-image: none;
      -webkit-background-clip: initial;
      background-clip: initial;
      color: #000000;
      -webkit-text-fill-color: #000000;
    }
  }

  /* Ensure any svg logo icon is dark on mobile */
  .logo__icon svg {
    fill: var(--text, var(--heading));
  }

  .header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }

  .header__mobile-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }

  /* Configurator: hide the Configurator CTA (already inside configurator) */
  .header__actions a.btn[href^="/configurator"] {
    display: none !important;
  }

  .search-toggle,
  .cart-icon,
  .header__mobile-action {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius-sm);
    color: var(--heading);
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .search-toggle svg,
  .cart-icon svg,
  .header__mobile-action svg {
    width: 22px;
    height: 22px;
  }

  .search-toggle:active,
  .cart-icon:active {
    color: var(--link);
  }

  .search-toggle:hover,
  .search-toggle:active,
  .cart-icon:hover,
  .cart-icon:active {
    background: color-mix(in srgb, var(--heading) 6%, transparent);
  }

  .cart-icon__count {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--cta-bg);
    color: #ffffff;
    font-size: var(--text-xs);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-spring);
    pointer-events: none;
  }

  .cart-icon__count.visible {
    opacity: 1;
    transform: scale(1);
  }

  .header__cart-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--cta-bg);
    color: #ffffff;
    font-size: var(--text-xs);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
  }

  /* Buttons (used in header + mobile nav) */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 14px 28px;
    font-size: var(--text-sm);
    font-weight: 700;
    border-radius: var(--radius-pill, var(--radius));
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
    text-decoration: none;
  }

  .btn:active {
    transform: translateY(0);
  }

  .btn--primary {
    background: var(--cta-bg);
    color: var(--cta-text);
  }

  .btn--outline {
    background: transparent;
    border: 1px solid var(--btn-secondary-border);
    color: var(--btn-secondary-text);
  }

  .btn--sm {
    padding: 10px 18px;
    font-size: var(--text-sm);
  }

  .btn--full {
    width: 100%;
    justify-content: center;
  }

  .btn svg {
    width: 18px;
    height: 18px;
  }

  /* Mobile toggle (hamburger) */
  .mobile-toggle,
  .header__mobile-toggle {
    display: flex;
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background var(--t-fast);
  }

  .mobile-toggle span,
  .header__mobile-toggle span {
    display: block;
    width: 24px;
    height: 1.5px;
    background: var(--text, var(--heading));
    border-radius: 3px;
    transition: transform var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease-out);
    margin: 0;
  }

  .mobile-toggle.is-active span:nth-child(1),
  .header__mobile-toggle.is-active span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
  }

  .mobile-toggle.is-active span:nth-child(2),
  .header__mobile-toggle.is-active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .mobile-toggle.is-active span:nth-child(3),
  .header__mobile-toggle.is-active span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
  }

  /* Mobile nav overlay */
  .mobile-nav-overlay {
    display: block;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    background: color-mix(in srgb, var(--card) 78%, transparent);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    /* Keep above floating UI (chat widget, mobile bottom nav) */
    z-index: var(--z-mobile-nav);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--t-med) var(--ease-out), visibility var(--t-med);
  }

  .mobile-nav-overlay.is-visible {
    opacity: 1;
    visibility: visible;
  }

  /* Mobile nav panel */
  .mobile-nav {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 380px);
    background: var(--card);
    /* Above overlay and any floating widgets */
    z-index: var(--z-mobile-panel);
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.35s var(--ease-out);
    box-shadow: -8px 0 32px color-mix(in oklab, var(--heading) 12%, transparent);
    flex-direction: column;
    padding-top: calc(var(--space-sm) + var(--safe-top, 0px));
  }

  .mobile-nav.is-open {
    transform: translateX(0);
  }

  body.mobile-nav-open,
  html.mobile-nav-open {
    overflow: hidden;
    touch-action: none;
    position: fixed;
    width: 100%;
  }

  .mobile-nav__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    padding-top: calc(var(--space-md) + var(--safe-top, 0px));
    border-bottom: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
  }

  .mobile-nav__brand {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
  }

  .mobile-nav__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: color-mix(in srgb, var(--heading) 6%, transparent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
    transition: opacity var(--t-fast), transform var(--t-fast), color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav__close--floating {
    position: absolute;
    top: calc(var(--space-sm) + var(--safe-top, 0px));
    right: var(--space-sm);
    background: transparent;
    box-shadow: none;
  }

  .mobile-nav__scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-nav__inner {
    padding: 0 0 var(--space-sm);
    min-height: 100%;
    display: flex;
    flex-direction: column;
  }

  .mobile-nav__section {
    padding: var(--space-sm) var(--space-lg);
  }

  .mobile-nav__section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: color-mix(in srgb, var(--text-muted, #475569) 92%, transparent);
    margin-bottom: var(--space-xs);
    padding: 0 var(--space-md);
  }

  .mobile-nav__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    min-height: 56px;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text, var(--heading));
    transition: background var(--t-fast);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-decoration: none;
  }

  .mobile-nav__link:hover,
  .mobile-nav__link:active {
    background: color-mix(in srgb, var(--heading, #0b1224) 4%, transparent);
  }

  .mobile-nav__link svg {
    width: 20px;
    height: 20px;
    opacity: 0.4;
    flex-shrink: 0;
    transition: transform 0.25s var(--ease-out), opacity var(--t-fast);
    pointer-events: none;
  }

  .mobile-nav__link.is-expanded svg {
    transform: rotate(180deg);
    opacity: 0.7;
  }

  .mobile-nav__link:not([data-submenu]) {
    justify-content: flex-start;
  }

  .mobile-nav__link:not([data-submenu]) svg {
    display: none;
  }

  .mobile-nav__submenu {
    max-height: 0;
    overflow: hidden;
    background: color-mix(in srgb, var(--heading, #0b1224) 2%, transparent);
    transition: max-height 0.3s var(--ease-out);
  }

  .mobile-nav__submenu.is-open {
    max-height: 600px;
  }

  .mobile-nav__submenu a {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-lg);
    padding-left: calc(var(--space-lg) + var(--space-lg));
    min-height: 48px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted, #475569);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
  }

  .mobile-nav__submenu a:hover,
  .mobile-nav__submenu a:active {
    background: color-mix(in srgb, var(--heading, #0b1224) 4%, transparent);
    color: var(--text, var(--heading));
  }

  .mobile-nav__divider {
    height: 1px;
    background: var(--stroke, rgba(0, 0, 0, 0.08));
    margin: var(--space-sm) var(--space-lg);
  }

  /* Configurator: hide the bottom CTA area in the menu */
  .mobile-nav__cta {
    display: none !important;
  }

  .mobile-nav__contact {
    padding: var(--space-md) var(--space-lg);
    background: color-mix(in srgb, var(--heading, #0b1224) 4%, transparent);
    border-radius: var(--radius);
    margin: var(--space-sm) var(--space-lg);
  }

  .mobile-nav__contact-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    font-size: var(--text-sm);
    color: var(--text-muted, #475569);
    text-decoration: none;
  }

  .mobile-nav__contact-item svg {
    width: 18px;
    height: 18px;
    color: var(--text, var(--heading));
    flex-shrink: 0;
  }
}
