/**
 * ASMS PTSO Utility Classes
 * Reusable utility classes to replace inline styles in templates
 */

/* Layout utilities */
.scroll-anchor {
    scroll-margin-top: 100px;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.card-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.card-min-height {
    min-height: 160px;
}

/* Calendar embed utilities */
.calendar-wrapper {
    position: relative;
    padding-bottom: 75%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.calendar-iframe {
    border: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* What's New Card utilities */
.whats-new-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.content-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.content-text {
    flex-grow: 1;
    line-height: 1.5;
    max-height: 4.5em; /* Approximately 3 lines of text */
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.content-text.expanded {
    max-height: none;
}

.read-more-btn {
    align-self: flex-start;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.read-more-btn:hover {
    text-decoration: none;
}

/* Content Modal Styles */
.content-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--asms-surface, #ffffff);
    color: var(--asms-text, #111827);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(2,6,23,0.2);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

/* Responsive modal */
@media (max-width: 640px) {
    .content-modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
}

/* Button utilities */
.btn-hidden {
    display: none;
}

/* Theme-aware utilities that use CSS variables */
.asms-accent-bg {
    background-color: var(--asms-accent);
}

.asms-accent-color {
    accent-color: var(--asms-accent);
}

/* Theme-aware background for image containers - matches card background */
.asms-theme-bg {
    background-color: var(--asms-surface);
}

/* Theme-aware alternating background - uses main page background color */
.asms-theme-bg-alt {
    background-color: var(--asms-background);
}

/* Budget page utilities */
.asms-budget-item-bg {
    background-color: color-mix(in srgb, var(--asms-background) 85%, white 15%);
}

/* Hero image utilities */
.hero-image {
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.hero-image-fixed {
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.hero-image-contain {
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

/* Hero height utilities */
.hero-height-short {
    min-height: 60vh;
}

.hero-height-medium {
    min-height: 70vh;
}

.hero-height-tall {
    min-height: 80vh;
}

.hero-height-full {
    min-height: 100vh;
}

/* Alignment utilities */
.align-content-center {
    align-content: center;
}

/* Footer organization name centering */
.asms-footer-org-centered {
    justify-self: center;
}

/* Theme-aware glass morphism panel */
.asms-panel {
    background: rgba(255, 255, 255, 0.1);
    background-color: color-mix(in srgb, var(--asms-surface, #ffffff) 90%, transparent 10%);
    color: var(--asms-text, #111827);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}

/* Subtle hover effects */
.asms-panel:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.2),
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

/* Subtle inner highlight */
.asms-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 50%, 
        rgba(255, 255, 255, 0.05) 100%);
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

/* Ensure content is above the pseudo-element */
.asms-panel > * {
    position: relative;
    z-index: 2;
}

/* Newsletter form glass panel */
.tnp.tnp-subscription {
    background: rgba(255, 255, 255, 0.1);
    background-color: color-mix(in srgb, var(--asms-surface, #ffffff) 90%, transparent 10%);
    color: var(--asms-text, #111827);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}

/* Newsletter form hover effects */
.tnp.tnp-subscription:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.2),
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

/* Newsletter form inner highlight */
.tnp.tnp-subscription::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 50%, 
        rgba(255, 255, 255, 0.05) 100%);
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

/* Ensure newsletter form content is above the pseudo-element */
.tnp.tnp-subscription > * {
    position: relative;
    z-index: 2;
}

  .tnp-submit, /* Adjust based on actual class */
  a[title*="Unsubscribe"] { /* Fallback for link-based output */
      background: var(--asms-btn-primary-bg, #4A4A4A) !important;
      color: white !important;
      border: none !important;
      padding: 0.75rem 2rem !important;
      font-size: 1.1rem !important;
      font-weight: 600 !important;
      border-radius: 8px !important;
      cursor: pointer !important;
      text-decoration: none !important;
  }

  form.tnp-button-form.tnp-reactivate {
    margin-top: 5%;
    margin-bottom: 5%;
}

/* Fix for newsletter shortcode wp-block-columns spacing issue */
.wp-block-columns.is-layout-flex.wp-container-core-columns-is-layout-28f84493.wp-block-columns-is-layout-flex {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Additional fix for any wp-block-columns in newsletter context */
.newsletter-form .wp-block-columns {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Header organization name responsive display */
.asms-header-full-name {
    display: inline;
}

.asms-header-short-name {
    display: none;
}

/* Show short name below 360px */
@media (max-width: 359px) {
    .asms-header-full-name {
        display: none;
    }
    
    .asms-header-short-name {
        display: inline;
    }
}

/* Cross-browser centering fixes for Featured Event section */
.container {
    margin-left: auto;
    margin-right: auto;
    max-width: 1200px;
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Ensure Featured Event panel is properly centered */
.asms-panel {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
    display: block;
}

/* Firefox-specific flexbox centering fix */
@supports (-moz-appearance: none) {
    .container {
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
    
    .asms-panel {
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Loading indicator styles */
.asms-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: asms-spin 1s linear infinite;
    margin-right: 8px;
}

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

/* Loading button state */
.asms-btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.asms-btn-loading .asms-loading-spinner {
    margin-right: 8px;
}

/* Hide text when loading */
.asms-btn-loading .btn-text {
    opacity: 0;
}

/* Show loading text */
.asms-btn-loading .btn-loading-text {
    opacity: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

/* Initially hide loading text */
.btn-loading-text {
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

/* Form loading overlay */
.asms-form-loading {
    position: relative;
}

.asms-form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: inherit;
}

/* Centered animated spinner overlay shown during form submissions */
.asms-form-spinner {
    position: absolute;
    z-index: 20;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.asms-form-spinner .asms-loading-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.asms-form-spinner-text {
    color: var(--asms-text, #111827);
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
}

/* Sticky footer: ensure wrapper fills viewport and content grows */
html, body { height: 100%; }
#wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
#container {
  flex: 1 0 auto; /* grow to fill available space so footer is pushed to bottom */
}
#footer {
  flex-shrink: 0;
}

/* Donation form styles */
.amount-btn {
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.amount-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.amount-btn.active {
  border-color: var(--asms-accent-color, #3b82f6);
  background-color: var(--asms-accent-color, #3b82f6);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Stripe Elements styling */
#card-element {
  transition: border-color 0.2s ease;
}

#card-element:focus-within {
  border-color: var(--asms-accent-color, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.StripeElement {
  padding: 12px;
}

.StripeElement--focus {
  border-color: var(--asms-accent-color, #3b82f6);
}

.StripeElement--invalid {
  border-color: #dc2626;
}

/* Custom amount input */
#custom-amount {
  transition: all 0.2s ease;
}

#custom-amount:focus {
  border-color: var(--asms-accent-color, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Card used across forms to match Donate card styles */
.asms-card {
  background: var(--asms-surface, #ffffff);
  color: var(--asms-text, #111827);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: 0 6px 20px rgba(2,6,23,0.06);
}

/* Manage subscription block matches donation form visual style and respects theme vars */
.asms-manage-subscription {
  background: var(--asms-surface, #ffffff);
  color: var(--asms-text, #111827);
}

/* Primary button used site-wide (theme-aware) */
.asms-btn-primary {
  background-color: var(--asms-accent, #065f46);
  color: var(--asms-btn-text, #ffffff);
  border: none;
  display: inline-block;
  text-align: center;
}

.asms-btn-primary:hover {
  filter: brightness(0.95);
}

/* Form inputs consistent with donation form */
.asms-theme-border {
  border: 1px solid color-mix(in srgb, var(--asms-background, #f8fafc) 60%, rgba(0,0,0,0.06));
  background: var(--asms-input-bg, #fff);
  color: var(--asms-text, #111827);
}

/* Collapsible manage subscription styles */
.asms-manage-subscription-details summary {
  list-style: none;
}
.asms-manage-subscription-details summary::-webkit-details-marker {
  display: none;
}
.asms-manage-summary-indicator {
  display: inline-block;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 18px;
  border-radius: 4px;
  background: var(--asms-background, #f8fafc);
  color: var(--asms-text, #111827);
}
.asms-manage-subscription-details[open] .asms-manage-summary-indicator {
  transform: rotate(45deg);
}

/* Ensure manage subscription appears last on small screens */
@media (max-width: 767px) {
  /* Hide the desktop inline instance and show the mobile bottom one */
  .asms-manage-desktop-inline { display: none !important; }
  .asms-manage-mobile-bottom { display: block !important; }
}

@media (min-width: 768px) {
  /* Desktop: show inline instance, hide mobile bottom duplicate */
  .asms-manage-desktop-inline { display: block !important; }
  .asms-manage-mobile-bottom { display: none !important; }
}