/* ===================================
   RESPONSIVE DESIGN OPTIMIZATIONS
   ===================================*/

/* ===================================
   MOBILE DEVICES (320px - 768px)
   ===================================*/

/* Extra Small Devices (320px - 575px) */
@media (max-width: 575.98px) {
  /* Typography adjustments for small screens */
  :root {
    --font-size-5xl: 2rem;
    --font-size-4xl: 1.75rem;
    --font-size-3xl: 1.5rem;
    --font-size-2xl: 1.25rem;
    --font-size-xl: 1.125rem;
    --font-size-lg: 1rem;
  }

  /* Container padding for very small screens */
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Header optimizations */
  .header {
    height: 56px;
    padding: 0;
  }

  .navbar-brand {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .logo {
    height: 32px;
    width: 32px;
    flex-shrink: 0;
  }

  .brand-text {
    display: none; /* Hide brand text on very small screens */
  }

  /* Ensure navbar toggler is properly sized */
  .navbar-toggler {
    padding: 8px;
    font-size: 1rem;
    border-radius: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hero section mobile optimization */
  .hero-section {
    padding-top: 60px;
    min-height: 100vh;
    text-align: center;
  }

  .hero-title {
    font-size: 1.75rem;
    line-height: 1.3;
    margin-bottom: var(--spacing-md);
  }

  .hero-subtitle {
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-lg);
  }

  .hero-buttons {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .hero-buttons .btn {
    width: 100%;
    margin: 0;
  }

  /* Navigation mobile optimization */
  .navbar-nav {
    margin-bottom: var(--spacing-md);
  }

  .nav-link {
    font-size: var(--font-size-sm);
    padding: var(--spacing-sm);
  }

  /* Language and theme toggles */
  .language-toggle,
  .theme-toggle,
  .contrast-toggle {
    margin: var(--spacing-xs) 0;
  }

  .language-toggle .btn,
  .theme-toggle .btn,
  .contrast-toggle .btn {
    width: 100%;
    justify-content: center;
  }

  /* Services section mobile */
  .services-section .row {
    margin: 0;
  }
  
  .services-section .col-lg-3 {
    padding: 0 0 1rem 0;
    width: 100%;
    max-width: 100%;
  }

  .service-card {
    padding: 1.5rem;
    margin-bottom: 1rem;
    width: 100%;
    min-height: auto;
  }

  .service-card .service-icon {
    margin-bottom: 1rem;
  }

  .service-card h4 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .service-card p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
  }

  /* Products carousel mobile */
  .products-carousel {
    padding: 0 var(--spacing-sm);
  }

  .product-card {
    min-width: 280px;
  }

  /* Testimonials mobile */
  .testimonials-carousel {
    padding: 0 var(--spacing-sm);
  }

  .testimonial-card {
    padding: var(--spacing-md);
  }

  /* Contact form mobile */
  .contact-form {
    padding: var(--spacing-md);
  }

  .contact-form .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Footer mobile */
  .footer-content {
    text-align: center;
  }

  .footer-column {
    margin-bottom: var(--spacing-lg);
  }

  /* Nexa chat mobile optimization */
  .nexa-chat-fab {
    width: 56px;
    height: 56px;
    bottom: 20px;
    right: 16px;
  }

  .nexa-chat-modal {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  /* Touch-friendly button sizes */
  .btn {
    min-height: 44px;
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .btn-sm {
    min-height: 36px;
  }

  .btn-lg {
    min-height: 52px;
  }
}

/* Small Devices (576px - 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
  /* Container padding */
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }

  /* Show brand text again */
  .brand-text {
    display: inline;
    font-size: 1rem;
  }

  /* Header adjustments */
  .header {
    height: 60px;
  }

  .logo {
    height: 36px;
    width: 36px;
  }

  /* Hero adjustments */
  .hero-title {
    font-size: 2.25rem;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 1.125rem;
  }

  .hero-buttons {
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .hero-buttons .btn {
    width: auto;
    min-width: 140px;
  }

  /* Services grid - 2 columns */
  .services-section .row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 0;
  }

  .services-section .col-lg-3 {
    padding: 0;
    width: auto;
    max-width: none;
  }

  .service-card {
    padding: 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  /* Products carousel */
  .product-card {
    min-width: 240px;
    padding: 1.25rem;
  }

  /* About section adjustments */
  .about-section .row {
    flex-direction: column;
  }

  .about-section .col-lg-6 {
    width: 100%;
    max-width: 100%;
    margin-bottom: 2rem;
  }
}

/* ===================================
   TABLET DEVICES (768px - 1024px)
   ===================================*/

@media (min-width: 768px) and (max-width: 1023.98px) {
  /* Container adjustments */
  .container {
    padding-left: 15px;
    padding-right: 15px;
    max-width: 720px;
  }

  /* Header adjustments */
  .header {
    height: 64px;
  }

  .logo {
    height: 40px;
    width: 40px;
  }

  .brand-text {
    font-size: 1.125rem;
  }

  /* Hero section tablet */
  .hero-section {
    padding-top: 70px;
    min-height: 100vh;
  }

  .hero-title {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
  }

  .hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 2rem;
  }

  .hero-buttons {
    gap: 1.5rem;
  }

  /* Navigation - horizontal layout for tablets */
  .navbar-toggler {
    display: none;
  }

  .navbar-collapse {
    display: flex !important;
    position: static;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    transform: none;
    opacity: 1;
    visibility: visible;
  }

  .navbar-nav {
    flex-direction: row;
    margin-bottom: 0;
    align-items: center;
  }

  .nav-item {
    margin: 0 0.5rem;
  }

  .nav-link {
    padding: 0.5rem 1rem;
    background: transparent;
    margin: 0;
    border-radius: 4px;
    transition: background-color 0.3s ease;
  }

  .nav-link:hover,
  .nav-link:focus {
    background-color: rgba(255, 255, 255, 0.1);
  }

  /* Services grid - 2 columns for tablets */
  .services-section .row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 0;
  }

  .services-section .col-lg-3 {
    padding: 0;
    width: auto;
    max-width: none;
  }

  .service-card {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .service-card .service-content {
    flex-grow: 1;
  }

  .service-card .learn-more-btn {
    margin-top: auto;
  }

  /* About section - stack columns on tablets */
  .about-section .row {
    flex-direction: column;
  }

  .about-section .col-lg-6 {
    width: 100%;
    max-width: 100%;
    margin-bottom: 2rem;
  }

  .about-section .col-lg-6:last-child {
    margin-bottom: 0;
  }

  /* Products carousel */
  .products-carousel .row {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .product-card {
    min-width: 200px;
    flex-shrink: 0;
  }

  /* Testimonials - show 2 at a time */
  .testimonials-carousel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
  }

  /* Contact section - stack form and info */
  .contact-section .row {
    flex-direction: column;
  }

  /* Footer - 2 columns */
  .footer-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
  }

  /* Nexa chat - larger on tablets */
  .nexa-chat-fab {
    width: 64px;
    height: 64px;
  }

  .nexa-chat-modal {
    width: 400px;
    height: 500px;
  }
}

/* ===================================
   DESKTOP DEVICES (1024px+)
   ===================================*/

@media (min-width: 1024px) {
  /* Container adjustments */
  .container {
    max-width: 960px;
    padding-left: 15px;
    padding-right: 15px;
  }

  /* Full desktop layout */
  .header {
    height: 70px;
  }

  .logo {
    height: 40px;
    width: 40px;
  }

  .brand-text {
    font-size: 1.25rem;
  }

  /* Hero section full layout */
  .hero-section {
    padding-top: 80px;
    min-height: 100vh;
  }

  .hero-title {
    font-size: 3rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
  }

  .hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 2.5rem;
  }

  .hero-buttons {
    gap: 2rem;
  }

  /* Navigation - full desktop layout */
  .navbar-toggler {
    display: none;
  }

  .navbar-collapse {
    display: flex !important;
  }

  .navbar-nav {
    flex-direction: row;
    align-items: center;
  }

  .nav-item {
    margin: 0 0.75rem;
  }

  .nav-link {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }

  /* Services grid - 4 columns */
  .services-section .row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin: 0;
  }

  .services-section .col-lg-3 {
    padding: 0;
    width: auto;
    max-width: none;
  }

  .service-card {
    padding: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  /* About section - side by side */
  .about-section .row {
    flex-direction: row;
    align-items: flex-start;
  }

  .about-section .col-lg-6 {
    width: 50%;
    max-width: 50%;
    margin-bottom: 0;
  }

  /* Products - show more items */
  .products-carousel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
  }

  /* Testimonials - show 3 at a time */
  .testimonials-carousel {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Contact section - side by side */
  .contact-section .row {
    flex-direction: row;
  }

  /* Footer - 4 columns */
  .footer-content {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Nexa chat - desktop size */
  .nexa-chat-modal {
    width: 380px;
    height: 600px;
  }
}

/* ===================================
   LARGE DESKTOP (1200px+)
   ===================================*/

@media (min-width: 1200px) {
  /* Larger container */
  .container {
    max-width: 1140px;
  }

  /* Hero section enhancements */
  .hero-title {
    font-size: 3.5rem;
  }

  .hero-subtitle {
    font-size: var(--font-size-xl);
  }

  /* Services with more spacing */
  .services-grid {
    gap: var(--spacing-2xl);
  }

  /* Products - larger cards */
  .products-carousel {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

/* ===================================
   EXTRA LARGE DESKTOP (1400px+)
   ===================================*/

@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }

  .hero-title {
    font-size: 4rem;
  }
}

/* ===================================
   TOUCH-FRIENDLY INTERACTIONS
   ===================================*/

/* Increase touch targets for mobile */
@media (max-width: 768px) {
  /* Minimum touch target size of 44px */
  .btn,
  .nav-link,
  .language-toggle .btn,
  .theme-toggle .btn,
  .contrast-toggle .btn,
  .navbar-toggler,
  .carousel-control,
  .close,
  .form-control,
  .nexa-chat-fab,
  .quick-action-btn,
  .learn-more-btn {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Ensure buttons have adequate padding */
  .btn {
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.2;
  }

  .btn-sm {
    min-height: 40px;
    padding: 10px 14px;
    font-size: 14px;
  }

  .btn-lg {
    min-height: 52px;
    padding: 16px 24px;
    font-size: 18px;
  }

  /* Navigation links with adequate spacing */
  .nav-link {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 6px;
    font-size: 16px;
  }

  /* Larger tap areas for interactive elements */
  .service-card,
  .product-card,
  .testimonial-card {
    padding: 1.5rem;
    margin-bottom: 1rem;
  }

  .service-card .learn-more-btn,
  .product-card .product-cta {
    margin-top: 1rem;
    width: 100%;
  }

  /* Increase spacing between interactive elements */
  .nav-item {
    margin: 0.5rem 0;
  }

  /* Larger form inputs */
  .form-control {
    padding: 12px 16px;
    font-size: 16px; /* Prevent zoom on iOS */
    min-height: 44px;
    border-radius: 6px;
  }

  .form-control:focus {
    border-width: 2px;
    padding: 11px 15px; /* Adjust for thicker border */
  }

  /* Larger checkbox and radio buttons */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
  }

  /* Touch-friendly carousel controls */
  .carousel-control-prev,
  .carousel-control-next {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 18px;
  }

  .carousel-indicators button {
    width: 12px;
    height: 12px;
    margin: 0 4px;
    border-radius: 50%;
  }

  /* Touch-friendly social links */
  .social-link {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 4px;
    border-radius: 8px;
  }

  /* Nexa chat optimizations */
  .nexa-chat-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    bottom: 20px;
    right: 20px;
  }

  .nexa-chat-modal {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  .quick-action-btn {
    padding: 8px 12px;
    margin: 4px;
    border-radius: 20px;
    font-size: 14px;
  }

  /* Form validation feedback */
  .form-feedback {
    font-size: 14px;
    margin-top: 4px;
    padding: 4px 0;
  }
}

/* Tablet touch optimizations */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .btn,
  .nav-link,
  .form-control {
    min-height: 36px;
    min-width: 36px;
  }

  .btn {
    padding: 8px 16px;
    font-size: 15px;
  }

  .nav-link {
    padding: 8px 12px;
    font-size: 15px;
  }

  .form-control {
    padding: 8px 12px;
    font-size: 15px;
  }

  .service-card,
  .product-card,
  .testimonial-card {
    padding: 1.25rem;
  }

  .social-link {
    min-width: 36px;
    min-height: 36px;
  }

  .nexa-chat-fab {
    width: 52px;
    height: 52px;
  }
}

/* ===================================
   PERFORMANCE OPTIMIZATIONS
   ===================================*/

/* Reduce animations on slower devices */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Optimize for slower connections */
@media (max-width: 768px) {
  /* Reduce complex animations */
  .particle,
  .floating-element,
  .nexa-glow {
    display: none;
  }

  /* Simplify gradients for better performance */
  .hero-section {
    background: linear-gradient(135deg, #1A1E5D 0%, #282828 100%);
  }

  /* Reduce box shadows */
  .card,
  .btn,
  .service-card,
  .testimonial-card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .card:hover,
  .btn:hover,
  .service-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: none; /* Remove transform animations on mobile */
  }

  /* Optimize images for mobile */
  img {
    image-rendering: auto;
    image-rendering: optimizeSpeed;
  }

  /* Reduce transition effects */
  * {
    transition-duration: 0.2s;
  }

  /* Simplify hover effects */
  .service-card:hover,
  .product-card:hover,
  .testimonial-card:hover {
    transform: none;
  }

  /* Optimize fonts */
  body {
    font-display: swap;
  }

  /* Reduce blur effects */
  .backdrop-blur {
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.95);
  }

  [data-theme="dark"] .backdrop-blur {
    background: rgba(26, 30, 93, 0.95);
  }
}

/* Connection-aware optimizations */
@media (max-width: 768px) and (prefers-reduced-data: reduce) {
  /* Further reduce visual effects for data-conscious users */
  .hero-section {
    background: #1A1E5D;
  }

  .service-card,
  .product-card,
  .testimonial-card {
    box-shadow: none;
    border: 1px solid #e9ecef;
  }

  /* Disable non-essential animations */
  [data-aos] {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Battery optimization */
@media (max-width: 768px) {
  /* Reduce CPU-intensive effects when battery is low */
  .pulse-effect,
  .pulse-ring,
  .spinner {
    animation-duration: 2s; /* Slower animations */
  }

  /* Optimize scroll performance */
  * {
    will-change: auto;
  }

  .sticky-header {
    will-change: transform;
  }

  /* Reduce repaints */
  .service-card,
  .product-card,
  .testimonial-card {
    contain: layout style paint;
  }
}

/* ===================================
   LANDSCAPE ORIENTATION OPTIMIZATIONS
   ===================================*/

@media (max-height: 500px) and (orientation: landscape) {
  /* Reduce hero section height on landscape mobile */
  .hero-section {
    min-height: 100vh;
    padding: var(--spacing-lg) 0;
  }

  .hero-title {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
  }

  .hero-subtitle {
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
  }

  /* Compact header */
  .header {
    height: 48px;
  }

  /* Hide scroll indicator */
  .scroll-indicator {
    display: none;
  }
}

/* ===================================
   HIGH DPI DISPLAYS
   ===================================*/

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Ensure crisp images on retina displays */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  /* Adjust border widths for high DPI */
  .card,
  .form-control,
  .btn {
    border-width: 0.5px;
  }
}

/* ===================================
   PRINT STYLES
   ===================================*/

@media print {
  /* Hide interactive elements */
  .header,
  .nexa-chat-container,
  .btn,
  .navbar-toggler,
  .theme-toggle,
  .language-toggle,
  .contrast-toggle {
    display: none !important;
  }

  /* Optimize for print */
  body {
    font-size: 12pt;
    line-height: 1.4;
    color: #000;
    background: #fff;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  /* Page breaks */
  .hero-section,
  .about-section,
  .services-section,
  .products-section,
  .testimonials-section,
  .contact-section {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  /* Ensure links are visible */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
  }
}

/* ===================================
   ACCESSIBILITY ENHANCEMENTS
   ===================================*/

/* Focus indicators for keyboard navigation */
@media (max-width: 768px) {
  .btn:focus,
  .nav-link:focus,
  .form-control:focus,
  .navbar-toggler:focus {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
  }

  /* Larger focus indicators on mobile */
  .btn:focus {
    box-shadow: 0 0 0 4px rgba(30, 153, 255, 0.25);
  }
}

/* ===================================
   BROWSER-SPECIFIC OPTIMIZATIONS
   ===================================*/

/* Safari iOS optimizations */
@supports (-webkit-touch-callout: none) {
  /* Fix viewport height issues on iOS */
  .hero-section {
    min-height: -webkit-fill-available;
  }

  /* Prevent zoom on input focus */
  .form-control {
    font-size: 16px;
  }

  /* Fix sticky header on iOS */
  .sticky-header {
    position: -webkit-sticky;
    position: sticky;
  }
}

/* Chrome mobile optimizations */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  /* Smooth scrolling performance */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ===================================
   CONTAINER QUERIES (Future-proofing)
   ===================================*/

/* When container queries are supported, these will provide even better responsive design */
@supports (container-type: inline-size) {
  .responsive-container {
    container-type: inline-size;
  }

  @container (max-width: 400px) {
    .service-card {
      padding: var(--spacing-sm);
    }
  }

  @container (min-width: 600px) {
    .service-card {
      padding: var(--spacing-lg);
    }
  }
}