/**
 * Responsive Fixes for Patent Products Page
 * Comprehensive responsive design with accessibility and performance optimizations
 */

/* ==========================================================================
   CSS Variables and Configuration
   ========================================================================== */

:root {
  /* Responsive breakpoints */
  --breakpoint-xs: 0;
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --breakpoint-xxl: 1400px;

  /* Spacing variables */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Typography scale */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
  --font-size-5xl: 3rem;

  /* Animation durations */
  --transition-fast: 0.15s;
  --transition-base: 0.3s;
  --transition-slow: 0.5s;

  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ==========================================================================
   Mobile First Responsive Design
   ========================================================================== */
/* Adjust top space for large and small screens */
.modern-hero {
  padding: 8rem 0 4rem 0; /* Top 6rem, bottom 4rem */
  text-align: center;
}

@media (max-width: 768px) {
  .modern-hero {
    padding: 4rem 1rem 2rem 1rem; /* On tablets and phones */
  }
}

/* Extra Small devices (phones, 576px and down) */
@media (max-width: 575.98px) {
  /* Hero Section Mobile */
  .modern-hero {
    padding: 6rem 0 3rem;
    text-align: center;
    min-height: auto;
  }

  .hero-title {
    font-size: var(--font-size-3xl);
    line-height: 1.2;
    margin-bottom: var(--spacing-sm);
    word-wrap: break-word;
  }

  .hero-subtitle {
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
  }

  /* @media (min-width: 768px) { */
  .stats {
    flex-wrap: wrap; /* allow wrapping again */
    justify-content: center;
  }
}

/* .stats {
        margin-top: var(--spacing-lg) !important;
        gap: var(--spacing-sm);

    } */

.stat-number {
  font-size: var(--font-size-2xl);
  font-weight: 700;
}

.stat-label {
  font-size: var(--font-size-xs);
  margin-top: var(--spacing-xs);
}

/* Products Grid Mobile */
.row-cols-1 > * {
  flex: 0 0 100%;
  max-width: 100%;
  padding: var(--spacing-xs);
}

.product-card {
  margin-bottom: var(--spacing-sm);
  border-radius: 12px;
}

.product-img {
  max-width: 160px !important;
  height: 200px !important;
  border-radius: 8px;
}

.card-title {
  font-size: var(--font-size-lg);
  margin-bottom: var(--spacing-xs);
}

.card-text {
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

/* Footer Mobile */
.footer {
  text-align: center;
  padding: var(--spacing-lg) 0;
}

.footer-brand .logo-container {
  justify-content: center;
  margin-bottom: var(--spacing-md);
}

.social-links {
  justify-content: center;
  margin-top: var(--spacing-md);
  gap: var(--spacing-sm);
}

/* Navigation Mobile */
.navbar-brand .brand-text {
  display: none !important;
}

.navbar-nav {
  text-align: center;
  padding: var(--spacing-sm) 0;
}

.dropdown-menu {
  text-align: center;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dropdown-item {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dropdown-item:last-child {
  border-bottom: none;
}

/* Container adjustments */
.container {
  padding-left: var(--spacing-sm);
  padding-right: var(--spacing-sm);
}

/* Button adjustments */
.btn {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  border-radius: 8px;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: var(--font-size-base);
}

/* Typography adjustments */
.lead {
  font-size: var(--font-size-base);
  line-height: 1.6;
}

.display-4 {
  font-size: var(--font-size-3xl);
  line-height: 1.2;
}

.fw-bold {
  font-weight: 600 !important;
}

/* Spacing adjustments */
.py-5 {
  padding-top: var(--spacing-lg) !important;
  padding-bottom: var(--spacing-lg) !important;
}

.mb-5 {
  margin-bottom: var(--spacing-lg) !important;
}

.mt-5 {
  margin-top: var(--spacing-lg) !important;
}

/* Search modal mobile */
.search-content {
  width: 95%;
  margin: var(--spacing-lg) auto;
  border-radius: 12px;
}

.search-input {
  font-size: 16px; /* Prevents zoom on iOS */
  padding: var(--spacing-md);
}

/* Section spacing */
section {
  padding: var(--spacing-lg) 0;
}

/* ==========================================================================
   Small devices (landscape phones, 576px and up)
   ========================================================================== */

@media (min-width: 576px) and (max-width: 767.98px) {
  .hero-title {
    font-size: var(--font-size-4xl);
  }

  .hero-subtitle {
    font-size: var(--font-size-lg);
  }

  .product-img {
    max-width: 180px !important;
    height: 220px !important;
  }

  .stats {
    margin-top: var(--spacing-xl) !important;
  }

  .stat-number {
    font-size: var(--font-size-3xl);
  }

  .container {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
}

/* ==========================================================================
   Medium devices (tablets, 768px and up)
   ========================================================================== */

@media (min-width: 768px) and (max-width: 991.98px) {
  .hero-title {
    font-size: var(--font-size-5xl);
  }

  .hero-subtitle {
    font-size: var(--font-size-xl);
  }

  .product-img {
    max-width: 200px !important;
    height: 250px !important;
  }

  /* Tablet Navigation */
  .navbar-brand .brand-text {
    display: block !important;
  }

  .brand-name {
    font-size: var(--font-size-lg);
  }

  .brand-tagline {
    font-size: var(--font-size-sm);
  }

  /* Tablet grid adjustments */
  .row-cols-md-3 > * {
    padding: var(--spacing-xs);
  }

  .container {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
}

/* ==========================================================================
   Large devices (desktops, 992px and up)
   ========================================================================== */

@media (min-width: 992px) {
  .hero-title {
    font-size: 3.5rem;
  }

  .hero-subtitle {
    font-size: var(--font-size-xl);
  }

  .product-img {
    max-width: 200px !important;
    height: 250px !important;
  }

  /* Desktop Navigation */
  .navbar-brand .brand-text {
    display: block !important;
  }

  /* Desktop grid adjustments */
  .row-cols-lg-4 > * {
    padding: var(--spacing-xs);
  }

  .container {
    max-width: 1140px;
  }
}

/* ==========================================================================
   Extra large devices (large desktops, 1200px and up)
   ========================================================================== */

@media (min-width: 1200px) {
  .hero-title {
    font-size: 4rem;
  }

  .container {
    max-width: 1140px;
  }
}

/* ==========================================================================
   Extra extra large devices (larger desktops, 1400px and up)
   ========================================================================== */

@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
}

/* ==========================================================================
   Product Cards Responsive Improvements
   ========================================================================== */

.product-card {
  transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #ffffff;
  overflow: hidden;
  position: relative;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
  border-color: rgba(44, 85, 48, 0.2);
}

.product-img {
  transition: transform var(--transition-base) ease;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 8px;
  overflow: hidden;
}

.product-card:hover .product-img {
  transform: scale(1.05);
}

/* ==========================================================================
   Button Responsive Improvements
   ========================================================================== */

.btn {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition-base) ease;
  border-radius: 8px;
  font-weight: 500;
  letter-spacing: 0.025em;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-outline-success {
  border-width: 2px;
  color: #198754;
  border-color: #198754;
}

.btn-outline-success:hover {
  background-color: #198754;
  border-color: #198754;
  color: #ffffff;
}

/* ==========================================================================
   Navigation Responsive Improvements
   ========================================================================== */

.navbar {
  background-color: #ffffff !important; /* Solid white */
  backdrop-filter: none !important; /* Disable blur */
  -webkit-backdrop-filter: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* Optional: light shadow */
}

.navbar.scrolled {
  background-color: #ffffff !important; /* Keep white on scroll */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* Enhance if needed */
}

/* Navigation links underline animation */
.navbar-nav .nav-link {
  position: relative;
  font-weight: 500;
  transition: color 0.3s ease;
}

.navbar-nav .nav-link::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after {
  width: 100%;
}

/* ==========================================================================
   Dropdown Responsive Improvements
   ========================================================================== */

@media (max-width: 991.98px) {
  .dropdown-submenu > .dropdown-menu {
    position: static !important;
    float: none;
    width: 100%;
    margin-top: var(--spacing-xs);
    margin-left: var(--spacing-md);
    border: none;
    box-shadow: none;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
  }

  .dropdown-submenu > a::after {
    float: right;
    margin-top: var(--spacing-xs);
  }
}

/* ==========================================================================
   Search Modal Responsive Improvements
   ========================================================================== */

.search-modal {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.search-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.search-input {
  border: 2px solid transparent;
  transition: all var(--transition-base) ease;
  border-radius: 12px;
}

.search-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.1);
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .product-card,
  .product-img,
  .btn,
  .navbar-nav .nav-link::after {
    transition: none;
  }

  .product-card:hover {
    transform: none;
  }
}

@media (prefers-contrast: high) {
  .product-card {
    border: 2px solid #000;
  }

  .btn-outline-success {
    border-width: 3px;
  }

  .navbar-nav .nav-link::after {
    height: 3px;
  }
}

/* Focus states for accessibility */
.btn:focus,
.nav-link:focus,
.dropdown-item:focus,
.search-input:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ==========================================================================
   Loading States and Animations
   ========================================================================== */

.product-img {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.product-img[src] {
  background: none;
  animation: none;
}

/* ==========================================================================
   Grid Improvements
   ========================================================================== */

.row-cols-1 > * {
  padding: var(--spacing-xs);
}

@media (min-width: 576px) {
  .row-cols-sm-2 > * {
    padding: var(--spacing-xs);
  }
}

@media (min-width: 768px) {
  .row-cols-md-3 > * {
    padding: var(--spacing-xs);
  }
}

@media (min-width: 992px) {
  .row-cols-lg-4 > * {
    padding: var(--spacing-xs);
  }
}

/* ==========================================================================
   Image Optimization
   ========================================================================== */

.product-img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  object-fit: cover;
  object-position: center;
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

.product-card {
  will-change: transform;
  contain: layout style paint;
}

.product-img {
  will-change: transform;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .product-card {
    background-color: #2d3748;
    border-color: #4a5568;
  }

  .card-title a {
    color: #e2e8f0 !important;
  }

  .card-text {
    color: #a0aec0 !important;
  }

  .navbar {
    background: rgba(45, 55, 72, 0.95);
  }

  .search-content {
    background: rgba(45, 55, 72, 0.95);
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .header,
  .footer,
  .search-modal,
  .btn,
  .navbar-toggler {
    display: none !important;
  }

  .product-card {
    break-inside: avoid;
    border: 1px solid #000;
    box-shadow: none;
    margin-bottom: var(--spacing-md);
  }

  .hero-title {
    color: #000 !important;
  }

  .container {
    max-width: none !important;
    padding: 0 !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.4;
  }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aspect-ratio-1-1 {
  aspect-ratio: 1 / 1;
}

.aspect-ratio-4-3 {
  aspect-ratio: 4 / 3;
}

/* ==========================================================================
   Custom Scrollbar
   ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ==========================================================================
   Selection Styles
   ========================================================================== */

::selection {
  background-color: var(--accent-color);
  color: #000;
}

::-moz-selection {
  background-color: var(--accent-color);
  color: #000;
}

/* ==========================================================================
   Focus Visible (for keyboard navigation)
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
