/* ======================================================================
   DH KID Branding — v9.5 (Inline Colours + Spinners + Save State)
   ====================================================================== */

#dh-kid-branding-wrapper {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 30px;
  font-family: Montserrat, sans-serif;
  box-sizing: border-box;
}

.kid-branding-grid {
  display: grid;
  grid-template-columns: 1fr 2fr; /* 33% : 67% */
  gap: 32px;
  min-height: 80vh;
}

.branding-left,
.branding-right {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 22px;
  overflow-y: auto;
}

/* ======================================================================
   Profile Bar
   ====================================================================== */
.dh-profile-bar { 
  display:flex; 
  gap:10px; 
  margin-bottom:18px; 
  align-items:center; 
}
.dh-btn-sm { 
  padding:6px 10px; 
  border-radius:6px; 
  background:#eee; 
  cursor:pointer; 
  border:1px solid #ccc;
  font-size:13px;
}
.dh-btn-sm:hover { background:#f5f5f5; }
.dh-btn-sm.danger { background:#e8c3c3; }
.dh-btn-sm.danger:hover { background:#e2aaaa; }

/* ======================================================================
   Form Fields
   ====================================================================== */
.dh-form-group { margin-bottom:16px; }
.dh-form-group label { display:block; font-weight:600; margin-bottom:6px; }
.dh-static-value { padding:8px; background:#fafafa; border:1px solid #ddd; border-radius:6px; }

/* ======================================================================
   Inline Colour Pickers (MEDIUM)
   ====================================================================== */
.dh-branding-colours {
  display: flex;
  flex-wrap: nowrap;
  gap: 32px;
  align-items: center;
  margin: 14px 0;
}

.dh-branding-colours .colour-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.dh-branding-colours .colour-field label {
  white-space: nowrap;
  font-weight: 600;
}

.dh-branding-colours .colour-field input[type="color"] {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
}

/* ======================================================================
   Logo Editor w/ Overlay Controls
   ====================================================================== */
.logo-wrap {
  position: relative;
  display: inline-block;
  background: #fafafa;
  border: 1px dashed #ccc;
  border-radius: 8px;
  padding: 10px;
  min-width: 200px;
  min-height: 100px;
  text-align:center;
}

#branding-logo-img {
  max-width: 380px;     /* wider, more realistic display */
  height: auto;         /* preserve aspect ratio */
  max-height: none;     /* remove forced vertical squeeze */
  object-fit: contain;
  display: none;        /* remains hidden until a logo exists */
}

.logo-empty-hint {
  font-size: 12px;
  color: #777;
  padding-top: 18px;
  display:block;
}

.logo-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 6px;
}

.logo-actions .logo-action {
  border: 1px solid #cbd1d8;
  background: #fff;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}
.logo-actions .logo-action:hover { background:#f1f5f9; }

#branding-logo-file { display: none; }

/* ======================================================================
   Save Button + Saving State
   ====================================================================== */
.branding-save-row { text-align:right; margin-top:18px; }

.dh-btn-primary { 
  background:#811DD1; 
  color:#fff; 
  padding:10px 18px; 
  border-radius:6px; 
  cursor:pointer; 
  border:none; 
  transition: background .15s;
}
.dh-btn-primary:hover { background:#9b4ae5; }

.dh-btn-primary.is-saving {
  cursor: wait;
  opacity: 0.75;
  position: relative;
}

.dh-btn-primary.is-saving::after {
  content: "⏳ Saving…";
  margin-left: 8px;
  font-weight: 500;
}

/* ======================================================================
   Global Overlay Spinner (for load / profile switch / uploads)
   Call via JS: addClass('is-loading') on #dh-kid-branding-wrapper
   ====================================================================== */
#dh-kid-branding-wrapper.is-loading::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(2px);
  z-index: 9999;
}

#dh-kid-branding-wrapper.is-loading::before {
  content: "";
  position: fixed;
  top: 50%; left:50%;
  width: 48px; height:48px;
  margin-top:-24px; margin-left:-24px;
  border: 5px solid #ccc;
  border-top-color: var(--primary, #811DD1);
  border-radius: 50%;
  animation: dh-spin 0.9s linear infinite;
  z-index: 10000;
}

@keyframes dh-spin {
  to { transform: rotate(360deg); }
}

/* ======================================================================
   Preview
   ====================================================================== */
#kid-live-preview { 
  --primary:#811DD1; 
  --accent:#D11D8D; 
  color:#000; 
  font-size:14px; 
  line-height:1.45; 
}

.kid-title { text-align:center; font-size:1.4rem; margin:8px 0; color:var(--primary); }
.kid-title-divider { border:none; border-top:2px solid var(--primary); margin:12px 0; }

.kid-branding-header { display:flex; align-items:center; gap:16px; margin:10px 0 18px; }
/* Ensure logo never scales beyond desired max size */
.kid-branding-logo {
  max-width: 240px;      /* upper bound */
  height: auto;          /* preserve aspect */
  width: auto;           /* do not stretch */
  object-fit: contain;
  display: block;
  flex: 0 0 auto;        /* <-- prevents flex expansion */
}

/* Optional: keep spacing tidy */
.kid-branding-header {
  display: flex;
  align-items: flex-start; /* prevents vertical stretch */
  gap: 24px;               /* spacing between logo + text */
}
.kid-branding-trading { font-size:1.05rem; color:var(--primary); margin:0 0 2px; }
.kid-branding-company { font-size:.9rem; color:#4b5563; }
.kid-branding-contact, .kid-branding-address { font-size:.9rem; }
.accent { color: var(--accent); }

.kid-section-title { font-size:1.05rem; margin:16px 0 8px; color:var(--primary); }

table { width:100%; border-collapse:collapse; margin-bottom:18px; }
.kid-section-table th { text-align:left; width:30%; padding:6px 4px; font-weight:600; }
.kid-section-table td { padding:6px 4px; }

.kid-preview-footer { text-align:center; font-size:12px; color:#666; margin-top:26px; }

/* Responsive */
@media (max-width: 900px) {
  .kid-branding-grid { grid-template-columns:1fr; }
}

/* Fix KID preview logo scaling */
.kid-branding-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

/* This is the missing override — stops flex from stretching logo */
.kid-branding-header .kid-branding-logo {
  flex: 0 0 auto;       /* prevent auto expansion */
  max-width: 240px;     /* cap width */
  width: auto;          /* shrink to natural aspect */
  height: auto;         /* preserve ratio */
  object-fit: contain;
  display: block;
}

.branding-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 18px;
  color: #333;
}