/* Mobile Layout Fixes
 * Comprehensive improvements for IKENAS website mobile version
 * Applied across all sections
 */

/* ===== GLOBAL FIXES ===== */
@media (max-width: 768px) {
  /* Better spacing and typography for mobile */
  body {
    font-size: 16px;
    padding-top: 70px;
  }

  .container {
    padding: 0 15px;
  }

  section {
    padding: 60px 0;
  }

  h1 {
    font-size: 2rem !important;
    line-height: 1.3 !important;
  }

  h2 {
    font-size: 1.8rem !important;
  }

  h3 {
    font-size: 1.3rem !important;
  }

  /* Improved button layout for touch */
  .btn {
    padding: 12px 24px;
    min-height: 44px; /* Better touch target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Improve logo sizing */
  .logo img, .logo-img {
    max-height: 35px;
    width: auto;
  }
}

/* ===== HEADER FIXES ===== */
@media (max-width: 768px) {
  header {
    height: 70px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }
  
  header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
  }

  /* Hamburger menu button styling to match the blue version in screenshot */
  .mobile-menu-toggle {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--primary-color);
  }
  
  .mobile-menu-toggle i {
    color: var(--primary-color);
  }

  /* Full-screen white mobile menu */
  .menu-overlay {
    background-color: rgba(0, 0, 0, 0.5);
  }

  .main-menu {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    background-color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .main-menu li {
    width: 80%;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0;
    margin: 0;
    transform: none !important;
    opacity: 1 !important;
  }

  .main-menu a {
    color: var(--text-color);
    font-size: 1.2rem;
    padding: 15px 0;
    display: block;
    font-weight: 500;
  }

  /* Specific fixes for the "Se connecter" button */
  .main-menu li:last-child {
    border-bottom: none;
    margin-top: 15px;
    margin-bottom: 15px;
  }

  .main-menu .btn.se-connecter,
  .main-menu .btn-login {
    background-color: #3b5ee8;
    color: white;
    padding: 10px 22px;
    border-radius: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 500;
    width: auto;
    min-width: 150px;
    margin: 0 auto;
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    transform: none;
  }

  .main-menu .btn.se-connecter i,
  .main-menu .btn-login i {
    margin-right: 6px;
    font-size: 1rem;
  }

  .main-menu .btn.se-connecter:hover,
  .main-menu .btn-login:hover {
    background-color: #2a4cd9;
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  }
}

/* ===== HERO SECTION FIXES ===== */
@media (max-width: 768px) {
  .hero {
    padding-top: 100px;
    padding-bottom: 60px;
    text-align: center;
  }

  .hero-content {
    margin-bottom: 30px;
  }

  .hero-content p {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-buttons {
    flex-direction: column;
    gap: 15px;
    align-items: center;
  }

  .hero-buttons .btn {
    width: 100%;
    max-width: 280px;
  }

  .hero-image {
    max-width: 90%;
    margin: 0 auto;
    display: block;
  }
  
  /* Disable floating animation for hero image on mobile */
  .hero-image img {
    animation: none !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ===== SERVICES SECTION FIXES ===== */
@media (max-width: 768px) {
  /* Improve services carousel on mobile */
  .services-container {
    padding: 0;
  }

  /* Hide navigation buttons on mobile */
  .services-nav {
    display: none;
  }

  .services-slider {
    padding: 15px 0;
    margin-left: 0 !important;
    padding-left: 0 !important;
    max-width: 100%;
    width: 100%;
  }

  .services-wrapper {
    padding-left: 0 !important;
    gap: 15px;
  }

  .service-card {
    flex: 0 0 260px;
    min-width: 260px;
    padding: 25px 20px;
  }

  .service-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  .service-card p {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  /* Better positioned navigation buttons - hidden on mobile but keeping for completeness */
  .services-nav {
    width: 36px;
    height: 36px;
  }

  .services-prev {
    left: 5px;
  }

  .services-next {
    right: 5px;
  }
}

/* ===== FORMATIONS SECTION FIXES ===== */
@media (max-width: 768px) {
  .formations-grid {
    grid-template-columns: 1fr;
    gap: 25px;
  }

  .formation-card {
    max-width: 400px;
    margin: 0 auto;
  }

  .formation-image {
    height: 180px;
  }

  .formation-content {
    padding: 20px;
  }

  .formation-details {
    justify-content: space-between;
    gap: 10px;
  }
}

/* ===== PARTENAIRES SECTION FIXES ===== */
@media (max-width: 768px) {
  .partenaires {
    padding: 40px 0;
    background-color: var(--bg-light);
  }
  
  .partenaires .section-header h2 {
    font-size: 1.8rem !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
  }
  
  .partenaires .section-header p {
    font-size: 1rem;
    color: var(--text-light);
    line-height: 1.5;
    max-width: 90%;
    margin: 0 auto;
  }
  
  .partenaires-grid {
    margin-top: 30px;
  }
  
  /* Optimized 2-column grid for partners on mobile */
  .partenaires-grid .row-1 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 90%;
    margin: 0 auto;
  }
  
  /* Partner logo styling */
  .partenaire-item {
    height: 90px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    margin-bottom: 0;
  }
  
  .partenaire-item img {
    max-width: 75%;
    max-height: 65%;
    filter: grayscale(100%);
    opacity: 0.8;
  }
  
  /* Remove any special positioning on mobile */
  .partenaire-item:nth-child(n) {
    grid-column: auto;
  }
}

/* Extra small screens optimization */
@media (max-width: 480px) {
  .partenaires-grid .row-1 {
    width: 95%;
    gap: 10px;
  }
  
  .partenaire-item {
    height: 80px;
    padding: 10px;
    border-radius: 6px;
  }
  
  .partenaire-item img {
    max-width: 70%;
    max-height: 60%;
  }
}

/* ===== CONTACT SECTION FIXES ===== */
@media (max-width: 768px) {
  .contact-container {
    flex-direction: column;
  }

  .contact-info {
    margin-bottom: 30px;
    padding-right: 0;
  }

  .contact-form {
    width: 100%;
  }

  .form-group {
    margin-bottom: 15px;
  }

  .form-group input,
  .form-group textarea {
    padding: 12px 15px;
    font-size: 16px;
  }
}

/* ===== FOOTER FIXES ===== */
@media (max-width: 768px) {
  .footer {
    padding: 40px 0 100px;
    background-color: #111827 !important; /* Dark blue/black background as in screenshot 3 */
    color: white;
  }
  
  .footer-top {
    display: flex;
    flex-direction: column;
    gap: 30px;
  }

  .footer-col {
    text-align: center;
    margin-bottom: 0;
    padding: 0 20px;
  }
  
  /* IKENAS title in footer - match styling from screenshot 3 */
  .footer-logo h2 {
    color: white !important;
    font-size: 1.5rem !important;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 1px;
  }
  
  /* Subtitle text - match styling from screenshot 3 */
  .footer-col p {
    color: #9ca3af;
    font-size: 0.95rem;
    margin-bottom: 20px;
  }
  
  /* Social media icons - match the blue circular style from screenshot 3 */
  .footer-social {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
  }
  
  .footer-social a {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.3s ease;
  }
  
  /* Quick links section - match styling from screenshot 3 */
  .footer .liens-rapides {
    margin-top: 30px;
  }
  
  .footer h4 {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
  }
  
  .footer h4:after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 2px;
    background-color: var(--primary-color);
    border-radius: 3px;
  }

  .footer-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
  }
  
  .footer-links li {
    margin-bottom: 5px;
  }
  
  .footer-links a {
    color: #e5e7eb;
    font-size: 1rem;
    transition: color 0.3s ease;
  }
  
  .footer-links a:hover {
    color: var(--primary-color);
  }
  
  .footer-bottom {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
  }
  
  .footer-bottom p {
    color: #9ca3af;
    font-size: 0.9rem;
  }
}

/* ===== FLOATING BUTTONS FIXES ===== */
@media (max-width: 768px) {
  .whatsapp-btn,
  .scroll-top {
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
    bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: fixed;
    z-index: 99;
  }

  /* WhatsApp button green as in screenshots */
  .whatsapp-btn {
    left: 20px;
    background-color: #25D366;
  }

  /* Scroll to top button blue as in screenshots */
  .scroll-top {
    right: 20px;
    background-color: var(--primary-color);
    animation: pulse 2s infinite;
  }
  
  @keyframes pulse {
    0% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.05);
    }
    100% {
      transform: scale(1);
    }
  }
}

/* Fix styling for scroll-to-top button on mobile */
@media (max-width: 768px) {
  .scroll-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #3b5ee8;
    color: white;
    text-align: center;
    line-height: 50px;
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    transform: none !important;
    animation: none !important;
  }
  
  .scroll-top:before,
  .scroll-top:after {
    content: none !important;
    display: none !important;
  }
  
  .scroll-top i {
    font-size: 1.2rem;
    line-height: 50px;
    position: relative;
    z-index: 1;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
  
  .scroll-top.active {
    opacity: 1;
    visibility: visible;
    transform: none !important;
    animation: none !important;
  }
  
  .scroll-top:hover,
  .scroll-top:active,
  .scroll-top:focus {
    transform: none !important;
    animation: none !important;
    background-color: #3b5ee8 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) !important;
  }
  
  .scroll-top:hover i,
  .scroll-top:active i,
  .scroll-top:focus i {
    transform: none !important;
    animation: none !important;
  }
}

/* Completely new scroll-to-top button with minimal styling */
.scroll-top-new {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: #3b5ee8;
  color: white;
  border: none;
  display: none; /* Hidden by default, shown via JS */
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
}

/* When displayed, use flex layout */
.scroll-top-new[style*="display: block"] {
  display: flex !important;
}

/* Simple icon styling */
.scroll-top-new i {
  font-size: 18px;
  line-height: 1;
}

/* Simple hover effect that won't cause animation issues */
.scroll-top-new:hover {
  background-color: #2749d6;
}

/* Hide the original button completely */
.scroll-top {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ===== ANIMATION PERFORMANCE ===== */
@media (max-width: 768px) {
  /* Reduce or disable animations on mobile for better performance */
  * {
    animation-duration: 0.1s !important;
    transition-duration: 0.2s !important;
  }
  
  /* Completely disable specific animations that cause performance issues */
  .hero-image img,
  .service-icon img,
  .about-image img,
  .rotating-element,
  .floating-element {
    animation: none !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Better tap targets for improved accessibility */
@media (max-width: 768px) {
  a, button, .btn, input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .social-link, .footer-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
}

/* Horizontal scrolling for Actualités section on mobile */
@media (max-width: 768px) {
  /* Make the news grid scrollable horizontally */
  .news-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 20px;
    margin: 0 -15px;
    padding-left: 15px;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
  }
  
  .news-grid::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
  
  .news-card {
    flex: 0 0 auto;
    width: 85%;
    margin-right: 15px;
    scroll-snap-align: start;
  }
  
  /* Same for events list */
  .events-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 20px;
    margin: 0 -15px;
    padding-left: 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .events-list::-webkit-scrollbar {
    display: none;
  }
  
  .event-item {
    flex: 0 0 auto;
    width: 85%;
    margin-right: 15px;
    scroll-snap-align: start;
  }
  
  /* Visual indicator that content is scrollable - REMOVED */
  .tab-pane.active::after {
    content: none; /* Removed the gradient shadow */
    display: none;
  }
  
  .tab-pane {
    position: relative;
  }
}

/* Fix button tap area issues - more robust solution */
@media (max-width: 768px) {
  /* Increase tap target size for all buttons */
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-sm,
  a.btn {
    position: relative;
    padding: 12px 25px !important;
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Create invisible larger tap target */
  .btn::after,
  .btn-primary::after,
  .btn-secondary::after,
  a.btn::after {
    content: "";
    position: absolute;
    top: -10px;
    right: -10px;
    bottom: -10px;
    left: -10px;
    z-index: 1;
  }
  
  /* Specific fix for the troublesome button */
  .btn-secondary,
  .formations-more .btn-secondary,
  .view-all .btn-secondary {
    width: calc(100% - 30px) !important;
    max-width: 300px !important;
    margin: 15px auto !important;
    display: block !important;
    text-align: center !important;
  }
  
  /* Make sure the text is positioned properly */
  .btn span, 
  .btn-primary span, 
  .btn-secondary span {
    position: relative;
    z-index: 2;
  }
}

/* Even smaller screens */
@media (max-width: 480px) {
  .news-card {
    width: 250px;
  }
  
  .news-card .news-image {
    height: 130px;
  }
  
  .actualites .tab-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
  }
  
  .view-all .btn-secondary {
    max-width: 250px;
    padding: 10px 20px;
    font-size: 0.85rem;
  }
}
