/**
 * Divi Simple Give - Donation Form Styles
 *
 * LAYOUT AND STRUCTURE ONLY
 * Visual styling (colors, fonts, borders, shadows) is handled by:
 * - Divi's get_advanced_fields_config()
 * - CSS custom properties from module settings
 * - ET_Builder_Element::set_style() in render method
 *
 * @package DiviSimpleGive
 */

/* ==========================================================================
   CSS Custom Properties (defaults, overridden by module settings)
   ========================================================================== */

.dsg-donation-form {
  --dsg-primary-color: #2563eb;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.dsg-hidden {
  display: none !important;
}

/* ==========================================================================
   Amount Buttons - Layout
   ========================================================================== */

.dsg-amounts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75em;
  margin-bottom: 1.5em;
}

@media (min-width: 480px) {
  .dsg-amounts {
    grid-template-columns: repeat(4, 1fr);
  }
}

.dsg-amount-btn {
  padding: 12px;
  cursor: pointer;
  border: 1px solid var(--dsg-primary-color);
  background: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
  border-radius: 5px;
}

.dsg-amount-btn.active {
  background-color: var(--dsg-primary-color);
  color: #fff;
}

/* Custom Amount Field */
.dsg-custom-amount {
  grid-column: span 2;
  position: relative;
  display: flex;
  align-items: center;
}

@media (min-width: 480px) {
  .dsg-custom-amount {
    grid-column: span 4;
  }
}

.dsg-custom-amount-input {
  padding-left: 28px !important;
}

/* ==========================================================================
   Type Toggle & Frequency Row - Layout
   ========================================================================== */

.dsg-type-frequency-row {
  display: flex;
  gap: 0.75em;
  margin-bottom: 1.5em;
}

.dsg-frequency {
  flex: 1;
  max-width: 50%;
}

.dsg-type-toggle {
  display: flex;
  flex: 0 0 auto;
  width: 50%;
  overflow: hidden;
}

.dsg-type-btn {
  flex: 1;
  padding: 9px;
  cursor: pointer;
  border: 1px solid var(--dsg-primary-color);
  background: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  border-radius: 0px 5px 5px 0px;
}

.dsg-type-btn:first-child {
  border-right: none;
  border-radius: 5px 0px 0px 5px;
}

.dsg-type-btn.active {
  background-color: var(--dsg-primary-color);
  color: #fff;
}

/* ==========================================================================
   Form Fields - Layout Only
   ========================================================================== */

.dsg-donor-info {
  margin-bottom: 1.5em;
}

.dsg-field {
  margin-bottom: 1em;
}

.dsg-field label,
.dsg-payment > label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.15;
}

/* Input base - structure only, Divi handles visual styling */
.dsg-input,
.dsg-frequency-select,
.dsg-custom-amount-input {
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Select dropdown arrow */
.dsg-frequency-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 36px;
}

/* ==========================================================================
   Payment Element - Layout
   ========================================================================== */

.dsg-payment {
  margin-bottom: 1.5em;
}

.dsg-payment > label {
  display: block;
  margin-bottom: 0.5em;
}

.dsg-payment-element {
  min-height: 50px;
}

.dsg-payment-errors {
  margin-top: 0.5em;
  color: #dc2626;
  font-size: 0.875em;
}

/* ==========================================================================
   Submit Button - Layout
   Visual styling handled by Divi's button advanced field
   ========================================================================== */

.dsg-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
  cursor: pointer;
}

.dsg-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dsg-submit-btn.loading .dsg-btn-text,
.dsg-submit-btn.loading .dsg-btn-amount {
  display: none;
}

.dsg-submit-btn.loading .dsg-spinner {
  display: block;
}

.dsg-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: dsg-spin 0.8s linear infinite;
}

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

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

.dsg-success-message {
  text-align: center;
  padding: 2em;
  background-color: #f0fdf4;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
}

.dsg-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1em;
  border-radius: 50%;
  background-color: #22c55e;
  color: #fff;
  font-size: 32px;
}

.dsg-error-message {
  margin-top: 9px;
  color: #dc2626;
}

.dsg-notice {
  padding: 1em;
  border-radius: 4px;
}

.dsg-notice-warning {
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  color: #d97706;
}

/* Required field indicator */
.dsg-field .required {
  color: #dc2626;
}

/* Inline field error messages */
.dsg-field-error {
  display: block;
  margin-top: 6px;
  font-size: 0.875em;
  color: #dc2626;
  line-height: 1.4;
}

/* Error state for inputs */
.dsg-input.error {
  border-color: #dc2626 !important;
}

.dsg-input.error:focus {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 1px #dc2626 !important;
}

/* ==========================================================================
   Manage Donations Link
   ========================================================================== */

.dsg-manage-link {
  margin-top: 1.5em;
  text-align: center;
}

/* ==========================================================================
   Portal Modal - Layout and Styling
   (Portal is not styled by Divi module designer)
   ========================================================================== */

.dsg-portal-modal {
  /* Default primary color - will be overridden by JS with form's primary color */
  --dsg-primary-color: #2563eb;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1em;
}

.dsg-portal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.dsg-portal-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2em;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transition: max-width 0.3s ease;
}

/* Wider portal for dashboard view on larger screens */
@media (min-width: 768px) {
  .dsg-portal-content.dsg-portal-wide {
    max-width: 640px;
  }
}

.dsg-portal-close {
  position: absolute;
  top: 1em;
  right: 1em;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 1;
  font-size: 24px;
  color: #6b7280;
  transition: color 0.2s ease;
}

.dsg-portal-close:hover {
  color: #111827;
}

.dsg-portal-step h3 {
  margin: 0 0 0.5em;
}

.dsg-portal-step > p {
  margin: 0 0 1.5em;
  color: #6b7280;
}

.dsg-portal-message {
  margin-top: 1em;
  padding: 0.75em 1em;
  border-radius: 4px;
}

.dsg-portal-message:empty {
  display: none;
}

.dsg-portal-message.error {
  background-color: #fef2f2;
  color: #dc2626;
}

.dsg-portal-message.success {
  background-color: #f0fdf4;
  color: #16a34a;
}

.dsg-portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5em;
}

.dsg-portal-header h3 {
  margin: 0;
}

/* Logout link at bottom of dashboard */
.dsg-portal-logout-wrapper {
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}

.dsg-portal-logout {
  display: inline-block;
  cursor: pointer;
  color: #6b7280;
  font-size: 0.875em;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
}

.dsg-portal-logout:hover {
  color: #374151;
  text-decoration: underline;
}

.dsg-portal-subscriptions,
.dsg-portal-history {
  margin-bottom: 1.5em;
}

.dsg-portal-subscriptions h4,
.dsg-portal-history h4 {
  margin: 0 0 1em;
  font-size: 1em;
  color: #374151;
}

.dsg-subscription-card {
  padding: 1em;
  margin-bottom: 0.75em;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

/* Subscription row layout */
.dsg-subscription-row {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

@media (min-width: 480px) {
  .dsg-subscription-row {
    flex-direction: row;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
  }
}

.dsg-subscription-amount {
  font-size: 1.25em;
  font-weight: 600;
  color: #111827;
}

.dsg-subscription-interval {
  color: #6b7280;
  font-size: 0.875em;
}

.dsg-subscription-next {
  color: #6b7280;
  font-size: 0.875em;
}

.dsg-subscription-card-info {
  color: #6b7280;
  font-size: 0.875em;
}

@media (min-width: 480px) {
  .dsg-subscription-interval,
  .dsg-subscription-next,
  .dsg-subscription-card-info {
    padding-left: 0.5em;
    border-left: 1px solid #e5e7eb;
  }
}

.dsg-subscription-actions {
  display: flex;
  gap: 0.5em;
  margin-top: 0.75em;
  padding-top: 0.75em;
  border-top: 1px solid #e5e7eb;
}

.dsg-btn-small {
  padding: 0.5em 1em;
  cursor: pointer;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.875em;
}

.dsg-btn-small:hover {
  background: #f9fafb;
}

.dsg-btn-small.danger {
  color: #dc2626;
  border-color: #fecaca;
}

.dsg-btn-small.danger:hover {
  background: #fef2f2;
}

.dsg-donation-item {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  padding: 0.75em 0;
  border-bottom: 1px solid #e5e7eb;
}

@media (min-width: 480px) {
  .dsg-donation-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75em;
  }
}

.dsg-donation-item:last-child {
  border-bottom: none;
}

.dsg-donation-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
}

@media (min-width: 480px) {
  .dsg-donation-info {
    gap: 0.75em;
    flex-wrap: nowrap;
  }
}

.dsg-donation-type-badge {
  padding: 0.125em 0.5em;
  font-size: 0.75em;
  border-radius: 4px;
  background: #e5e7eb;
  color: #374151;
}

.dsg-donation-type-badge.recurring {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Receipt link in donation history */
.dsg-receipt-link {
  font-size: 0.875em;
  color: var(--dsg-primary-color);
  text-decoration: none;
  white-space: nowrap;
}

.dsg-receipt-link:hover {
  text-decoration: underline;
}

.dsg-link-btn {
  display: block;
  margin-top: 1em;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  text-align: center;
  color: var(--dsg-primary-color);
  font-size: 0.875em;
}

.dsg-link-btn:hover {
  text-decoration: underline;
}

.dsg-empty-state {
  text-align: center;
  padding: 1.5em;
  color: #6b7280;
  font-size: 0.875em;
}

/* Portal form inputs - need styling since not in Divi context */
.dsg-portal-content .dsg-input {
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.5;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background-color: #fff;
  color: #111827;
}

.dsg-portal-content .dsg-input:focus {
  outline: none;
  border-color: var(--dsg-primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.dsg-portal-content .dsg-submit-btn {
  padding: 0.75em 1.5em;
  background-color: var(--dsg-primary-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1em;
  font-weight: 500;
}

.dsg-portal-content .dsg-submit-btn:hover {
  opacity: 0.9;
}
