/**
 * Nedarim Plus shortcode styles
 * Form fields, wait message, result, overlay.
 *
 * Classes used by Shortcode.php and JS controllers (reference):
 * - Layout: nedarim-plus-wrap, izicerfa_nedarim_plus_sc, nedarim-plus-content
 * - Lang: nedarim-plus-lang-style, nedarim-plus-lang-toggle-wrap, nedarim-plus-lang-toggle
 * - Form: nedarim-plus-form, nedarim-plus-field, nedarim-plus-label, nedarim-plus-label-translated,
 *   nedarim-plus-label-hebrew, nedarim-plus-input-wrap, nedarim-plus-amount-wrap, nedarim-plus-input,
 *   nedarim-plus-input-number, nedarim-plus-currency, nedarim-plus-select, required
 * - Segmented: nedarim-plus-segmented, nedarim-plus-segmented-input, nedarim-plus-segmented-label
 * - Rows: nedarim-plus-choice-row, nedarim-plus-choice-row--hidden, nedarim-plus-tashlumim-row,
 *   nedarim-plus-tashlumim-row--hidden, nedarim-plus-tashlumim-wrap, nedarim-plus-tashlumim-unlimited-option,
 *   nedarim-plus-summary-row, nedarim-plus-summary-row--hidden, nedarim-plus-summary
 * - Validation: nedarim-plus-field--error
 * - Submit: nedarim-plus-submit-wrap, nedarim-plus-submit-btn
 * - Overlay: nedarim-plus-validation-overlay, nedarim-plus-validation-spinner
 * - Result: nedarim-plus-result, nedarim-plus-result--success, nedarim-plus-result--error
 * - Iframe: nedarim-plus-iframe-legend-wrap, nedarim-plus-iframe-cell, nedarim-plus-iframe,
 *   nedarim-plus-wait, nedarim-plus-spinner
 * - Utility: nedarim-plus-text-left, nedarim-plus-text-right
 */

/* Wrapper for form + iframe + submit (positioned for overlay) */
.nedarim-plus-content {
  position: relative;
}

/* Language toggle: top right */
.nedarim-plus-lang-toggle-wrap {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
}

.nedarim-plus-lang-toggle {
  padding: 0.25em 0.5em;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.nedarim-plus-lang-toggle:hover {
  background: #f5f5f5;
}

/* Semi-transparent overlay with spinner during validation */
.nedarim-plus-validation-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  z-index: 10;
}

.nedarim-plus-validation-overlay[hidden] {
  display: none !important;
}

.nedarim-plus-validation-spinner {
  display: block;
  width: 3rem;
  height: 3rem;
  border: 3px solid #e0e0e0;
  border-top-color: #17a2b8;
  border-radius: 50%;
  animation: nedarim-plus-spin 0.7s linear infinite;
}

/* Form: 3-column table-like layout (translated label | input | Hebrew label) */
.nedarim-plus-form {
  padding-top: 2em;
  margin-bottom: 1em;
}

.nedarim-plus-field {
  margin: 0.5em 0;
}

.nedarim-plus-label {
  display: grid;
  grid-template-columns: minmax(7em, 0.8fr) minmax(12em, 2fr);
  gap: 0.5em 1em;
  align-items: center;
  font-weight: 500;
}

.nedarim-plus-label-translated {
  text-align: left;
}

.nedarim-plus-label-hebrew {
  text-align: right;
}

.nedarim-plus-label.nedarim-plus-checkbox-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em 1em;
}

.nedarim-plus-input-checkbox {
  width: auto;
  max-width: none;
  margin: 0;
}

/* Responsive: narrow screens — labels above the field.
   Flexbox + wrap: the two labels stay on one line (latin left, hebrew right)
   until they would overflow, then the second wraps below. Field always on its own row. */
@media (max-width: 800px) {
  .nedarim-plus-label {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em 0.5em;
    align-items: baseline;
  }

  .nedarim-plus-label-translated {
    order: 1;
    flex: 0 1 auto;
    min-width: 0;
    text-align: left;
  }

  .nedarim-plus-label-hebrew {
    order: 2;
    flex: 0 1 auto;
    min-width: 0;
    text-align: right;
    margin-left: auto;
  }

  .nedarim-plus-field .nedarim-plus-label .nedarim-plus-input-wrap,
  .nedarim-plus-field .nedarim-plus-label .nedarim-plus-input,
  .nedarim-plus-field .nedarim-plus-label textarea {
    order: 3;
    flex: 1 1 100%;
    min-width: 100%;
    gap: 0;
  }

  /* Amount: wrap takes full row; input takes remaining space, symbol stays on the right */
  .nedarim-plus-field .nedarim-plus-label .nedarim-plus-amount-wrap .nedarim-plus-input {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
  }

  .nedarim-plus-field .nedarim-plus-label .nedarim-plus-amount-wrap .nedarim-plus-currency {
    flex: 0 0 auto;
  }

  /* Tashlumim: wrap takes full row; select keeps flex 1 */
  .nedarim-plus-field .nedarim-plus-label .nedarim-plus-tashlumim-wrap .nedarim-plus-select {
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* Segmented control (donation frequency + your choice) */
.nedarim-plus-segmented {
  display: inline-flex;
  border-radius: 4px;
  overflow: hidden;
  background: #f0f0f0;
}

.nedarim-plus-segmented-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.nedarim-plus-segmented-label {
  border: 0.2em solid #17a2b8;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  padding: 0.5em 1em;
  margin: 0;
  cursor: pointer;
  background: #e9ecef;
  color: #333;
  font-weight: 500;
  font-size: 0.95em;
  transition: background 0.15s, color 0.15s;
  flex-grow: 1;
}

.nedarim-plus-segmented-input:checked + .nedarim-plus-segmented-label {
  background: #17a2b8;
  color: #fff;
}

.nedarim-plus-segmented-label:hover {
  filter: brightness(1.2);
}

.nedarim-plus-segmented-input:checked + .nedarim-plus-segmented-label .nedarim-plus-label-hebrew {
  color: rgba(255, 255, 255, 0.9);
}

.nedarim-plus-segmented-input:focus-visible + .nedarim-plus-segmented-label {
  outline: 2px solid #17a2b8;
  outline-offset: 2px;
}

/* Choice row + Tashlumim row: visible only when "I give in several times", with transition */
.nedarim-plus-choice-row,
.nedarim-plus-tashlumim-row {
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition:
    max-height 0.3s ease,
    opacity 0.25s ease,
    margin 0.25s ease,
    padding 0.25s ease;
}

.nedarim-plus-choice-row--hidden,
.nedarim-plus-tashlumim-row--hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  visibility: hidden;
  transition:
    max-height 0.3s ease,
    opacity 0.25s ease,
    margin 0.25s ease,
    padding 0.25s ease,
    visibility 0s linear 0.3s;
}

.nedarim-plus-choice-row:not(.nedarim-plus-choice-row--hidden),
.nedarim-plus-tashlumim-row:not(.nedarim-plus-tashlumim-row--hidden) {
  max-height: 180px;
}

/* Tashlumim: select (2–12, + "Until cancellation" when repeat) */
.nedarim-plus-tashlumim-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.nedarim-plus-tashlumim-wrap .nedarim-plus-select {
  min-width: 6em;
}

/* Summary row: own line, visible only when multiple times (hidden when donation is once) */
.nedarim-plus-summary-row,
.nedarim-plus-tashlumim-summary-row {
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition:
    max-height 0.3s ease,
    opacity 0.25s ease,
    margin 0.25s ease,
    padding 0.25s ease;
}

.nedarim-plus-summary-row--hidden,
.nedarim-plus-tashlumim-summary-row--hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  visibility: hidden;
  transition:
    max-height 0.3s ease,
    opacity 0.25s ease,
    margin 0.25s ease,
    padding 0.25s ease,
    visibility 0s linear 0.3s;
}

.nedarim-plus-summary-row:not(.nedarim-plus-summary-row--hidden),
.nedarim-plus-tashlumim-summary-row:not(.nedarim-plus-tashlumim-summary-row--hidden) {
  max-height: 120px;
}

.nedarim-plus-summary,
.nedarim-plus-tashlumim-summary {
  margin: 0.5em 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: #333;
  text-align: center;
  display: block;
  width: 100%;
}

/* Number input: text-like appearance (no native spinner) */
.nedarim-plus-input-number {
  -moz-appearance: textfield;
  appearance: textfield;
  text-align: right;
}

.nedarim-plus-input-number::-webkit-outer-spin-button,
.nedarim-plus-input-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.nedarim-plus-field .required {
  color: #b00;
}

.nedarim-plus-field--error {
  border-color: #b00;
  border-width: 2px;
  border-style: solid;
}

.nedarim-plus-input {
  width: 100%;
  min-width: 0;
  padding: 0.4em 0.5em;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-sizing: border-box;
}

/* Amount field: input + ILS symbol inside one border */
.nedarim-plus-amount-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
}

.nedarim-plus-amount-wrap .nedarim-plus-input {
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: right;
  order: 1;
}

.nedarim-plus-amount-wrap .nedarim-plus-currency {
  flex-shrink: 0;
  padding: 0 0.5em;
  font-size: 1em;
  color: #555;
  order: 2;
}

.nedarim-plus-field textarea.nedarim-plus-input {
  min-height: 3em;
  resize: vertical;
}

/* Submit button */
.nedarim-plus-submit-wrap {
  margin: 1em 0 0;
}

.nedarim-plus-submit-btn {
  padding: 0.5em 1.2em;
  font-size: 1em;
  font-weight: 500;
  color: #fff;
  background: #17a2b8;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.nedarim-plus-submit-btn:hover:not(:disabled) {
  background: #138496;
}

.nedarim-plus-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Result message (success / error) after TransactionResponse */
.nedarim-plus-result {
  margin-top: 1em;
  padding: 0.6em 0.75em;
  font-size: 0.95em;
  border-radius: 4px;
  border: 1px solid transparent;
}

.nedarim-plus-result--success {
  color: #155724;
  background: #d4edda;
  border-color: #c3e6cb;
}

.nedarim-plus-result--error {
  color: #721c24;
  background: #f8d7da;
  border-color: #f5c6cb;
}

.nedarim-plus-result--error h4 {
  color: #721c24;
  margin: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.nedarim-plus-result--error p,
.nedarim-plus-result--error div {
  color: #721c24;
  margin: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.nedarim-plus-text-left {
  text-align: left;
}

.nedarim-plus-text-right {
  text-align: right;
}

/* Wait message during iframe load */
.nedarim-plus-wait {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 0;
  font-size: 0.9em;
  color: #666;
}

/* Spinner */
.nedarim-plus-spinner {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  border: 2px solid #e0e0e0;
  border-top-color: #666;
  border-radius: 50%;
  animation: nedarim-plus-spin 0.7s linear infinite;
}

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

/* Iframe container */
.nedarim-plus-iframe-legend-wrap {
  display: flex;
  align-items: stretch;
  gap: 1em;
  margin-top: 0.75em;
  position: relative;
}

.nedarim-plus-iframe-cell {
  flex: 1;
  min-width: 0;
  position: relative;
}
