/* =====================================================
   Alyatim Donation Form – Modern UI
   Version: 1.6.1
   Features: RTL Phone Fix, Full Country List
   ===================================================== */

:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --primary: #0e7490;
  --primary-hover: #155e75;
  --border: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --focus-ring: rgba(14, 116, 144, 0.2);
  --radius: 12px;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
}

/* ========================================
   Container & Layout
   ======================================== */

.donation-form-container {
  max-width: 600px;
  margin: 40px auto;
  padding: 32px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  color: var(--text-main);
  border: 1px solid #f1f5f9;
}

/* RTL (Arabic) */
.donation-form-container.rtl-form {
  direction: rtl;
  text-align: right;
}

/* LTR (English) */
.donation-form-container.ltr-form {
  direction: ltr;
  text-align: left;
}

/* ========================================
   Form Header
   ======================================== */

.form-header {
  text-align: center;
  font-size: 24px;
  margin-bottom: 28px;
  color: var(--primary);
  font-weight: 700;
  position: relative;
  padding-bottom: 15px;
}

.form-header::after {
  content: "";
  display: block;
  width: 60px;
  height: 4px;
  background: var(--primary);
  margin: 10px auto 0;
  border-radius: 10px;
  opacity: 0.2;
}

/* ========================================
   Form Sections & Groups
   ======================================== */

.form-section {
  margin-bottom: 20px;
}

.form-divider {
  border: 0;
  border-top: 1px solid #eee;
  margin: 25px 0;
}

.form-group {
  margin-bottom: 20px;
}

/* ========================================
   Field Labels
   ======================================== */

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ========================================
   Input & Select Base Styles
   ======================================== */

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: all 0.2s ease-in-out;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input,
.form-group select {
  height: 52px;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

/* Focus states */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
  z-index: 10;
  position: relative;
}

/* ========================================
   Phone Row - RTL & LTR Support
   Layout: [Country Dropdown] [Country Code] [Phone Input]
   ======================================== */

.phone-row {
  display: flex;
  flex-direction: row;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}

.phone-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

/* Country selector */
.phone-row .country-select {
  flex: 0 0 140px;
  width: 140px;
  height: 50px;
  border: none;
  border-radius: 0;
  background: #f8fafc;
  font-weight: 600;
  color: var(--primary);
  padding: 12px 10px;
  cursor: pointer;
}

.phone-row .country-select:focus {
  box-shadow: none;
  outline: none;
}

/* Country code display box */
.phone-row .country-code-box {
  flex: 0 0 60px;
  width: 60px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* Phone input */
.phone-row .phone-input {
  flex: 1;
  height: 50px;
  border: none;
  border-radius: 0;
  padding: 12px 16px;
  direction: ltr;
  text-align: left;
}

.phone-row .phone-input:focus {
  box-shadow: none;
  outline: none;
}

/* ========================================
   Phone Row - RTL (Arabic) Layout (FINAL)
   Desired visual: العراق | رقم الهاتف | +964
   ======================================== */

.phone-row-rtl {
  flex-direction: row !important;
}

/* 1 — Country (rightmost) */
.phone-row-rtl .country-select {
  order: 1 !important;
  border-radius: var(--radius) 0 0 var(--radius);
  border-left: 1px solid var(--border);
  border-right: none;
}

/* 2 — Phone Input (middle) */
.phone-row-rtl .phone-input {
  order: 2 !important;
  border-radius: 0;
  text-align: right !important;
  direction: rtl !important;
}

/* 3 — Country Code (leftmost) */
.phone-row-rtl .country-code-box {
  order: 3 !important;
  border-radius: 0 var(--radius) var(--radius) 0;
  border-right: 1px solid var(--border);
  border-left: none;
}

/* ========================================
   Phone Row - LTR (English) Layout
   Order: [Country] [Code] [Phone]
   ======================================== */

.phone-row-ltr {
  flex-direction: row;
}

.phone-row-ltr .country-select {
  order: 1;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: 1px solid var(--border);
  border-left: none;
}

.phone-row-ltr .country-code-box {
  order: 2;
}

.phone-row-ltr .phone-input {
  order: 3;
  border-radius: 0 var(--radius) var(--radius) 0;
  text-align: left;
}

/* ========================================
   Amount Row
   ======================================== */

.amount-row {
  display: flex;
  flex-direction: row;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}

.amount-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.amount-row .amount-input {
  flex: 1;
  height: 50px;
  border: none;
  border-radius: 0;
  padding: 12px 16px;
}

.amount-row .amount-input:focus {
  box-shadow: none;
  outline: none;
}

.amount-row .currency-display {
  flex: 0 0 120px;
  width: 120px;
  height: 50px;
  border: none;
  border-radius: 0;
  background: #f1f5f9;
  font-weight: 600;
  color: var(--primary);
  padding: 12px 10px;
  cursor: not-allowed;
  opacity: 0.9;
}

/* Amount Row - RTL */
.amount-row-rtl .amount-input {
  order: 2;
  border-radius: var(--radius) 0 0 var(--radius);
}

.amount-row-rtl .currency-display {
  order: 1;
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 1px solid var(--border);
}

/* Amount Row - LTR */
.amount-row-ltr .amount-input {
  order: 1;
  border-radius: var(--radius) 0 0 var(--radius);
}

.amount-row-ltr .currency-display {
  order: 2;
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 1px solid var(--border);
}

/* ========================================
   Provinces Dropdown
   ======================================== */

.iraqi-provinces-wrapper {
  overflow: hidden;
}

.province-select {
  width: 100%;
  height: 52px;
  padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}

/* ========================================
   Donor Notes Textarea
   ======================================== */

#donor-notes {
  width: 100%;
  min-height: 80px;
  padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

#donor-notes:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.char-counter {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.rtl-form .char-counter {
  text-align: left;
}

.ltr-form .char-counter {
  text-align: right;
}

.char-counter.warning {
  color: var(--warning);
  font-weight: 600;
}

/* ========================================
   Currency & Conversion Display
   ======================================== */

.currency-description {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
  padding-left: 5px;
  direction: ltr;
  font-weight: 500;
}

.currency-description.ar {
  text-align: right;
  direction: rtl;
  padding-left: 0;
  padding-right: 5px;
}

#converted-amount {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  font-weight: bold;
  color: var(--primary);
}

/* ========================================
   Submit Button
   ======================================== */

.donation-submit {
  width: 100%;
  padding: 16px;
  margin-top: 15px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(14, 116, 144, 0.3);
  font-family: inherit;
}

.donation-submit:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(14, 116, 144, 0.4);
}

.donation-submit:active {
  transform: translateY(0);
}

/* ========================================
   Preview & Payment Widget
   ======================================== */

.preview-header {
  font-size: 20px;
  color: var(--primary);
  margin-bottom: 15px;
  font-weight: 600;
}

#donation-summary {
  margin-bottom: 15px;
  padding: 15px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

#donation-summary p {
  margin: 8px 0;
  font-size: 14px;
}

#donation-summary strong {
  color: var(--primary);
}

/* Payment Widget LTR Fix */
#payment-widget,
#payment-widget *,
.visa-card-container,
.visa-card-container * {
  direction: ltr !important;
  text-align: left !important;
}

#payment-widget input,
#payment-widget select {
  unicode-bidi: plaintext;
}

#payment-widget label {
  display: block;
  text-align: left !important;
}

/* ========================================
   Status Messages
   ======================================== */

.success-box {
  background: #ecfdf5;
  color: var(--success);
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid #a7f3d0;
  margin-top: 15px;
  text-align: center;
  font-weight: 600;
}

.error-box {
  background: #fef2f2;
  color: var(--error);
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid #fecaca;
  margin-top: 15px;
  text-align: center;
  font-weight: 600;
}

/* ========================================
   Select Arrow Custom Styling
   ======================================== */

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230e7490' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 12px;
  cursor: pointer;
}

.rtl-form .form-group select {
  background-position: left 16px center;
  padding-left: 40px;
}

.ltr-form .form-group select {
  background-position: right 16px center;
  padding-right: 40px;
}

/* Special styling for selects inside phone-row */
.phone-row select {
  background-position: left 10px center;
}

/* ========================================
   Animation for Provinces Dropdown
   ======================================== */

.iraqi-provinces-wrapper {
  transition: all 0.3s ease-in-out;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 600px) {
  .donation-form-container {
    padding: 20px;
    margin: 15px auto;
    border-radius: 12px;
  }

  .form-header {
    font-size: 20px;
  }

  /* Stack phone row vertically on mobile */
  .phone-row {
    flex-direction: column !important;
    border: none;
    background: transparent;
    gap: 10px;
  }

  .phone-row:focus-within {
    box-shadow: none;
  }

  .phone-row .country-select,
  .phone-row .country-code-box,
  .phone-row .phone-input {
    width: 100% !important;
    flex: auto !important;
    order: unset !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
  }

  .phone-row .country-select {
    height: 52px;
  }

  .phone-row .country-code-box {
    height: 52px;
    justify-content: flex-start;
    padding-left: 16px;
  }

  .phone-row .phone-input {
    height: 52px;
  }

  /* Stack amount row vertically on mobile */
  .amount-row {
    flex-direction: column !important;
    border: none;
    background: transparent;
    gap: 10px;
  }

  .amount-row:focus-within {
    box-shadow: none;
  }

  .amount-row .amount-input,
  .amount-row .currency-display {
    width: 100% !important;
    flex: auto !important;
    order: unset !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    height: 52px;
  }

  .donation-submit {
    font-size: 16px;
    padding: 14px;
  }
}

/* ========================================
   Donation Caption (Hidden - Backwards compatibility)
   ======================================== */

.donation-caption {
  display: none;
}
/* Add dropdown arrow to country select (Arabic + English) */
.phone-row .country-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230e7490' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 12px;
  background-position: right 12px center; /* LTR */
  padding-right: 32px;
}

/* RTL alignment */
.rtl-form .phone-row .country-select {
  background-position: left 12px center;
  padding-left: 32px;
  padding-right: 12px;
}
