/* ===== COMPREHENSIVE MOBILE RESPONSIVENESS ENHANCEMENTS ===== */

/* Enhanced Mobile Viewport Settings */
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  min-width: 320px;
}

/* Mobile-specific spacing fixes for navbar overlap */
@media (max-width: 768px) {
  .hero-section {
    padding-top: 4rem !important;
  }
  
  .practice-area-header {
    padding-top: 4rem !important;
  }
  
  main > section:first-child:not(.hero-section):not(.practice-area-header),
  .main-content > section:first-child:not(.hero-section):not(.practice-area-header) {
    padding-top: 4rem !important;
  }
}

/* Extra small mobile devices */
@media (max-width: 576px) {
  .navbar .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .navbar-brand {
    flex: 1;
    min-width: 0;
  }
  
  .navbar-brand img,
  .brand-img {
    max-height: 35px;
  }
  
  .company-name {
    display: none; /* Hide on very small screens to prevent cutoff */
  }
  
  .hero-section,
  .practice-area-header {
    padding-top: 3rem !important;
  }
  
  main > section:first-child:not(.hero-section):not(.practice-area-header) {
    padding-top: 3rem !important;
  }
  
  /* Reduce overall spacing on very small screens */
  .section-title {
    margin-bottom: 1rem !important;
  }
}

/* Responsive Typography with Fluid Scaling */
h1, .h1 {
  font-size: clamp(1.75rem, 5vw, 3.5rem);
  line-height: 1.2;
}

h2, .h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.3;
}

h3, .h3 {
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.4;
}

h4, .h4 {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  line-height: 1.4;
}

h5, .h5 {
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.5;
}

h6, .h6 {
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
  line-height: 1.5;
}

p, .lead {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  line-height: 1.6;
}

/* Enhanced Mobile Navigation */
@media (max-width: 991.98px) {
  .navbar {
    position: fixed;
    z-index: 1030;
    padding: 0.75rem 0;
  }
  
  .navbar .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .navbar-brand {
    padding: 0.25rem 0;
    margin-right: 1rem;
  }
  
  .navbar-brand img,
  .brand-img {
    max-height: 40px;
  }
  
  .company-name {
    font-size: 0.9rem;
    margin-left: 0.5rem;
  }
  
  .navbar-toggler {
    border: none;
    padding: 4px 8px;
    background: var(--primary-red);
    border-radius: 4px;
    transition: all 0.3s ease;
    pointer-events: auto !important;
    cursor: pointer !important;
    margin-left: auto;
  }
  
  .navbar-toggler:focus {
    box-shadow: 0 0 0 2px rgba(178, 34, 34, 0.3);
    outline: none;
  }
  
  .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    filter: invert(1);
    pointer-events: none;
  }
  
  .navbar-collapse {
    background: white;
    margin-top: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 1rem;
    position: relative;
    z-index: 1000;
    pointer-events: auto !important;
  }
  
  .navbar-nav {
    pointer-events: auto !important;
  }
  
  .navbar-nav .nav-item {
    pointer-events: auto !important;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: var(--primary-blue) !important;
    font-weight: 500;
    background: transparent !important;
    border: 1px solid transparent;
    pointer-events: auto !important;
    cursor: pointer !important;
    text-decoration: none !important;
    position: relative;
    z-index: 10;
    transform: none !important;
  }
  
  .navbar-nav .nav-link:hover,
  .navbar-nav .nav-link:focus {
    background: var(--primary-red) !important;
    color: white !important;
    transform: translateX(4px) !important;
    border-color: var(--primary-red);
    pointer-events: auto !important;
  }
  
  .navbar-nav .nav-link.active,
  .navbar-nav .nav-item.active .nav-link,
  .navbar-nav .nav-link.current,
  .navbar-nav .nav-link[aria-current="page"] {
    background: var(--primary-red) !important;
    color: white !important;
    font-weight: 600;
    border: 1px solid var(--primary-red) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
  }
  
  /* Force visibility and clickability for any potentially hidden active states */
  .navbar-nav .active > .nav-link,
  .navbar-nav .nav-link.show {
    background: var(--primary-red) !important;
    color: white !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  
  /* Additional fallback for Bootstrap active states */
  .navbar-nav .nav-item.active > .nav-link,
  .navbar-nav .nav-item > .nav-link.active {
    background-color: var(--primary-red) !important;
    color: rgba(255, 255, 255, 1) !important;
    text-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  
  /* Ensure dropdown items are also clickable */
  .navbar-nav .dropdown-item {
    pointer-events: auto !important;
    cursor: pointer !important;
    color: var(--primary-blue) !important;
    background: transparent !important;
  }
  
  .navbar-nav .dropdown-item:hover,
  .navbar-nav .dropdown-item:focus {
    background: var(--primary-red) !important;
    color: white !important;
    pointer-events: auto !important;
  }
}

/* Mobile-Optimized Containers */
@media (max-width: 768px) {
  .container,
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }
  
  .col,
  [class*="col-"] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  section {
    padding: 3rem 0;
  }
  
  .section-header {
    margin-bottom: 2rem;
  }
}

/* Enhanced Touch-Friendly Buttons */
.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.5rem;
  font-size: clamp(0.9rem, 2vw, 1rem);
  border-radius: 6px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

@media (max-width: 768px) {
  .btn {
    padding: 1rem 2rem;
    margin: 0.5rem 0.25rem;
    width: 100%;
    max-width: 280px;
  }
  
  .btn-group .btn {
    width: auto;
    flex: 1;
  }
}

/* Mobile-Optimized Forms */
@media (max-width: 768px) {
  .form-control,
  .form-select {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem 1rem;
    border-radius: 6px;
  }
  
  .form-floating > .form-control,
  .form-floating > .form-select {
    min-height: 58px;
  }
  
  .form-label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
  }
  
  .input-group {
    flex-wrap: nowrap;
  }
  
  .input-group .form-control {
    min-width: 0;
  }
}

/* Mobile Hero Section Enhancements */
@media (max-width: 768px) {
  .hero-section {
    min-height: 85vh;
    padding: 2rem 0;
  }
  
  .hero-section .mask {
    background-color: rgba(0, 0, 0, 0.6) !important;
  }
  
  .hero-section h1 {
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  }
  
  .hero-section .lead {
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 2rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  }
  
  .hero-bottom-stats {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
    padding: 1.5rem;
  }
  
  .hero-stat-item {
    min-width: auto;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
  }
}

/* Mobile Card Layouts */
@media (max-width: 768px) {
  .card {
    margin-bottom: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  }
  
  .card-body {
    padding: 1.5rem;
  }
  
  .card-title {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    margin-bottom: 1rem;
  }
  
  .card-text {
    font-size: clamp(0.9rem, 2vw, 1rem);
    line-height: 1.6;
  }
  
  .card-img-top {
    height: 200px;
    object-fit: cover;
  }
}

/* Mobile Grid Improvements */
@media (max-width: 768px) {
  .row.g-4 > * {
    margin-bottom: 2rem;
  }
  
  .col-lg-4,
  .col-lg-6,
  .col-md-6 {
    width: 100%;
    max-width: 100%;
  }
  
  .d-flex.flex-row {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }
}

/* Mobile Footer Enhancements */
@media (max-width: 768px) {
  .footer {
    text-align: center;
    padding: 2rem 0;
  }
  
  .footer .col-lg-8,
  .footer .col-lg-4 {
    margin-bottom: 2rem;
  }
  
  .footer .nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .footer .nav-link {
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    transition: all 0.3s ease;
  }
  
  .footer .nav-link:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
  }
}

/* Mobile Carousel/Slider Improvements */
@media (max-width: 768px) {
  .practice-carousel .owl-nav {
    display: none !important;
  }
  
  .practice-carousel .owl-dots {
    margin-top: 2rem;
    text-align: center;
    padding: 0;
  }
  
  .practice-carousel .owl-dot {
    width: 12px;
    height: 12px;
    margin: 0 6px;
    border-radius: 50%;
    background: rgba(178, 34, 34, 0.3);
    transition: all 0.3s ease;
    display: inline-block;
    border: none;
    outline: none;
    cursor: pointer;
    position: relative;
  }
  
  .practice-carousel .owl-dot span {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    background: rgba(178, 34, 34, 0.3) !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    margin: 0 !important;
    border: none !important;
  }
  
  .practice-carousel .owl-dot.active,
  .practice-carousel .owl-dot:hover {
    background: var(--primary-red);
    transform: scale(1.2);
  }
  
  .practice-carousel .owl-dot.active span,
  .practice-carousel .owl-dot:hover span {
    background: var(--primary-red) !important;
    box-shadow: 0 0 8px rgba(178, 34, 34, 0.4) !important;
  }
  
  /* Fix for oversized dots - force consistent sizing */
  .practice-carousel .owl-dots .owl-dot {
    width: 12px !important;
    height: 12px !important;
    max-width: 12px !important;
    max-height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
  }
  
  .practice-carousel .owl-dots .owl-dot span {
    width: 12px !important;
    height: 12px !important;
    max-width: 12px !important;
    max-height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
  }
  
  .practice-carousel .owl-dots .owl-dot.active {
    width: 12px !important;
    height: 12px !important;
    transform: scale(1.1) !important;
  }
  
  .practice-carousel .owl-dots .owl-dot.active span {
    width: 12px !important;
    height: 12px !important;
    transform: none !important;
  }
  
  /* Enhanced practice areas mobile layout */
  .practice-areas-section {
    padding: 3rem 0 4rem;
    background: #f8f9fa;
  }
  
  .practice-carousel-wrapper {
    padding: 0 1rem;
    overflow: visible;
  }
  
  .practice-carousel .practice-item {
    background: white;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    margin: 0 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    text-align: center;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .practice-carousel .practice-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  }
  
  .practice-carousel .practice-icon {
    font-size: 2.5rem;
    color: var(--primary-red);
    margin-bottom: 1.5rem;
    display: block;
  }
  
  .practice-carousel .practice-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 1rem;
    line-height: 1.3;
  }
  
  .practice-carousel .practice-description {
    font-size: 0.95rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    flex-grow: 1;
  }
  
  .practice-carousel .practice-link {
    color: var(--primary-red);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(178, 34, 34, 0.1);
    border-radius: 25px;
    transition: all 0.3s ease;
    align-self: center;
  }
  
  .practice-carousel .practice-link:hover {
    background: var(--primary-red);
    color: white;
    transform: translateY(-2px);
  }
  
  /* Section header improvements */
  .practice-areas-section .section-header {
    margin-bottom: 3rem;
    text-align: center;
  }
  
  .practice-areas-section .section-title {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: var(--primary-blue);
    margin-bottom: 1rem;
    font-weight: 700;
  }
  
  .practice-areas-section .section-description {
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
  }
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: rgba(0,0,0,0);
  }
  
  img {
    max-width: 100%;
    height: auto;
  }
  
  .img-fluid {
    object-fit: cover;
  }
  
  /* Enhanced touch interactions for carousel */
  .practice-carousel {
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
  }
  
  .practice-carousel .owl-stage {
    cursor: grab;
  }
  
  .practice-carousel .owl-stage:active {
    cursor: grabbing;
  }
  
  /* Improve mobile carousel responsiveness */
  .practice-carousel .owl-item {
    padding: 0 0.5rem;
  }
  
  .practice-carousel .practice-item {
    margin: 0;
    transform: translateZ(0); /* Enable hardware acceleration */
    will-change: transform;
  }
  
  /* Reduce animations on mobile for better performance but keep essential ones */
  .card:hover {
    transform: none;
  }
  
  .btn:hover {
    transform: none;
  }
  
  /* Optimize scroll performance */
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better carousel transitions on mobile */
  .practice-carousel .owl-item.active .practice-item {
    animation: slideInUp 0.6s ease-out;
  }
  
  @keyframes slideInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Mobile-specific carousel autoplay indicators */
  .practice-carousel .owl-dots {
    position: relative;
  }
  
  .practice-carousel .owl-dots::before {
    content: '';
    position: absolute;
    top: -1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-red), var(--accent-gold));
    border-radius: 2px;
    opacity: 0.3;
  }
}

/* Mobile Accessibility Improvements */
@media (max-width: 768px) {
  /* Larger touch targets */
  a, button, .btn, .nav-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Better focus indicators */
  *:focus {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
  }
  
  /* Skip to content link for screen readers */
  .skip-to-content {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-red);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 4px;
  }
  
  .skip-to-content:focus {
    top: 6px;
  }
}

/* Mobile Sticky Elements */
@media (max-width: 768px) {
  .navbar {
    padding: 0.5rem 1rem;
  }
  
  .navbar.fixed-top {
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.95) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  }
}

/* Mobile Modal Improvements */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 1rem;
    max-width: calc(100vw - 2rem);
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1.5rem;
  }
  
  .modal-title {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
  }
}

/* Mobile Table Responsiveness */
@media (max-width: 768px) {
  .table-responsive {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  }
  
  .table {
    font-size: 0.85rem;
  }
  
  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }
}

/* Mobile Utility Classes */
@media (max-width: 768px) {
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-visible {
    display: block !important;
  }
  
  .mobile-center {
    text-align: center !important;
  }
  
  .mobile-full-width {
    width: 100% !important;
  }
  
  .mobile-no-margin {
    margin: 0 !important;
  }
  
  .mobile-small-padding {
    padding: 0.5rem !important;
  }
  
  /* Mobile section spacing improvements */
  section {
    padding: 2.5rem 0;
  }
  
  .section-header {
    padding: 0 1rem;
    margin-bottom: 2.5rem;
  }
  
  /* Mobile container improvements */
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Mobile stats section improvements */
  .stats-section {
    padding: 3rem 0;
  }
  
  .stats-item {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  }
  
  .stats-number {
    font-size: clamp(2rem, 6vw, 3rem);
  }
  
  .stats-label {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  }
  
  /* Mobile team section improvements */
  .team-section .card {
    margin-bottom: 2rem;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 6px 25px rgba(0,0,0,0.1);
  }
  
  .team-section .card-img-top {
    height: 250px;
    object-fit: cover;
  }
  
  /* Mobile about section improvements */
  .about-section {
    padding: 3rem 0;
  }
  
  .about-fact {
    background: white;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    text-align: center;
  }
  
  .about-fact-number {
    font-size: clamp(2.5rem, 7vw, 3.5rem);
    color: var(--primary-red);
    font-weight: 700;
    margin-bottom: 0.5rem;
  }
  
  .about-fact-label {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--text-light);
    font-weight: 500;
  }
}

/* Animation Performance on Mobile */
@media (max-width: 768px) and (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;
  }
}
