@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
  /* Image Fallback Placeholder Styles */
  img.image-fallback-placeholder {
    @apply bg-muted opacity-90;
  }

  /* Flash Message Animations */
  @keyframes slide-down {
    from {
      opacity: 0;
      transform: translateY(-1rem);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-slide-down {
    animation: slide-down 0.3s ease-out;
  }

  /* ============================================
     CHECKOUT PAGE STYLES (subscriptions/new)
     ============================================ */

  /* Animations */
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes slideInLeft {
    from {
      opacity: 0;
      transform: translateX(-20px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes slideInRight {
    from {
      opacity: 0;
      transform: translateX(20px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  .animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
  }

  .animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
  }

  .animate-slide-in-left {
    animation: slideInLeft 0.6s ease-out forwards;
  }

  .animate-slide-in-right {
    animation: slideInRight 0.6s ease-out forwards;
  }

  /* Staggered animation delays */
  .checkout-page .order-summary-column {
    animation: slideInLeft 0.6s ease-out 0.1s forwards;
    opacity: 0;
  }

  .checkout-page .payment-methods-column {
    animation: slideInRight 0.6s ease-out 0.2s forwards;
    opacity: 0;
  }

  /* Order Summary Card */
  .checkout-page .bg-surface {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  }

  /* Payment Method Options */
  .payment-method-option {
    position: relative;
  }

  /* Hide the actual radio input */
  .payment-method-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
  }

  /* The clickable label */
  .payment-method-label {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background-color: #282828;
    border: 2px solid #3a3a3a;
    border-radius: 22px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
  }

  /* Subtle gradient overlay on hover */
  .payment-method-label::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(243, 241, 220, 0.03) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
  }

  .payment-method-label:hover {
    border-color: rgba(243, 241, 220, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.3);
  }

  .payment-method-label:hover::before {
    opacity: 1;
  }

  /* Selected state */
  .payment-method-radio:checked + .payment-method-label {
    border-color: #f3f1dc;
    background-color: rgba(243, 241, 220, 0.08);
    box-shadow: 0 0 0 1px rgba(243, 241, 220, 0.1), 0 10px 30px -5px rgba(0, 0, 0, 0.3);
  }

  .payment-method-radio:checked + .payment-method-label::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(243, 241, 220, 0.06) 0%, transparent 60%);
  }

  /* Focus state for accessibility */
  .payment-method-radio:focus + .payment-method-label {
    outline: 2px solid #f3f1dc;
    outline-offset: 2px;
  }

  /* Custom radio indicator */
  .payment-method-indicator {
    width: 24px;
    height: 24px;
    border: 2px solid #3a3a3a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
  }

  .payment-method-indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #282828;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* Selected indicator state */
  .payment-method-radio:checked + .payment-method-label .payment-method-indicator {
    border-color: #f3f1dc;
    background-color: #f3f1dc;
    box-shadow: 0 0 0 4px rgba(243, 241, 220, 0.15);
  }

  .payment-method-radio:checked + .payment-method-label .payment-method-indicator-dot {
    transform: scale(1);
    background-color: #282828;
  }

  /* Payment Forms */
  #stripe-payment-section,
  #manual-payment-section form {
    animation: fadeInUp 0.4s ease-out forwards;
  }

  /* Buttons */
  .checkout-page button[type="submit"],
  .checkout-page button[data-action*="submit"] {
    position: relative;
    overflow: hidden;
  }

  .checkout-page button[type="submit"]::after,
  .checkout-page button[data-action*="submit"]::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .checkout-page button[type="submit"]:hover::after,
  .checkout-page button[data-action*="submit"]:hover::after {
    opacity: 1;
  }

  /* Responsive Adjustments */
  @media (max-width: 1024px) {
    .checkout-page .order-summary-column,
    .checkout-page .payment-methods-column {
      animation: fadeInUp 0.6s ease-out forwards;
      opacity: 0;
    }

    .checkout-page .payment-methods-column {
      animation-delay: 0.15s;
    }
  }

  /* Reduced Motion */
  @media (prefers-reduced-motion: reduce) {
    .animate-fade-in,
    .animate-fade-in-up,
    .animate-slide-in-left,
    .animate-slide-in-right,
    .checkout-page .order-summary-column,
    .checkout-page .payment-methods-column,
    #stripe-payment-section,
    #manual-payment-section form {
      animation: none;
      opacity: 1;
      transform: none;
    }

    .payment-method-label,
    .payment-method-indicator,
    .payment-method-indicator-dot {
      transition: none;
    }
  }

  /* ============================================
     SUBSCRIPTION PLANS INDEX STYLES
     ============================================ */

  /* Plan card ordering for desktop layout */
  @media (min-width: 768px) {
    .plan-card-wrapper {
      order: var(--desktop-order, 0);
    }
  }
}
