/* Global CSS Variables & Theme Setup */
:root {
  --primary-color: #881b24; /* Deep Buddhist Maroon */
  --primary-hover: #6b1219;
  --accent-color: #f1a80a; /* Saffron Gold */
  --bg-color: #f7f3eb; /* Soft Warm Cream Background */
  --card-bg: #ffffff;
  --text-main: #2d2d2d;
  --text-muted: #5f6368;
  --border-color: #dadce0;
  --error-color: #d93025;
  --success-color: #1e7e34;
  --focus-ring: rgba(136, 27, 36, 0.15);
  
  /* Responsive base font size controlled by accessibility widget */
  --font-scale: 1;
  --base-font: 'Inter', sans-serif;
  --sinhala-font: 'Noto Serif Sinhala', serif;
}

/* Custom Membership Form styles */
.form-layout-container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--base-font);
  font-size: calc(15px * var(--font-scale));
  transition: font-size 0.2s ease;
}

/* Card Common Styles */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Top Banner Image Card */
.banner-container {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  background-color: var(--primary-color);
  aspect-ratio: 4 / 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Title Card Specific Styles */
.title-card {
  border-top: 10px solid var(--primary-color);
  padding: 32px 24px 24px 24px;
}

.card-border {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 10px;
  background-color: var(--primary-color);
}

.main-title {
  font-family: var(--sinhala-font);
  font-size: calc(26px * var(--font-scale));
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.3;
}

.sub-title {
  font-family: var(--sinhala-font);
  font-size: calc(16px * var(--font-scale));
  font-weight: 400;
  color: var(--text-muted);
}

/* Intro and Blessing Card */
.intro-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-left: 5px solid var(--accent-color);
}

.blessing-text {
  text-align: center;
  padding: 8px 0;
}

.pali-verse {
  font-family: var(--sinhala-font);
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
  font-style: italic;
}

.sinhala-translation {
  font-family: var(--sinhala-font);
  font-size: calc(15px * var(--font-scale));
  color: var(--text-muted);
}

.emojis {
  font-size: calc(20px * var(--font-scale));
  margin-top: 8px;
  letter-spacing: 6px;
}

.divider {
  border: 0;
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

.intro-description {
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.intro-description strong {
  color: var(--primary-color);
}

.highlight-box {
  background-color: rgba(241, 168, 10, 0.08);
  border: 1px dashed var(--accent-color);
  padding: 12px 16px;
  border-radius: 6px;
  line-height: 1.5;
  text-align: center;
}

.lotus-emoji {
  color: var(--primary-color);
  display: inline-block;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Form Question Cards */
.question-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Highlight focused card */
.question-card:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 1px 5px rgba(136, 27, 36, 0.1);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-label {
  font-family: var(--sinhala-font);
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.required-indicator {
  color: var(--error-color);
  margin-left: 3px;
  font-weight: bold;
}

.optional-label {
  font-size: 0.85em;
  font-weight: normal;
  color: var(--text-muted);
}

.question-description {
  font-size: calc(13px * var(--font-scale));
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Input Fields (Google Forms Underline Style) */
.form-control {
  width: 100%;
  font-family: var(--base-font);
  font-size: calc(15px * var(--font-scale));
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--border-color);
  background-color: transparent;
  outline: none;
  color: var(--text-main);
  transition: border-bottom-color 0.2s ease;
}

/* Expand underline on focus */
.form-control:focus {
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 7px; /* Account for thicker border to prevent layout shift */
}

/* Textarea input adjustment */
textarea.form-control {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px;
  resize: vertical;
  background-color: rgba(0, 0, 0, 0.01);
}

textarea.form-control:focus {
  border: 2px solid var(--primary-color);
  padding: 9px;
}

/* Dropdown styling */
.select-control {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

/* Date input styling */
.date-control {
  padding: 8px 4px;
  cursor: text;
}

/* Radio Fieldset styling */
.radio-fieldset {
  border: none;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
}

.radio-option input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary-color);
  cursor: pointer;
  flex-shrink: 0;
}

.radio-label {
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  color: var(--text-main);
  line-height: 1.4;
}

/* Inline text input for "Other" option */
.other-option {
  flex-wrap: wrap;
  align-items: center;
}

.inline-text-input {
  width: calc(100% - 30px);
  margin-left: 30px;
  margin-top: 4px;
  max-width: 300px;
}

.inline-text-input:disabled {
  border-bottom-color: transparent;
  background-color: transparent;
}

/* Custom File Upload Styling */
.file-upload-wrapper {
  position: relative;
  margin-top: 8px;
}

.file-input {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background-color: #ffffff;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.file-input:hover + .file-upload-btn,
.file-input:focus + .file-upload-btn {
  background-color: rgba(136, 27, 36, 0.05);
}

.file-input:focus + .file-upload-btn {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.upload-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.photo-preview-container {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: rgba(0, 0, 0, 0.01);
}

#photoPreview {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.remove-photo-btn {
  padding: 6px 12px;
  background-color: transparent;
  color: var(--error-color);
  border: 1px solid var(--error-color);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--sinhala-font);
  font-size: calc(13px * var(--font-scale));
  z-index: 3; /* Must sit above file input */
  position: relative;
  transition: background-color 0.2s ease;
}

.remove-photo-btn:hover {
  background-color: rgba(217, 48, 37, 0.05);
}

/* Bank Account & Payment Details Card */
.bank-card {
  border-left: 5px solid var(--primary-color);
  background-color: #faf8f5;
}

.bank-card-title {
  font-family: var(--sinhala-font);
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.fee-text {
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  color: var(--text-main);
  margin-bottom: 16px;
  line-height: 1.5;
}

.bank-details-box {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.bank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f3f4;
  padding-bottom: 8px;
}

.bank-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.bank-label {
  font-family: var(--sinhala-font);
  font-size: calc(13px * var(--font-scale));
  color: var(--text-muted);
}

.bank-value {
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
}

.highlight-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: monospace, sans-serif;
  font-size: calc(17px * var(--font-scale));
  color: var(--primary-color);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background-color: rgba(136, 27, 36, 0.05);
  color: var(--primary-color);
  border: 1px solid rgba(136, 27, 36, 0.15);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--sinhala-font);
  transition: background-color 0.2s ease;
}

.copy-btn:hover {
  background-color: rgba(136, 27, 36, 0.1);
}

.copy-icon {
  width: 14px;
  height: 14px;
}

.alert-box {
  background-color: rgba(217, 48, 37, 0.03);
  border: 1px solid rgba(217, 48, 37, 0.15);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.alert-item {
  font-family: var(--sinhala-font);
  font-size: calc(13px * var(--font-scale));
  color: var(--error-color);
  line-height: 1.4;
}

/* WhatsApp Box Call-to-action */
.whatsapp-join-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 8px;
}

.whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background-color: #25d366; /* Official WhatsApp Color */
  color: #ffffff;
  text-decoration: none;
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 6px rgba(37, 211, 102, 0.15);
  width: 100%;
  max-width: 420px;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.whatsapp-btn:hover {
  background-color: #20ba59;
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(37, 211, 102, 0.25);
}

.whatsapp-btn:active {
  transform: translateY(1px);
}

.whatsapp-icon {
  width: 20px;
  height: 20px;
}

.whatsapp-subtext {
  font-family: var(--sinhala-font);
  font-size: calc(12px * var(--font-scale));
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
  max-width: 380px;
}

/* Validation Error Styles */
.error-message {
  font-family: var(--sinhala-font);
  font-size: calc(12px * var(--font-scale));
  color: var(--error-color);
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 4px;
}

.error-message::before {
  content: "⚠️";
  font-size: 11px;
}

.form-control.invalid {
  border-bottom-color: var(--error-color);
}

.question-card.has-error {
  border-left: 4px solid var(--error-color);
}

/* Action Buttons Footer */
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.submit-btn {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 12px 24px;
  font-family: var(--sinhala-font);
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.submit-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.reset-btn {
  background-color: transparent;
  color: var(--primary-color);
  border: none;
  font-family: var(--sinhala-font);
  font-size: calc(14px * var(--font-scale));
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.reset-btn:hover {
  background-color: rgba(136, 27, 36, 0.05);
}

/* Loading & Success Modal Overlays */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  position: relative;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 32px 24px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.success-close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 26px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
  z-index: 10;
}

.success-close-btn:hover {
  background-color: #f1f3f4;
  color: var(--text-main);
}

.overlay.visible .overlay-content {
  transform: translateY(0);
}

/* Spinner Animation */
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(136, 27, 36, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  margin: 0 auto 16px auto;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.overlay-message {
  font-family: var(--sinhala-font);
  font-size: calc(15px * var(--font-scale));
  color: var(--text-main);
  line-height: 1.5;
}

/* Success Card Overlay Details */
.success-card {
  border-top: 10px solid var(--success-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.success-icon-wrapper {
  width: 80px;
  height: 80px;
  margin-bottom: 8px;
}

.success-lotus {
  width: 100%;
  height: 100%;
  transform-origin: bottom center;
  animation: growLotus 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes growLotus {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.success-title {
  font-family: var(--sinhala-font);
  font-size: calc(24px * var(--font-scale));
  font-weight: 700;
  color: var(--success-color);
}

.success-description {
  font-family: var(--sinhala-font);
  font-size: calc(15px * var(--font-scale));
  color: var(--text-main);
  line-height: 1.5;
}

.success-note {
  font-family: var(--sinhala-font);
  font-size: calc(13px * var(--font-scale));
  color: var(--text-muted);
  background-color: rgba(30, 126, 52, 0.03);
  border: 1px solid rgba(30, 126, 52, 0.15);
  border-radius: 6px;
  padding: 12px;
  line-height: 1.5;
  text-align: left;
}

.receipt-remind {
  color: var(--error-color);
  margin-top: 6px;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

.success-wa-btn {
  max-width: 100%;
}

.reload-btn {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px;
  font-family: var(--sinhala-font);
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.reload-btn:hover {
  background-color: #f1f3f4;
  color: var(--text-main);
}

/* Card Preview and Download Button */
.card-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin: 12px 0;
  overflow-x: auto;
  padding: 4px;
}

/* Virtual Membership ID Card styling */
.virtual-card {
  width: 100%;
  max-width: 400px;
  min-height: 220px;
  background-color: #fdfcf7;
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  margin: 0 auto;
}

.vc-header {
  background-color: var(--primary-color);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--accent-color);
}

.vc-header-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  border: 1px solid var(--accent-color);
  background-color: #ffffff;
  flex-shrink: 0;
}

.vc-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.vc-org-title {
  font-family: var(--sinhala-font);
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
}

.vc-card-subtitle {
  font-family: var(--sinhala-font);
  font-size: 8px;
  color: var(--accent-color);
  font-weight: 600;
}

.vc-body {
  padding: 14px;
  display: flex;
  gap: 14px;
  flex-grow: 1;
  align-items: center;
  background-color: #ffffff;
  background-image: radial-gradient(rgba(241, 168, 10, 0.03) 12%, transparent 80%);
}

.vc-photo-side {
  width: 85px;
  height: 95px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: #fafafa;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vc-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vc-details-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.vc-field {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.vc-label {
  font-family: var(--sinhala-font);
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
}

.vc-value {
  font-family: var(--sinhala-font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.vc-id-highlight {
  font-family: monospace, sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 1px;
}

/* Card Mobile Responsive Adjustments */
@media (max-width: 440px) {
  .vc-body {
    padding: 10px;
    gap: 10px;
  }
  
  .vc-photo-side {
    width: 75px;
    height: 85px;
  }
  
  .vc-value {
    font-size: 11px;
  }
  
  .vc-id-highlight {
    font-size: 15px;
  }
  
  .vc-org-title {
    font-size: 11px;
  }
}

.vc-footer {
  background-color: #faf8f5;
  padding: 6px 14px;
  border-top: 1px solid #f1eeeb;
  text-align: center;
}

.vc-footer p {
  font-family: var(--sinhala-font);
  font-size: 9px;
  font-style: italic;
  color: var(--text-muted);
}

/* Download Card Button */
.download-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--accent-color);
  color: #222222;
  border: none;
  border-radius: 4px;
  padding: 12px 20px;
  font-family: var(--sinhala-font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(241, 168, 10, 0.15);
  width: 100%;
  max-width: 400px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.download-card-btn:hover {
  background-color: #db9706;
  box-shadow: 0 4px 8px rgba(241, 168, 10, 0.25);
}

.download-card-btn:active {
  transform: scale(0.99);
}

.download-icon {
  width: 18px;
  height: 18px;
}

/* Floating Accessibility Widget Styling */
.accessibility-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border-radius: 30px;
  padding: 4px;
  display: flex;
  gap: 4px;
  z-index: 900;
}

.acc-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.acc-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}

.acc-btn.active {
  background-color: var(--primary-color);
  color: #ffffff;
}

.acc-btn:focus {
  outline: 2px solid var(--primary-color);
}

/* Utility Hidden state */
.hidden {
  display: none !important;
}

/* Responsive Styles for smaller screens */
@media (max-width: 600px) {
  body {
    padding: 10px 5px 60px 5px;
  }
  
  .card {
    padding: 18px;
    border-radius: 6px;
  }
  
  .title-card {
    padding: 24px 18px 18px 18px;
  }
  
  .main-title {
    font-size: calc(21px * var(--font-scale));
  }
  
  .pali-verse {
    font-size: calc(16px * var(--font-scale));
  }
  
  .form-actions {
    flex-direction: column-reverse;
    gap: 12px;
    align-items: stretch;
  }
  
  .submit-btn, .reset-btn {
    width: 100%;
    text-align: center;
  }
}
