/**
 * Mobile-First Utility Classes
 * These utilities complement Tailwind CSS with mobile-specific patterns
 */

/* ===== MOBILE CARD PATTERNS ===== */

/* Mobile card stack - vertically stacked cards on mobile */
.mobile-card-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .mobile-card-stack.md\:grid {
    display: grid;
  }
  
  .mobile-card-stack.md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .mobile-card-stack.md\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Mobile card component */
.mobile-card {
  background-color: #ffffff;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s;
}

.mobile-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (min-width: 768px) {
  .mobile-card {
    padding: 1.5rem;
  }
}

/* ===== RESPONSIVE TABLE TO CARD TRANSFORMATION ===== */

/* Hide table on mobile, show on desktop */
.responsive-table {
  display: none;
}

@media (min-width: 768px) {
  .responsive-table {
    display: table;
    width: 100%;
  }
}

/* Show cards on mobile, hide on desktop */
.responsive-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .responsive-cards {
    display: none;
  }
}

/* Individual responsive card */
.responsive-card {
  background-color: #ffffff;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.responsive-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.responsive-card-row:last-child {
  border-bottom: none;
}

.responsive-card-label {
  font-weight: 600;
  color: #6b7280;
  font-size: 0.875rem;
  text-transform: uppercase;
}

.responsive-card-value {
  font-weight: 500;
  color: #111827;
  text-align: right;
}

/* ===== TAP TARGET UTILITIES ===== */

/* Minimum tap target size for mobile (44x44px) */
.tap-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tap-target-lg {
  min-height: 48px;
  min-width: 48px;
}

/* Ensure adequate spacing between tap targets */
.tap-spacing {
  margin: 0.5rem;
}

/* ===== MOBILE FORM UTILITIES ===== */

/* Mobile-optimized form input */
.input-mobile {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-mobile:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-mobile.error {
  border-color: #dc2626;
}

/* Form field spacing for mobile */
.form-field-mobile {
  margin-bottom: 1rem;
}

/* Error message styling */
.error-message {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ===== MOBILE BUTTON UTILITIES ===== */

/* Full-width button on mobile, auto-width on desktop */
.btn-mobile {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: 0.5rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .btn-mobile {
    width: auto;
  }
}

.btn-mobile:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== MOBILE NAVIGATION UTILITIES ===== */

/* Hamburger menu icon */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.5rem;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
}

.hamburger-line {
  width: 1.5rem;
  height: 2px;
  background-color: #111827;
  transition: all 0.3s;
}

.hamburger.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile navigation overlay */
.mobile-nav-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.mobile-nav-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mobile-nav-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80%;
  max-width: 320px;
  background-color: #ffffff;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.3s;
  overflow-y: auto;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.mobile-nav-menu.active {
  transform: translateX(0);
}

/* Sticky header for mobile */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ===== SCROLL UTILITIES ===== */

/* Prevent horizontal scrolling */
.prevent-horizontal-scroll {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Hide scrollbar but keep functionality */
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Smooth scrolling */
.smooth-scroll {
  scroll-behavior: smooth;
}

/* ===== IMAGE UTILITIES ===== */

/* Lazy loading placeholder */
.lazy-image {
  background-color: #f3f4f6;
  background-image: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Responsive image container */
.responsive-image {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.responsive-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* ===== SPACING UTILITIES ===== */

/* Mobile-optimized spacing */
.mobile-spacing {
  padding: 1rem;
}

@media (min-width: 640px) {
  .mobile-spacing {
    padding: 1.5rem;
  }
}

@media (min-width: 768px) {
  .mobile-spacing {
    padding: 2rem;
  }
}

/* Section spacing */
.section-mobile {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

@media (min-width: 768px) {
  .section-mobile {
    padding-top: 4rem;
    padding-bottom: 4rem;
  }
}

/* ===== STATUS BADGES ===== */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.status-badge.paid {
  background-color: #dcfce7;
  color: #166534;
}

.status-badge.pending {
  background-color: #fef3c7;
  color: #92400e;
}

.status-badge.refunded {
  background-color: #fee2e2;
  color: #991b1b;
}

.status-badge.generated {
  background-color: #dbeafe;
  color: #1e40af;
}

/* ===== EMPTY STATES ===== */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  color: #9ca3af;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.5rem;
}

.empty-state-description {
  color: #6b7280;
  margin-bottom: 1.5rem;
}

/* ===== LOADING STATES ===== */

.loading-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ===== BACK TO TOP BUTTON ===== */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3rem;
  height: 3rem;
  background-color: #2563eb;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, background-color 0.2s;
  z-index: 20;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background-color: #1e40af;
}

/* ===== ACCESSIBILITY ===== */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background-color: #2563eb;
  color: #ffffff;
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 100;
}

.skip-to-main:focus {
  top: 0;
}
