/* DealAlarm stable UI layer
   Loaded last on purpose. It resolves legacy v3-v6 responsive conflicts without
   changing the application/data logic. */

:root {
  --da-header-height: 68px;
  --da-icon-size: 18px;
}

.svg-icon {
  width: var(--da-icon-size);
  height: var(--da-icon-size);
  display: inline-flex;
  flex: 0 0 var(--da-icon-size);
  align-items: center;
  justify-content: center;
  color: currentColor;
}
.svg-icon svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-only-label { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.site-header { z-index: 100; }
.header-inner { min-height: var(--da-header-height); }
.brand { gap: 10px; }
.brand-mark {
  width: 48px !important;
  height: 40px !important;
  flex: 0 0 48px !important;
  display: block !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
  background-color: transparent !important;
  background-image: url("./images/logos/deal%20alarm%20logo%20transp%20flat.png") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  box-shadow: none !important;
  color: transparent !important;
  font-size: 0 !important;
}
.brand-mark img { display: none !important; }
.brand strong { font-size: 1rem; letter-spacing: -.025em; }
.brand small { font-size: .7rem; }
.header-actions { gap: 8px; }
.header-help-link { gap: 7px; }
.language-compact { min-height: 40px; }
.profile-button { min-height: 42px; }

/* The hero used to dominate the whole first viewport. Keep it strong but useful. */
.hero.hero-v3 { padding-top: clamp(34px, 5vw, 62px); padding-bottom: 38px; }
.hero-v3 .hero-centered { max-width: 1080px; width: 100%; }
.hero h1 {
  max-width: 1040px;
  font-size: clamp(2.15rem, 5vw, 4.4rem);
  line-height: .99;
  margin-top: 12px;
  margin-bottom: 16px;
  text-wrap: balance;
}
.hero p { max-width: 780px; font-size: clamp(.96rem, 1.6vw, 1.06rem); line-height: 1.6; text-wrap: pretty; }
.smart-form { margin-top: 30px; max-width: 1040px; }
.smart-input-row { grid-template-columns: minmax(240px,1fr) 150px auto; align-items: stretch; }
.smart-input-wrap input { width: 100%; min-width: 0; }
.scope-select { min-width: 0; }
.smart-submit { white-space: nowrap; }
.smart-form-foot { align-items: center; }
.smart-message:empty { min-height: 0; margin-top: 0; }
.trust-row { margin-top: 17px; }

.system-banner { max-width: 1120px; margin-top: 14px; padding: 12px 14px; }
.system-banner strong { font-size: .9rem; }
.system-banner span { font-size: .82rem; }

.account-strip.compact-account-strip {
  margin-top: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}
.metric-grid.metric-grid-v5 { margin-top: 18px; margin-bottom: 38px; gap: 10px; }
.metric-grid-v5 .metric-card { padding: 16px; }
.metric-grid-v5 .metric-card strong { margin-top: 5px; }
.content-section { padding-top: 20px; }
.content-section + .content-section { margin-top: 40px; }
.section-header { margin-bottom: 16px; }
.section-header h2 { font-size: clamp(1.5rem, 2.5vw, 2rem); }

.button .svg-icon,
.text-button .svg-icon,
.filter-chips .svg-icon { margin-right: 1px; }
.icon-button .svg-icon { margin: 0; }
.icon-button { display: inline-grid; place-items: center; }
#refreshProducts,
#refreshWatches { width: 40px; padding: 0; }
#refreshProducts .svg-icon,
#refreshWatches .svg-icon { margin: 0; }

.mobile-nav button > span:first-child {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}
.mobile-nav .svg-icon { width: 21px; height: 21px; }

/* Critical fix: old ux-v3 switched the full UI to phone mode at 820px.
   561-820px is now a compact tablet/desktop layout, not phone mode. */
@media (min-width: 561px) and (max-width: 820px) {
  body { padding-bottom: 0 !important; }
  .site-header { position: sticky !important; top: 0; }
  .header-inner { min-height: 66px !important; }
  .brand-mark { width: 45px !important; height: 38px !important; flex-basis: 45px !important; }
  .brand small { display: block !important; }
  .language-compact span { display: inline-flex !important; }
  .profile-button-name { display: inline !important; max-width: 100px; }
  .header-help-link { width: auto !important; min-width: 0 !important; height: auto !important; padding: 0 12px !important; }
  .header-help-link > b { display: inline !important; }
  .hero-v3 { padding-top: 38px !important; }
  .hero-centered h1 { font-size: clamp(2.2rem, 6vw, 3.25rem) !important; line-height: .99 !important; }
  .smart-input-row {
    grid-template-columns: minmax(220px, 1fr) 132px auto !important;
    gap: 8px !important;
    padding: 8px !important;
  }
  .scope-select,
  .smart-submit { width: auto !important; min-height: 52px !important; }
  .smart-form-foot { flex-direction: row !important; align-items: center !important; }
  .smart-form-foot #toggleAdvanced { align-self: auto !important; }
  .advanced-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .advanced-grid.two-wide { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .day-grid { grid-template-columns: repeat(7,1fr) !important; }
  .trust-row { display: flex !important; }
  .profile-menu {
    position: fixed !important;
    top: 70px !important;
    right: 16px !important;
    left: auto !important;
    bottom: auto !important;
    width: min(340px, calc(100vw - 32px)) !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 18px !important;
    padding: 18px !important;
    box-shadow: 0 20px 60px rgba(17,24,39,.16) !important;
  }
  body.profile-open::before { display: none !important; }
  .mobile-nav { display: none !important; }
  .site-footer { display: block !important; }
}

@media (max-width: 700px) {
  .metric-grid.metric-grid-v5 { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .price-grid.price-grid-v5 { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
}

/* Phone layout starts much later than before. */
@media (max-width: 560px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
  .shell { width: min(100% - 24px, 1120px) !important; }
  .header-inner { min-height: 60px !important; gap: 8px; }
  .brand-mark { width: 43px !important; height: 34px !important; flex-basis: 43px !important; }
  .brand small,
  .language-compact > span,
  .profile-button-name { display: none !important; }
  .brand strong { font-size: .94rem; }
  .header-actions { gap: 5px !important; }
  .header-help-link { width: 38px !important; min-width: 38px !important; padding: 0 !important; }
  .header-help-link > b { display: none !important; }
  .language-compact { padding: 6px 4px !important; }
  .language-compact select { min-width: 40px !important; }
  .hero.hero-v3 { padding-top: 27px !important; padding-bottom: 30px; }
  .hero-centered h1 { font-size: clamp(2rem, 10.5vw, 2.8rem) !important; line-height: 1 !important; }
  .hero p { font-size: .94rem; line-height: 1.55; }
  .smart-form { margin-top: 24px; }
  .smart-input-row { grid-template-columns: 1fr !important; gap: 8px !important; padding: 8px !important; }
  .scope-select,
  .smart-submit { width: 100% !important; min-height: 48px !important; border-left: 0 !important; border-top: 1px solid var(--line); }
  .smart-form-foot { flex-direction: column !important; align-items: stretch !important; gap: 4px !important; }
  .smart-form-foot #toggleAdvanced { align-self: flex-end !important; min-height: 38px; }
  .advanced-panel { padding: 14px !important; }
  .advanced-grid,
  .advanced-grid.two-wide { grid-template-columns: 1fr !important; }
  .day-grid { grid-template-columns: repeat(4,1fr) !important; }
  .trust-row { display: grid !important; grid-template-columns: 1fr 1fr; gap: 7px 12px !important; justify-items: start; }
  .account-strip.compact-account-strip { padding: 12px; }
  .metric-grid.metric-grid-v5 { gap: 8px !important; }
  .metric-grid-v5 .metric-card { padding: 12px !important; }
  .section-header { align-items: center; }
  .list-toolbar { gap: 10px; }
  .profile-menu {
    top: auto !important;
    right: 0 !important;
    left: 0 !important;
    bottom: calc(66px + env(safe-area-inset-bottom)) !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
  }
  .mobile-nav {
    display: grid !important;
    grid-template-columns: repeat(4,1fr) !important;
    z-index: 95 !important;
  }
  .site-footer { display: none !important; }
}

@media (max-width: 380px) {
  .brand > span:last-child { display: none; }
  .metric-grid.metric-grid-v5 { grid-template-columns: 1fr 1fr !important; }
  .card-actions-v5 { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
