/* ============================================================
   Charity Donations Manager – Public Stylesheet
   Inherits the site theme's font-family, base font-size, and
   text color wherever possible; sizing is em-based so the whole
   form scales with the theme's typography instead of fighting it.
   Base accent color: #1a3a54
   ============================================================ */

.cd-wrap {
  font-family: inherit;
  color: inherit;
  /* Inherit the theme's type scale, but clamp it so the form stays
     comfortably usable even on themes with unusually small/large
     base font sizes (most themes sit between 14px–18px). */
  font-size: clamp(14px, 1em, 18px);
  width: 100%;
  max-width: 40em;         /* scales with theme type size, not a fixed px cap */
  margin: 0 auto;
  padding: 1em 0;
  box-sizing: border-box;
  --cd-primary:       #1a3a54;
  --cd-primary-dark:  #122940;
  --cd-primary-light: #235070;
  --cd-accent:        #e8a020;
  --cd-accent-dark:   #c8880a;
  --cd-success:       #28a745;
  --cd-danger:        #dc3545;
  --cd-warning:       #ffc107;
  --cd-bg:            color-mix(in srgb, currentColor 4%, transparent);
  --cd-card-bg:       Canvas;
  --cd-border:        color-mix(in srgb, currentColor 14%, transparent);
  --cd-text:          inherit;
  --cd-text-muted:    color-mix(in srgb, currentColor 55%, transparent);
  --cd-radius:        12px;
  --cd-radius-sm:     8px;
  --cd-shadow:        0 4px 24px rgba(26,58,84,.12);
  --cd-shadow-hover:  0 8px 32px rgba(26,58,84,.20);
  --cd-transition:    all .22s ease;
  --cd-font:          inherit;
}
.cd-wrap, .cd-wrap * { box-sizing: border-box; }

/* Fallbacks for browsers without color-mix() support */
@supports not (color: color-mix(in srgb, red, blue)) {
  .cd-wrap {
    --cd-bg:         rgba(0,0,0,.03);
    --cd-border:     rgba(0,0,0,.14);
    --cd-text-muted: rgba(0,0,0,.55);
  }
}

/* When the shortcode is dropped in a wide page layout (no narrow content
   column), allow it to breathe further but still cap at a readable measure */
.cd-wrap.cd-wrap-wide { max-width: 56em; }

/* ── Panel ───────────────────────────────────────────────── */
.cd-form-panel {
  background: var(--cd-card-bg);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius);
  box-shadow: var(--cd-shadow);
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────── */
.cd-header {
  background: linear-gradient(135deg, var(--cd-primary) 0%, var(--cd-primary-light) 100%);
  padding: 2em 2em 1.5em;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.cd-header::before {
  content: '';
  position: absolute;
  top: -2.5em; right: -2.5em;
  width: 10em; height: 10em;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}
.cd-header::after {
  content: '';
  position: absolute;
  bottom: -3.75em; left: -1.25em;
  width: 12.5em; height: 12.5em;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
}
.cd-header-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 4em; height: 4em;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  margin-bottom: 1em;
  position: relative; z-index: 1;
}
.cd-header-icon svg {
  width: 2em; height: 2em;
  stroke: #fff;
}
.cd-icon-upi  { background: rgba(232,160,32,.25); }
.cd-icon-bank { background: rgba(40,167,69,.25); }

.cd-title {
  font-size: 1.6em;
  font-weight: 700;
  color: #fff;
  margin: 0 0 .4em;
  position: relative; z-index: 1;
  font-family: inherit;
}
.cd-subtitle {
  color: rgba(255,255,255,.8);
  font-size: .95em;
  margin: 0;
  position: relative; z-index: 1;
}

/* ── Form body ───────────────────────────────────────────── */
.cd-form-body {
  padding: 1.75em 2em;
}

/* ── Labels & Fields ─────────────────────────────────────── */
.cd-label {
  display: block;
  font-size: .82em;
  font-weight: 600;
  color: inherit;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .45em;
  opacity: .85;
}
.cd-req { color: var(--cd-danger); }
.cd-field-group { margin-bottom: 1.25em; }
.cd-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
}
@media (max-width: 30em) { .cd-field-row { grid-template-columns: 1fr; } }

.cd-input {
  width: 100%;
  padding: .7em 1em;
  border: 1.5px solid var(--cd-border);
  border-radius: var(--cd-radius-sm);
  font-size: .95em;
  font-family: inherit;
  color: inherit;
  background: var(--cd-card-bg);
  transition: var(--cd-transition);
  box-sizing: border-box;
  outline: none;
}
.cd-input:focus {
  border-color: var(--cd-primary);
  box-shadow: 0 0 0 3px rgba(26,58,84,.1);
}
.cd-textarea { resize: vertical; min-height: 5em; }

/* ── Cause cards ─────────────────────────────────────────── */
.cd-cause-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75em;
  margin-bottom: .5em;
}
@media (max-width: 30em) { .cd-cause-cards { grid-template-columns: 1fr; } }

.cd-cause-card {
  display: flex;
  align-items: center;
  gap: .75em;
  padding: .85em 1em;
  border: 2px solid var(--cd-border);
  border-radius: var(--cd-radius-sm);
  cursor: pointer;
  transition: var(--cd-transition);
  background: var(--cd-bg);
}
.cd-cause-card:hover {
  border-color: var(--cd-primary);
  background: color-mix(in srgb, var(--cd-primary) 8%, transparent);
}
.cd-cause-card.cd-selected {
  border-color: var(--cd-primary);
  background: color-mix(in srgb, var(--cd-primary) 10%, transparent);
  box-shadow: 0 0 0 3px rgba(26,58,84,.1);
}
.cd-cause-card .cd-cause-icon svg {
  width: 1.75em; height: 1.75em;
  stroke: var(--cd-primary);
  flex-shrink: 0;
}
.cd-cause-info { min-width: 0; }
.cd-cause-name {
  display: block;
  font-weight: 600;
  font-size: .9em;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Progress bar ────────────────────────────────────────── */
.cd-progress-bar {
  width: 100%;
  height: .4em;
  background: var(--cd-border);
  border-radius: 99px;
  overflow: hidden;
  margin: .3em 0 .2em;
}
.cd-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cd-primary), var(--cd-accent));
  border-radius: 99px;
  transition: width .6s ease;
}
.cd-progress-text {
  font-size: .72em;
  color: var(--cd-text-muted);
}

/* ── Amount presets ──────────────────────────────────────── */
.cd-amount-presets {
  display: flex;
  flex-wrap: wrap;
  gap: .5em;
  margin-bottom: .75em;
}
.cd-preset-btn {
  padding: .5em 1.1em;
  border: 2px solid var(--cd-border);
  border-radius: 99px;
  font-size: .9em;
  font-weight: 600;
  cursor: pointer;
  background: var(--cd-card-bg);
  color: inherit;
  transition: var(--cd-transition);
  font-family: inherit;
}
.cd-preset-btn:hover,
.cd-preset-btn.cd-active {
  border-color: var(--cd-primary);
  background: var(--cd-primary);
  color: #fff;
}
.cd-custom-btn { color: var(--cd-text-muted); }
.cd-amount-input-wrap {
  position: relative;
}
.cd-currency-prefix {
  position: absolute;
  left: 1em; top: 50%;
  transform: translateY(-50%);
  font-weight: 700;
  color: var(--cd-primary);
  font-size: 1.05em;
  pointer-events: none;
}
.cd-amount-input { padding-left: 2.2em; font-size: 1.1em; font-weight: 600; }

/* ── Payment methods ─────────────────────────────────────── */
.cd-method-options {
  display: flex;
  flex-wrap: wrap;
  gap: .75em;
}
.cd-method-loading {
  color: var(--cd-text-muted);
  font-size: .9em;
  padding: .5em 0;
}
.cd-method-btn {
  display: flex;
  align-items: center;
  gap: .6em;
  padding: .85em 1.4em;
  border: 2px solid var(--cd-border);
  border-radius: var(--cd-radius-sm);
  cursor: pointer;
  background: var(--cd-card-bg);
  font-family: inherit;
  font-size: .95em;
  font-weight: 600;
  color: inherit;
  transition: var(--cd-transition);
  flex: 1;
  min-width: 7.5em;
}
.cd-method-btn svg {
  width: 1.4em; height: 1.4em;
  stroke: var(--cd-text-muted);
  flex-shrink: 0;
}
.cd-method-btn:hover { border-color: var(--cd-primary); background: color-mix(in srgb, var(--cd-primary) 8%, transparent); }
.cd-method-btn.cd-selected {
  border-color: var(--cd-primary);
  background: var(--cd-primary);
  color: #fff;
}
.cd-method-btn.cd-selected svg { stroke: #fff; }

/* ── Primary button ──────────────────────────────────────── */
.cd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  padding: .85em 1.75em;
  border-radius: var(--cd-radius-sm);
  font-family: inherit;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  transition: var(--cd-transition);
  border: 2px solid transparent;
  text-decoration: none;
  line-height: 1.2;
}
.cd-btn-primary {
  background: linear-gradient(135deg, var(--cd-primary), var(--cd-primary-light));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(26,58,84,.30);
}
.cd-btn-primary:hover {
  background: linear-gradient(135deg, var(--cd-primary-dark), var(--cd-primary));
  box-shadow: 0 6px 20px rgba(26,58,84,.40);
  transform: translateY(-1px);
}
.cd-btn-primary:active { transform: translateY(0); }
.cd-btn-full { width: 100%; }
.cd-btn-arrow { width: 1.1em; height: 1.1em; }
.cd-btn-upi {
  background: linear-gradient(135deg, #7b2ff7, #5a1ab8);
  color: #fff;
  border: none;
}
.cd-btn-upi:hover { opacity: .9; }
.cd-btn-outline {
  background: transparent;
  border-color: var(--cd-primary);
  color: var(--cd-primary);
}
.cd-btn-outline:hover {
  background: var(--cd-primary);
  color: #fff;
}

/* ── Secure note ─────────────────────────────────────────── */
.cd-secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  font-size: .8em;
  color: var(--cd-text-muted);
  margin: .75em 0 0;
}
.cd-secure-note svg { width: .9em; height: .9em; }

/* ── Alerts ──────────────────────────────────────────────── */
.cd-alert {
  padding: .85em 1em;
  border-radius: var(--cd-radius-sm);
  font-size: .9em;
  margin-bottom: 1em;
}
.cd-alert-error { background: #fdf2f3; border: 1px solid #f5c6cb; color: #721c24; }
.cd-alert-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }

/* ── UPI section ─────────────────────────────────────────── */
.cd-upi-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 1.25em;
}
.cd-upi-qr {
  width: 11em; height: 11em;
  border: 3px solid var(--cd-border);
  border-radius: var(--cd-radius-sm);
  padding: .5em;
  background: #fff;
}
.cd-upi-details {
  background: var(--cd-bg);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius-sm);
  padding: 1em 1.25em;
  margin-bottom: 1em;
}
.cd-upi-id-row {
  display: flex;
  align-items: center;
  gap: .75em;
  padding: .35em 0;
}
.cd-upi-id-row + .cd-upi-id-row { border-top: 1px solid var(--cd-border); }
.cd-upi-label { font-size: .82em; font-weight: 600; color: var(--cd-text-muted); min-width: 3.75em; }
.cd-upi-value { font-weight: 700; color: inherit; flex: 1; }
.cd-amount-row .cd-upi-value { color: var(--cd-primary); font-size: 1.15em; }
.cd-copy-btn {
  padding: .25em .7em;
  font-size: .78em;
  background: var(--cd-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: var(--cd-transition);
}
.cd-copy-btn:hover { background: var(--cd-primary-dark); }

/* ── Bank details card ───────────────────────────────────── */
.cd-bank-details-card {
  background: var(--cd-bg);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius-sm);
  overflow: hidden;
}
.cd-bank-details-card .cd-bank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75em 1.25em;
  font-size: .92em;
}
.cd-bank-details-card .cd-bank-row + .cd-bank-row { border-top: 1px solid var(--cd-border); }
.cd-bank-key { color: var(--cd-text-muted); font-size: .82em; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.cd-bank-val { font-weight: 700; color: inherit; }
.cd-bank-amount-row { background: color-mix(in srgb, var(--cd-primary) 8%, transparent); }
.cd-bank-amount-row .cd-bank-val { color: var(--cd-primary); font-size: 1.15em; }

/* ── Back button ─────────────────────────────────────────── */
.cd-back-btn {
  display: block;
  width: 100%;
  margin-top: .75em;
  padding: .6em;
  background: transparent;
  border: none;
  color: var(--cd-text-muted);
  font-family: inherit;
  font-size: .9em;
  cursor: pointer;
  text-align: center;
  transition: color .2s;
}
.cd-back-btn:hover { color: var(--cd-primary); }

/* ── Selected cause banner ───────────────────────────────── */
.cd-selected-cause-banner {
  display: flex;
  align-items: flex-start;
  gap: 1em;
  padding: 1em 1.25em;
  background: color-mix(in srgb, var(--cd-primary) 8%, transparent);
  border-radius: var(--cd-radius-sm);
  border-left: 4px solid var(--cd-primary);
  margin-bottom: 1.25em;
}
.cd-selected-cause-banner .cd-cause-icon svg {
  width: 2.25em; height: 2.25em;
  stroke: var(--cd-primary);
  flex-shrink: 0;
}
.cd-selected-cause-banner strong { display: block; font-size: 1em; color: inherit; }
.cd-selected-cause-banner p { margin: .25em 0 0; font-size: .85em; color: var(--cd-text-muted); }

/* ── Success panel ───────────────────────────────────────── */
.cd-success-panel { padding: 3em 2em; text-align: center; }
.cd-success-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5em;
}
.cd-success-icon svg { width: 5em; height: 5em; }
.cd-check-circle { stroke-dasharray: 157; stroke-dashoffset: 157; animation: cd-draw-circle .6s ease forwards; }
.cd-check-mark   { stroke-dasharray: 50;  stroke-dashoffset: 50;  animation: cd-draw-check .4s ease .55s forwards; }
@keyframes cd-draw-circle { to { stroke-dashoffset: 0; } }
@keyframes cd-draw-check  { to { stroke-dashoffset: 0; } }
.cd-success-panel .cd-title { color: inherit; font-size: 1.8em; }
.cd-success-panel .cd-subtitle { color: var(--cd-text-muted); max-width: 24em; margin: 0 auto 2em; }

/* ── Stats ───────────────────────────────────────────────── */
.cd-stats {
  display: flex;
  gap: 2em;
  flex-wrap: wrap;
  justify-content: center;
}
.cd-stat-item { text-align: center; }
.cd-stat-number {
  display: block;
  font-size: 2em;
  font-weight: 800;
  color: var(--cd-primary);
}
.cd-stat-label { font-size: .85em; color: var(--cd-text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Causes grid ─────────────────────────────────────────── */
.cd-causes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14em, 1fr));
  gap: 1.25em;
  width: 100%;
}
.cd-cause-tile {
  background: var(--cd-card-bg);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius);
  box-shadow: var(--cd-shadow);
  padding: 1.5em;
  transition: var(--cd-transition);
  display: flex;
  flex-direction: column;
}
.cd-cause-tile:hover {
  box-shadow: var(--cd-shadow-hover);
  transform: translateY(-3px);
}
.cd-cause-tile-icon {
  width: 3.4em; height: 3.4em;
  background: color-mix(in srgb, var(--cd-primary) 10%, transparent);
  border-radius: 12px;
  display: flex;
  align-items: center; justify-content: center;
  margin-bottom: 1em;
}
.cd-cause-tile-icon svg { width: 1.75em; height: 1.75em; stroke: var(--cd-primary); }
.cd-cause-tile-name { font-size: 1.05em; font-weight: 700; color: inherit; margin: 0 0 .5em; }
.cd-cause-tile-desc { font-size: .85em; color: var(--cd-text-muted); margin: 0 0 1em; flex: 1; line-height: 1.55; }
.cd-cause-tile-meta {
  display: flex;
  justify-content: space-between;
  font-size: .78em;
  color: var(--cd-text-muted);
  margin-top: .25em;
}
.cd-cause-donate-btn {
  margin-top: 1em;
  font-size: .9em;
  padding: .65em 1em;
}

/* ── Loading spinner ─────────────────────────────────────── */
.cd-spinner {
  display: inline-block;
  width: 1.1em; height: 1.1em;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cd-spin .7s linear infinite;
  margin-right: .5em;
}
@keyframes cd-spin { to { transform: rotate(360deg); } }

/* ── Wide-container support ──────────────────────────────── */
/* If the shortcode sits in a full-width page builder row, this lets
   the form panel itself stay a comfortable reading width while still
   centering correctly in a much wider parent. */
.cd-wrap { container-type: inline-size; }

.cd-wrap * { box-sizing: border-box; }

/* ── Mobile responsiveness ───────────────────────────────── */
@media (max-width: 640px) {
  .cd-wrap { padding: .5em 0; }

  .cd-header {
    padding: 1.25em 1.25em 1em;
  }
  .cd-header-icon {
    width: 3em; height: 3em;
    margin-bottom: .6em;
  }
  .cd-header-icon svg {
    width: 1.5em; height: 1.5em;
  }
  .cd-title {
    font-size: 1.25em;
    margin: 0 0 .25em;
  }
  .cd-subtitle {
    font-size: .85em;
  }

  .cd-form-body {
    padding: 1.25em 1.1em;
  }

  .cd-method-options {
    gap: .5em;
  }
  .cd-method-btn {
    min-width: 0;
    padding: .7em 1em;
    font-size: .88em;
  }

  .cd-amount-presets {
    gap: .4em;
  }
  .cd-preset-btn {
    padding: .45em .9em;
    font-size: .85em;
  }

  .cd-upi-qr {
    width: 9em; height: 9em;
  }

  .cd-success-panel {
    padding: 2em 1.25em;
  }
  .cd-success-panel .cd-title {
    font-size: 1.4em;
  }
  .cd-success-icon svg {
    width: 3.75em; height: 3.75em;
  }
}

@media (max-width: 380px) {
  .cd-header {
    padding: 1em 1em .85em;
  }
  .cd-header-icon {
    width: 2.6em; height: 2.6em;
  }
  .cd-header-icon svg {
    width: 1.3em; height: 1.3em;
  }
  .cd-title {
    font-size: 1.1em;
  }
  .cd-form-body {
    padding: 1em .9em;
  }
}
