/* WD Company Editor Popups — UI skin aligned to RAC Booking Editor Popup (Tabs) - v1.3.23
 * Version: 1.0.4
 * - Blur overlay (backdrop-filter)
 * - Same modal sizing rules (desktop ~60vw, mobile ~96vw)
 * - Stable internal scrolling: grid scrolls, actions stay visible
 * - Primary accents: #00B9FF (same as booking editor tabs)
 */


:root{
  --wd-ce-vvh: 100vh;
  --wd-ce-vvoffset-top: 0px;
  --wd-ce-modal-gutter: 14px;
}

/* Overlay + blur */
.wd-ce-modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999999;
  font-family: inherit;
}
.wd-ce-modal[aria-hidden="false"]{ display: block; }

.wd-ce-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* Dialog — match booking editor sizing behavior */
.wd-ce-dialog{
  position: fixed;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  overflow: hidden;
  z-index: 1000000;

  /* Layout */
  display: flex;
  flex-direction: column;
}

/* Desktop: ~60% width, tall modal */
@media (min-width: 921px){
  .wd-ce-dialog{
    top: 6vh;
    left: 50%;
    transform: translateX(-50%);
    width: 60vw;
    height: 88vh;
  }
}

/* Mobile / small: almost full width */
@media (max-width: 920px){
  .wd-ce-dialog{
    top: 3vh;
    left: 50%;
    transform: translateX(-50%);
    width: 96vw;
    height: 94vh;
  }
}

/* Header */
.wd-ce-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e7e7e7;
  gap: 10px;
}
.wd-ce-title{
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}
.wd-ce-close{
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

/* Form layout: grid scrolls, actions stay pinned */
.wd-ce-form{
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 16px 16px;
}

.wd-ce-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 14px;

  /* key: allow internal scrolling without pushing header/actions */
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

@media (max-width: 768px){
  .wd-ce-grid{ grid-template-columns: 1fr; }
}

/* Fields */
.wd-ce-field label{
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 6px 0;
}
.wd-ce-field input,
.wd-ce-field select,
.wd-ce-field textarea{
  width: 100%;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.wd-ce-field input:focus,
.wd-ce-field select:focus,
.wd-ce-field textarea:focus{
  border-color: rgba(0,0,0,.4);
  box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}

/* Actions */
.wd-ce-actions{
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  background: #fff;
  padding: 12px 0 6px;
  border-top: 1px solid #e7e7e7;
}

/* Buttons */
.wd-ce-btn{
  appearance: none;
  border: 1px solid rgba(0,0,0,.18);
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  font-weight: 700;
}
.wd-ce-btn:hover{ border-color: rgba(0,0,0,.35); }
.wd-ce-btn:disabled{ opacity: .6; cursor: not-allowed; }

.wd-ce-btn--primary{
  border: 1px solid #00B9FF;
  background: #00B9FF;
  color: #fff;
}

/* Note & Toast (keep existing behavior) */
.wd-ce-note{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(0,0,0,.03);
  font-size: 13px;
}
.wd-ce-toast{
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 1000001;
  display: none;
  background: #111;
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.wd-ce-toast.is-on{ display: block; }

/* Mobile: keep buttons compact (similar to booking editor "tab height ~= font height") */
@media (max-width: 920px){
  .wd-ce-btn{
    padding: 10px 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}


/* Real tablet viewport fix
 * Real iPad/Android browsers can report CSS vh larger than the visible area
 * when address/tool bars are present. JS writes --wd-ce-vvh from visualViewport.
 */
.wd-ce-head,
.wd-ce-actions,
.wd-ce-note{
  flex: 0 0 auto;
}
.wd-ce-grid{
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 14px;
}
.wd-ce-actions{
  position: relative;
  z-index: 2;
}
@media (max-width: 1180px), (hover: none) and (pointer: coarse){
  html.wd-ce-viewport-ready .wd-ce-modal[aria-hidden="false"] .wd-ce-dialog{
    top: calc(var(--wd-ce-vvoffset-top, 0px) + var(--wd-ce-modal-gutter, 14px));
    height: calc(var(--wd-ce-vvh, 100vh) - (var(--wd-ce-modal-gutter, 14px) * 2));
    max-height: calc(var(--wd-ce-vvh, 100vh) - (var(--wd-ce-modal-gutter, 14px) * 2));
  }
}
@supports (height: 100dvh){
  @media (max-width: 1180px), (hover: none) and (pointer: coarse){
    .wd-ce-dialog{
      max-height: calc(100dvh - 28px);
    }
  }
}
@media (max-width: 520px){
  :root{ --wd-ce-modal-gutter: 8px; }
  .wd-ce-form{ padding-left: 12px; padding-right: 12px; padding-bottom: 10px; }
  .wd-ce-head{ padding: 12px 14px; }
  .wd-ce-actions{ padding-bottom: 4px; }
}
