/* ==========================================================================
   PDF Editor — Desktop-First CSS
   Design System: M3 tokens from style.css
   Minimum: 1024px wide. Not designed for mobile.
   ========================================================================== */

/* ==========================================================================
   OUTER WRAPPER
   ========================================================================== */

.pdf-editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height, 56px));
  overflow: hidden;
  background: var(--md-sys-color-surface, #F8F9FF);
}

/* ==========================================================================
   TOP BAR
   ========================================================================== */

.pdf-editor__topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
  background: #1A365D;
  color: #fff;
  flex-shrink: 0;
  border-bottom: 2px solid #D4A012;
}

.pdf-editor__topbar-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
}
.pdf-editor__topbar-back:hover { background: rgba(255,255,255,0.22); }

.pdf-editor__topbar-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-editor__topbar-badge {
  font-size: 0.62rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  background: rgba(212,160,18,0.22);
  color: #D4A012;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pdf-editor__topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pdf-editor__btn-draft {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.35);
  background: transparent;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms;
  white-space: nowrap;
}
.pdf-editor__btn-draft:hover { background: rgba(255,255,255,0.12); }

.pdf-editor__download-group {
  display: flex;
  align-items: stretch;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid #D4A012;
}

.pdf-editor__btn-download-main {
  padding: 6px 16px;
  background: #D4A012;
  color: #1A365D;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms;
  white-space: nowrap;
}
.pdf-editor__btn-download-main:hover { background: #c49010; }

.pdf-editor__btn-download-caret {
  padding: 6px 10px;
  background: #D4A012;
  color: #1A365D;
  border: none;
  border-left: 1px solid rgba(26,54,93,0.25);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 150ms;
}
.pdf-editor__btn-download-caret:hover { background: #c49010; }

/* Download dropdown */
.pdf-editor__download-dropdown {
  position: absolute;
  right: 20px;
  top: 52px;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  z-index: 200;
  overflow: hidden;
}

.pdf-editor__download-option {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 120ms;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
}
.pdf-editor__download-option:last-child { border-bottom: none; }
.pdf-editor__download-option:hover { background: var(--md-sys-color-surface-container-low, #F1F4FB); }

.pdf-editor__download-option-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1A365D;
}

.pdf-editor__download-option-desc {
  font-size: 0.72rem;
  color: var(--md-sys-color-on-surface-variant, #44464F);
  margin-top: 2px;
}

/* ==========================================================================
   TEMPLATE STRIP
   ========================================================================== */

.pdf-editor__template-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--md-sys-color-surface-container-lowest, #FFF);
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.pdf-editor__template-strip::-webkit-scrollbar { height: 3px; }
.pdf-editor__template-strip::-webkit-scrollbar-thumb { background: #C3C6D4; border-radius: 2px; }

.template-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4);
  background: transparent;
  color: var(--md-sys-color-on-surface, #1A1C1E);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 150ms;
  flex-shrink: 0;
}
.template-chip:hover {
  border-color: #1A365D;
  color: #1A365D;
  background: rgba(26,54,93,0.06);
}
.template-chip--active {
  background: #1A365D;
  border-color: #1A365D;
  color: #fff;
}
.template-chip--multi {
  border-style: dashed;
}

/* ==========================================================================
   BODY (left form + right preview)
   ========================================================================== */

.pdf-editor__body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ==========================================================================
   LEFT PANEL — Form
   ========================================================================== */

.pdf-editor__form {
  width: 480px;
  min-width: 380px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--md-sys-color-surface-container-lowest, #FFF);
  border-right: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
  padding-bottom: 16px;
  scrollbar-width: thin;
}
.pdf-editor__form::-webkit-scrollbar { width: 4px; }
.pdf-editor__form::-webkit-scrollbar-thumb { background: #C3C6D4; border-radius: 2px; }

.pdf-editor__section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
}

.pdf-editor__section:last-child {
  border-bottom: none;
}

.pdf-editor__section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #D4A012;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Form fields */
.pdf-editor__field-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.pdf-editor__field-row > .pdf-editor__field {
  flex: 1;
  min-width: 0;
}

.pdf-editor__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.pdf-editor__field:last-child { margin-bottom: 0; }

.pdf-editor__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant, #44464F);
}

.pdf-editor__input,
.pdf-editor__select {
  height: 36px;
  padding: 0 10px;
  border: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--md-sys-color-on-surface, #1A1C1E);
  background: var(--md-sys-color-surface, #F8F9FF);
  transition: border-color 150ms;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.pdf-editor__input:focus,
.pdf-editor__select:focus {
  border-color: #1A365D;
  box-shadow: 0 0 0 2px rgba(26,54,93,0.12);
}

/* ==========================================================================
   COURT CARDS
   ========================================================================== */

.pdf-editor__court-card {
  background: var(--md-sys-color-surface-container, #E8EAF6);
  border: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}

.pdf-editor__court-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pdf-editor__court-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1A365D;
}

.pdf-editor__court-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(176,0,32,0.10);
  color: #B00020;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
  flex-shrink: 0;
}
.pdf-editor__court-remove:hover { background: rgba(176,0,32,0.20); }

.pdf-editor__court-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.pdf-editor__court-grid-wide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.pdf-editor__btn-add-court {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px;
  border: 1.5px dashed var(--md-sys-color-outline-variant, #C3C6D4);
  border-radius: 8px;
  background: transparent;
  color: #1A365D;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms;
}
.pdf-editor__btn-add-court:hover {
  border-color: #1A365D;
  background: rgba(26,54,93,0.05);
}

/* Add court modal (inline dialog) */
.pdf-editor__add-court-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Ensure hidden attribute works — overrides the display:flex above */
.pdf-editor__add-court-modal[hidden] {
  display: none;
}

.pdf-editor__add-court-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.36);
}

.pdf-editor__add-court-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.pdf-editor__add-court-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1A365D;
  margin-bottom: 16px;
}

.pdf-editor__sport-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.pdf-editor__sport-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 8px;
  border: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4);
  background: transparent;
  cursor: pointer;
  transition: all 150ms;
}
.pdf-editor__sport-btn:hover {
  border-color: #1A365D;
  background: rgba(26,54,93,0.06);
}
.pdf-editor__sport-btn--active {
  border-color: #1A365D;
  background: #1A365D;
  color: #fff;
}

.pdf-editor__sport-emoji {
  font-size: 1.4rem;
  line-height: 1;
}

.pdf-editor__sport-name {
  font-size: 0.62rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: inherit;
}

.pdf-editor__add-court-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pdf-editor__btn-cancel {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant, #44464F);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms;
}
.pdf-editor__btn-cancel:hover { background: var(--md-sys-color-surface-container, #E8EAF6); }

.pdf-editor__btn-confirm {
  padding: 8px 18px;
  border-radius: 20px;
  border: none;
  background: #1A365D;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms;
}
.pdf-editor__btn-confirm:hover { background: #143050; }
.pdf-editor__btn-confirm:disabled { opacity: 0.45; cursor: default; }

/* ==========================================================================
   ADD-ON CHIPS
   ========================================================================== */

.pdf-editor__addon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-editor__addon-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4);
  background: var(--md-sys-color-surface-container-low, #F1F4FB);
  color: var(--md-sys-color-on-surface, #1A1C1E);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms;
  user-select: none;
}
.pdf-editor__addon-chip:hover {
  border-color: #4CAF50;
  background: rgba(76,175,80,0.06);
}

.pdf-editor__addon-chip--active {
  background: rgba(76,175,80,0.12);
  border-color: #4CAF50;
  color: #2E7D32;
}

.pdf-editor__addon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-sys-color-outline, #74777F);
  flex-shrink: 0;
  transition: background 150ms;
}
.pdf-editor__addon-chip--active .pdf-editor__addon-dot {
  background: #4CAF50;
}

.pdf-editor__addon-amount {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--md-sys-color-on-surface-variant, #44464F);
  transition: color 150ms;
}
.pdf-editor__addon-chip--active .pdf-editor__addon-amount {
  color: #2E7D32;
}

/* Inline amount edit input (shown when user clicks amount) */
.pdf-editor__addon-amount-input {
  width: 80px;
  height: 22px;
  padding: 0 6px;
  border: 1.5px solid #4CAF50;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: inherit;
  background: #fff;
  outline: none;
}

/* ==========================================================================
   PRICING TABLE
   ========================================================================== */

.pdf-editor__pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.pdf-editor__pricing-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
  color: var(--md-sys-color-on-surface, #1A1C1E);
}

.pdf-editor__pricing-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pdf-editor__pricing-table tr:last-child td {
  border-bottom: none;
}

.pdf-editor__pricing-subtotal td {
  font-weight: 600;
  border-top: 1.5px solid var(--md-sys-color-outline-variant, #C3C6D4) !important;
  padding-top: 8px !important;
}

.pdf-editor__pricing-total td {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1A365D;
  border-top: 2px solid #1A365D !important;
  padding-top: 8px !important;
}

.pdf-editor__pricing-total td:last-child {
  color: #D4A012;
}

/* ==========================================================================
   RIGHT PANEL — Live Preview
   ========================================================================== */

.pdf-editor__preview {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: #E8ECF4;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 20px;
  scrollbar-width: thin;
}
.pdf-editor__preview::-webkit-scrollbar { width: 4px; }
.pdf-editor__preview::-webkit-scrollbar-thumb { background: #C3C6D4; border-radius: 2px; }

/* A4 proportioned card: 210mm × 297mm ≈ 1:1.414 */
.pdf-editor__preview-card {
  width: 100%;
  max-width: 680px;
  min-height: 960px;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.14);
  border-radius: 4px;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.8rem;
  color: #222;
  position: relative;
}

/* Preview header */
.pdf-editor__pv-header {
  background: #1A365D;
  padding: 20px 28px 16px;
  color: #fff;
}

.pdf-editor__pv-accent {
  height: 3px;
  background: linear-gradient(90deg, #D4A012 0%, #F0C040 100%);
  margin-bottom: 0;
}

.pdf-editor__pv-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 6px;
}

.pdf-editor__pv-doc-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}

.pdf-editor__pv-doc-id {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
}

.pdf-editor__pv-tagline {
  font-size: 0.7rem;
  color: #D4A012;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Preview body */
.pdf-editor__pv-body {
  padding: 20px 28px;
}

.pdf-editor__pv-section {
  margin-bottom: 18px;
}

.pdf-editor__pv-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1A365D;
  border-bottom: 1.5px solid #D4A012;
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.pdf-editor__pv-client-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
  font-size: 0.78rem;
}

.pdf-editor__pv-client-label {
  font-size: 0.65rem;
  color: #74777F;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1px;
}

.pdf-editor__pv-client-value {
  font-weight: 600;
  color: #1A1C1E;
}

/* Preview courts table */
.pdf-editor__pv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.pdf-editor__pv-table th {
  background: #1A365D;
  color: #fff;
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pdf-editor__pv-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #E8EAF6;
  color: #1A1C1E;
}

.pdf-editor__pv-table tr:nth-child(even) td {
  background: #F8F9FF;
}

.pdf-editor__pv-table .amount-col {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pdf-editor__pv-total-row td {
  background: #1A365D !important;
  color: #fff !important;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 9px 10px !important;
}

.pdf-editor__pv-total-row td.amount-col {
  color: #D4A012 !important;
}

/* Preview payment terms */
.pdf-editor__pv-terms {
  font-size: 0.72rem;
  color: #44464F;
  background: #F8F9FF;
  border-left: 3px solid #D4A012;
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
}

/* Preview footer */
.pdf-editor__pv-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1A365D;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255,255,255,0.7);
  font-size: 0.65rem;
}

.pdf-editor__pv-footer-brand {
  font-weight: 700;
  color: #D4A012;
  font-size: 0.72rem;
}

/* ==========================================================================
   BOTTOM BAR
   ========================================================================== */

.pdf-editor__bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--md-sys-color-outline-variant, #C3C6D4);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.pdf-editor__bottombar-total {
  font-size: 1rem;
  font-weight: 700;
  color: #1A365D;
}

.pdf-editor__bottombar-total span {
  color: #D4A012;
  font-size: 1.05rem;
}

.pdf-editor__bottombar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pdf-editor__btn-quick {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1.5px solid #1A365D;
  background: transparent;
  color: #1A365D;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}
.pdf-editor__btn-quick:hover {
  background: rgba(26,54,93,0.07);
}

.pdf-editor__btn-full {
  padding: 8px 20px;
  border-radius: 20px;
  border: none;
  background: #1A365D;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms;
  white-space: nowrap;
}
.pdf-editor__btn-full:hover { background: #143050; }

/* ==========================================================================
   MISC STATES
   ========================================================================== */

.pdf-editor__empty-courts {
  text-align: center;
  color: var(--md-sys-color-on-surface-variant, #44464F);
  font-size: 0.82rem;
  padding: 16px 0;
}

/* Kerb info hint */
.pdf-editor__kerb-hint {
  font-size: 0.68rem;
  color: #2E7D32;
  background: rgba(76,175,80,0.08);
  border-radius: 4px;
  padding: 4px 8px;
  margin-top: 4px;
}

/* Padel/Squash package inclusions preview chip */
.pdf-editor__package-inclusions {
  font-size: 0.7rem;
  color: #1A365D;
  background: rgba(212,160,18,0.10);
  border-left: 3px solid #D4A012;
  border-radius: 4px;
  padding: 8px 10px;
  margin-top: 8px;
  line-height: 1.45;
}

/* Circle Cricket material calculation summary */
.pdf-editor__circle-summary {
  font-size: 0.7rem;
  color: #1B5E20;
  background: rgba(85,139,47,0.10);
  border-left: 3px solid #558B2F;
  border-radius: 4px;
  padding: 8px 10px;
  margin-top: 8px;
  line-height: 1.45;
}

/* Field-level validation warning (e.g. missing package_rate, missing diameter) */
.pdf-editor__field-warning {
  font-size: 0.65rem;
  color: #C62828;
  margin-top: 4px;
  line-height: 1.3;
}

.pdf-editor__input--warning {
  border-color: #EF5350 !important;
  background: rgba(239,83,80,0.04);
}

/* Sport-specific card accent (subtle) */
.pdf-editor__court-card--package {
  border-left: 3px solid #D4A012; /* GOLD brand colour for premium package */
}
.pdf-editor__court-card--circle {
  border-left: 3px solid #558B2F; /* OLIVE for cricket turf */
}

/* Loading skeleton */
.pdf-editor__skeleton {
  background: linear-gradient(90deg, #E8EAF6 25%, #D4D7E5 50%, #E8EAF6 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 4px;
  height: 14px;
  margin-bottom: 6px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   RELATIVE POSITIONING HACK for dropdown
   ========================================================================== */

.pdf-editor__topbar { position: relative; }
