/* =========================================================
   STPI UPI QR Payment Form - Custom Styling
   Author: A K
   Module: stpi_upi_qr
   Description: Responsive, modern layout for UPI payment form
========================================================= */

/* =========================================
   Overall Layout - Centered Two-Column Design
========================================= */
form#stpi-upi-qr-public-payment-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;      /* centers layout horizontally */
  align-items: flex-start;      /* top alignment for form & QR */
  gap: 2rem;                    /* spacing between form and QR */
  margin: 2rem auto;            /* centers layout */
  max-width: 1000px;            /* restrict overall width */
  padding: 1rem;
  box-sizing: border-box;
}

/* =========================================
   Auto Layout Adjustment When QR is Empty
========================================= */
form#stpi-upi-qr-public-payment-form:has(#upi-qr-wrapper:empty) {
  flex-direction: column;
  align-items: center;
}

form#stpi-upi-qr-public-payment-form:has(#upi-qr-wrapper:empty) .payment-form-wrapper {
  flex: 0 0 100%;
  max-width: 600px;
}

/* =========================================
   Payment Form Wrapper (Left Section)
========================================= */
.payment-form-wrapper {
  background: #f9fafc;           /* light grey background */
  border: 1px solid #dcdcdc;     /* subtle border */
  border-radius: 12px;           /* rounded corners */
  padding: 1.5rem 2rem;          /* inner spacing */
  margin-bottom: 1.5rem;         /* spacing before submit button */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* soft shadow */
  flex: 0 0 48%;                 /* about 50% width */
  max-width: 480px;
  box-sizing: border-box;
}

/* =========================================
   Form Item Spacing
========================================= */
.payment-form-wrapper .form-item {
  margin-bottom: 1rem;
}

/* =========================================
   Labels
========================================= */
.payment-form-wrapper label {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.4rem;
  display: inline-block;
}

/* =========================================
   Inputs, Selects, Textareas
========================================= */
.payment-form-wrapper input.form-text,
.payment-form-wrapper select,
.payment-form-wrapper textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s ease-in-out;
  box-sizing: border-box;
}

/* Focus State */
.payment-form-wrapper input.form-text:focus,
.payment-form-wrapper select:focus,
.payment-form-wrapper textarea:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* =========================================
   Submit Button Styling
========================================= */
form#stpi-upi-qr-public-payment-form .form-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

form#stpi-upi-qr-public-payment-form .form-actions input[type="submit"] {
  background-color: #00bcd4;
  color: #fff;
  padding: 0.7rem 1.8rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

form#stpi-upi-qr-public-payment-form .form-actions input[type="submit"]:hover {
  background-color: #0097a7;
}

/* =========================================
   QR Code Wrapper (Right Section)
========================================= */
#upi-qr-wrapper {
  flex: 0 0 45%;                 /* half width */
  max-width: 400px;
  text-align: center;
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* When empty, visually hide but preserve layout logic for :has() */
#upi-qr-wrapper:empty {
  min-height: 0;
  padding: 0;
  border: none;
  box-shadow: none;
}

/* Optional: Display helpful placeholder text */
/*
#upi-qr-wrapper:empty::before {
  content: "QR code will appear here after generating";
  color: #999;
  font-size: 0.9rem;
  font-style: italic;
  padding: 1.5rem 0;
}
*/

/* QR Image */
#upi-qr-wrapper img {
  max-width: 100%;
  height: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 5px;
  background: #fff;
}

/* QR Details (Amount, Name, etc.) */
#upi-qr-wrapper p {
  margin-top: 0.75rem;
  font-size: 1rem;
  color: #444;
  line-height: 1.4;
}

#upi-qr-wrapper p strong {
  color: #222;
}

/* =========================================
   Responsive Adjustments
========================================= */
@media (max-width: 1024px) {
  form#stpi-upi-qr-public-payment-form {
    max-width: 90%;
  }

  .payment-form-wrapper,
  #upi-qr-wrapper {
    flex: 0 0 48%;
  }
}

@media (max-width: 768px) {
  form#stpi-upi-qr-public-payment-form {
    flex-direction: column;
    align-items: center;
  }

  .payment-form-wrapper,
  #upi-qr-wrapper {
    width: 100%;
    max-width: 480px;
  }

  #upi-qr-wrapper {
    margin-top: 1.5rem;
  }

  form#stpi-upi-qr-public-payment-form .form-actions {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  form#stpi-upi-qr-public-payment-form {
    padding: 0.5rem;
  }

  .payment-form-wrapper {
    padding: 1rem;
  }

  #upi-qr-wrapper {
    padding: 1rem;
  }
}

/* =========================================
   Validation Highlights
========================================= */
input.error,
select.error {
  border-color: #e53935 !important;
  background: #fff6f6;
}
