/**
 * Web-specific styles for PWA
 * Adds hover effects and responsive behaviors for desktop/tablet
 */

/* Prevent flash of unstyled content - set immediate background */
html {
  background-color: #F5F7FB;
}

/* Base hover styles for interactive elements */
@media (hover: hover) and (pointer: fine) {
  /* Buttons */
  button:hover,
  [role="button"]:hover {
    cursor: pointer;
    filter: brightness(0.95);
    transition: filter 0.2s ease, transform 0.1s ease;
  }

  button:active,
  [role="button"]:active {
    transform: scale(0.98);
  }

  /* Links */
  a:hover {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease;
  }

  /* Touchable elements */
  [data-touchable="true"]:hover {
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s ease;
  }

  /* Cards */
  [data-card="true"]:hover {
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    transition: all 0.2s ease;
  }

  /* Input fields */
  input:hover,
  textarea:hover,
  select:hover {
    border-color: #4169E1;
    transition: border-color 0.2s ease;
  }
}

/* Prevent text selection on interactive elements */
button,
[role="button"],
[data-touchable="true"] {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Focus styles for accessibility */
button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #4169E1;
  outline-offset: 2px;
}

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

/* Remove tap highlight on mobile */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Responsive container max-widths */
.responsive-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .responsive-container {
    max-width: 600px;
  }
}

@media (min-width: 1024px) {
  .responsive-container {
    max-width: 720px;
  }
}

/* Full-height containers on web */
html,
body,
#root {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

/* Ensure #root always has a solid background to prevent pattern bleed-through during hydration */
#root {
  background-color: #F5F7FB;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Decorative background for wide screens */
@media (min-width: 900px) {
  /* Apply gradient background to root on wide screens */
  body {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
    background-attachment: fixed;
  }
  
  /* Add checkered pattern overlay */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
      linear-gradient(45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
      linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.12) 75%),
      linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.12) 75%);
    background-size: 30px 30px;
    background-position: 0 0, 0 15px, 15px -15px, -15px 0px;
    pointer-events: none;
    z-index: -1;
  }
  
  /* Splash screen must be above background pattern */
  #splash {
    z-index: 999999 !important;
  }
  
  #root {
    position: relative;
    z-index: 1;
  }
}

/* Decorative background pattern for wide screens */
.pattern-overlay {
  background-image: 
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.03) 10px,
      rgba(255, 255, 255, 0.03) 20px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.03) 10px,
      rgba(255, 255, 255, 0.03) 20px
    );
}

/* Centered content layout for desktop/tablet */
@media (min-width: 768px) {
  .app-centered-layout {
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
    position: relative;
  }
  
  .app-centered-layout::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
      repeating-linear-gradient(
        45deg,
        transparent,
        transparent 20px,
        rgba(255, 255, 255, 0.03) 20px,
        rgba(255, 255, 255, 0.03) 40px
      );
    pointer-events: none;
  }
  
  .app-content-area {
    max-width: 1200px;
    width: 100%;
    background: #F5F7FB;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
  }
}

/* Custom scrollbar for webkit browsers */
@media (min-width: 768px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #f5f7fb;
  }

  ::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
}

/* Print styles */
@media print {
  * {
    box-shadow: none !important;
  }
  
  @page {
    margin: 0;
    size: 80mm auto;
  }
}

/* Loading animation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  animation: spin 1s linear infinite;
}

/* Fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

/* Responsive grid helpers */
.grid-responsive {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

@media (min-width: 640px) {
  .grid-responsive {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-responsive {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}
