/*
 * EMCAN Responsive Design Enhancements
 * Version: 1.0
 * Mobile-first responsive improvements
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
  /* Colors */
  --primary-color: #ff5528;
  --secondary-color: #0e2a47;
  --text-color: #333333;
  --text-light: #666666;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --border-color: #e5e5e5;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --spacing-xxl: 4rem;

  /* Typography */
  --font-primary: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-size-base: 16px;
  --font-size-sm: 14px;
  --font-size-lg: 18px;
  --line-height-base: 1.6;

  /* Borders */
  --border-radius-sm: 4px;
  --border-radius: 8px;
  --border-radius-lg: 16px;
  --border-radius-full: 50px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ==========================================================================
   Base Responsive Fixes
   ========================================================================== */

/* Prevent horizontal scroll */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* Better box sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Responsive images by default */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Better touch targets */
a, button, input, select, textarea {
  min-height: 44px;
  min-width: 44px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea,
select {
  font-size: 16px; /* Prevents iOS zoom on focus */
}

/* ==========================================================================
   Typography Improvements
   ========================================================================== */

body {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  margin-bottom: var(--spacing-sm);
}

/* ==========================================================================
   Header & Navigation - Mobile First
   ========================================================================== */

/* Mobile hamburger menu - larger touch target */
.mobile-nav__toggler {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 100;
}

/* Mobile navigation drawer improvements */
.mobile-nav__wrapper {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
}

.mobile-nav__wrapper.expanded {
  pointer-events: auto;
}

.mobile-nav__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.mobile-nav__wrapper.expanded .mobile-nav__overlay {
  opacity: 1;
}

.mobile-nav__content {
  position: absolute;
  top: 0;
  right: -320px;
  width: 300px;
  max-width: 85vw;
  height: 100%;
  background: var(--bg-white);
  overflow-y: auto;
  transition: right var(--transition-base);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
}

[dir="rtl"] .mobile-nav__content {
  right: auto;
  left: -320px;
  transition: left var(--transition-base);
}

.mobile-nav__wrapper.expanded .mobile-nav__content {
  right: 0;
}

[dir="rtl"] .mobile-nav__wrapper.expanded .mobile-nav__content {
  right: auto;
  left: 0;
}

/* Mobile nav close button */
.mobile-nav__close {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--border-radius);
  background: var(--bg-light);
  transition: background var(--transition-fast);
}

[dir="rtl"] .mobile-nav__close {
  right: auto;
  left: var(--spacing-sm);
}

.mobile-nav__close:hover {
  background: var(--border-color);
}

/* Mobile nav menu items */
.mobile-nav__container ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-nav__container li {
  border-bottom: 1px solid var(--border-color);
}

.mobile-nav__container a {
  display: block;
  padding: var(--spacing-sm) 0;
  font-size: var(--font-size-lg);
  color: var(--text-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.mobile-nav__container a:hover {
  color: var(--primary-color);
}

/* Mobile contact info in drawer */
.mobile-nav__contact {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

.mobile-nav__contact li {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.mobile-nav__contact i {
  color: var(--primary-color);
  width: 20px;
}

/* Mobile social links */
.mobile-nav__social {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-lg);
}

.mobile-nav__social a {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border-radius: var(--border-radius);
  color: var(--text-color);
  transition: all var(--transition-fast);
}

.mobile-nav__social a:hover {
  background: var(--primary-color);
  color: var(--bg-white);
}

/* ==========================================================================
   Footer Responsive
   ========================================================================== */

.main-footer {
  padding: var(--spacing-xl) 0;
}

.main-footer__about__text {
  font-size: var(--font-size-sm);
  line-height: 1.7;
}

.main-footer__social {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.main-footer__social a {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
}

.main-footer__info-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  word-break: break-word;
}

/* ==========================================================================
   Cards & Components
   ========================================================================== */

/* Modern card styling */
.modern-card,
.service-one__item,
.course-one__item,
.team-one__item {
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  overflow: hidden;
}

.modern-card:hover,
.service-one__item:hover,
.course-one__item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* Image containers with aspect ratio */
.img-container {
  position: relative;
  overflow: hidden;
  background: var(--bg-light);
}

.img-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.img-container:hover img {
  transform: scale(1.05);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.eduact-btn,
.btn-modern {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 28px;
  font-size: var(--font-size-base);
  font-weight: 600;
  border-radius: var(--border-radius-full);
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  border: none;
  gap: var(--spacing-xs);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 14px 18px;
  font-size: var(--font-size-base);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-white);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 85, 40, 0.1);
}

/* Form labels */
label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--text-color);
}

/* Form groups */
.form-group {
  margin-bottom: var(--spacing-md);
}

/* ==========================================================================
   WhatsApp Floating Button
   ========================================================================== */

.about-one__thumb__box {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  left: auto !important;
  z-index: 999 !important;
  background: #25d366 !important;
  color: white !important;
  padding: 12px 20px !important;
  border-radius: 50px !important;
  box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4) !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  text-decoration: none !important;
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
  width: auto !important;
  max-width: 280px !important;
}

[dir="rtl"] .about-one__thumb__box {
  right: auto !important;
  left: 20px !important;
}

.about-one__thumb__box:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 6px 30px rgba(37, 211, 102, 0.5) !important;
  color: white !important;
}

.about-one__thumb__box__icon {
  position: static !important;
  left: 0 !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  flex-shrink: 0 !important;
  background: rgba(255, 255, 255, 0.2) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
  color: white !important;
  transform: none !important;
}

.about-one__thumb__box__icon::after {
  display: none !important;
  content: none !important;
}

.about-one__thumb__box__icon span {
  position: static !important;
  transform: none !important;
}

.about-one__thumb__box__title {
  font-size: 12px !important;
  font-weight: 500 !important;
  color: rgba(255, 255, 255, 0.9) !important;
  margin: 0 !important;
  line-height: 1.3 !important;
}

.about-one__thumb__box__text {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: white !important;
  margin: 0 !important;
  letter-spacing: 0 !important;
}

/* Responsive WhatsApp Button */
@media (max-width: 767px) {
  .about-one__thumb__box {
    bottom: 15px !important;
    right: 15px !important;
    padding: 10px !important;
    max-width: 56px !important;
    border-radius: 50% !important;
    width: 56px !important;
    height: 56px !important;
    justify-content: center !important;
  }

  [dir="rtl"] .about-one__thumb__box {
    right: auto !important;
    left: 15px !important;
  }

  .about-one__thumb__box__icon {
    position: static !important;
    left: 0 !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: 18px !important;
    background: transparent !important;
    margin: 0 !important;
  }

  .about-one__thumb__box__title,
  .about-one__thumb__box__text {
    display: none !important;
  }
}

/* ==========================================================================
   Scroll to Top Button
   ========================================================================== */

.scroll-top {
  position: fixed;
  bottom: 100px;
  right: var(--spacing-lg);
  width: 50px;
  height: 50px;
  z-index: 998;
}

[dir="rtl"] .scroll-top {
  right: auto;
  left: var(--spacing-lg);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }

.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing-md); }

/* ==========================================================================
   MEDIA QUERIES - Mobile First
   ========================================================================== */

/* Extra Small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
  :root {
    --font-size-base: 14px;
  }

  .container {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
  }

  /* Header */
  .main-menu__logo img {
    max-width: 120px;
    height: auto;
  }

  /* Hide desktop menu */
  .main-menu__nav,
  .main-menu__right .main-menu__list {
    display: none;
  }

  /* Show only hamburger */
  .main-menu__toggler {
    display: flex !important;
  }

  /* Footer stacked */
  .main-footer .row > [class*="col-"] {
    margin-bottom: var(--spacing-lg);
  }

  .main-footer__about,
  .main-footer__navmenu,
  .main-footer__newsletter {
    text-align: center;
  }

  .main-footer__social {
    justify-content: center;
  }

  /* Sections padding */
  section {
    padding: var(--spacing-xl) 0;
  }

  .pt-120, .pb-120 {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
  }

  /* Cards full width */
  .service-one__item,
  .course-one__item {
    margin-bottom: var(--spacing-md);
  }

  /* Buttons full width on mobile */
  .eduact-btn {
    width: 100%;
    text-align: center;
  }

  /* Forms */
  .form-group {
    margin-bottom: var(--spacing-sm);
  }

  /* Hide user display name on mobile */
  .mobile-user {
    display: none;
  }
}

/* Small devices (landscape phones, 576px to 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .container {
    max-width: 540px;
  }

  .main-menu__nav {
    display: none;
  }

  .main-menu__toggler {
    display: flex !important;
  }

  .main-footer .col-md-5,
  .main-footer .col-md-4 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* Medium devices (tablets, 768px to 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .container {
    max-width: 720px;
  }

  /* Show partial nav on tablets */
  .main-menu__nav .main-menu__list > li:nth-child(n+5) {
    display: none;
  }

  .main-menu__toggler {
    display: flex !important;
  }

  /* Footer 2 columns */
  .main-footer .col-xl-4 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .main-footer .col-xl-4:last-child {
    flex: 0 0 100%;
    max-width: 100%;
    margin-top: var(--spacing-lg);
  }
}

/* Large devices (desktops, 992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .container {
    max-width: 960px;
  }

  /* Show full nav */
  .main-menu__nav {
    display: flex;
  }

  /* Hide mobile toggler on desktop */
  .mobile-nav__toggler {
    display: none !important;
  }

  .main-menu__toggler {
    display: none !important;
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }

  /* Hide mobile elements */
  .mobile-nav__toggler,
  .main-menu__toggler {
    display: none !important;
  }

  .main-menu__nav {
    display: flex;
  }

  /* Larger spacing on desktop */
  section {
    padding: var(--spacing-xxl) 0;
  }
}

/* XXL devices (1400px and up) */
@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
}

/* ==========================================================================
   Image Optimization
   ========================================================================== */

/* Base image styles */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Fade-in effect for lazy loaded images */
img:not(.img-loaded) {
  opacity: 0;
  transition: opacity var(--transition-base);
}

img.img-loaded {
  opacity: 1;
}

/* Skip fade for critical images above the fold */
.hero-banner img,
.main-menu__logo img,
.main-footer__logo img {
  opacity: 1 !important;
}

/* Image containers with aspect ratio */
.img-wrapper {
  position: relative;
  overflow: hidden;
  background-color: var(--bg-light);
}

.img-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Common aspect ratios */
.img-wrapper--16x9 {
  padding-bottom: 56.25%;
}

.img-wrapper--4x3 {
  padding-bottom: 75%;
}

.img-wrapper--1x1 {
  padding-bottom: 100%;
}

.img-wrapper--3x2 {
  padding-bottom: 66.67%;
}

.img-wrapper--2x1 {
  padding-bottom: 50%;
}

/* Responsive image in card */
.card-img-wrapper {
  position: relative;
  overflow: hidden;
  background-color: var(--bg-light);
  padding-bottom: 66.67%; /* 3:2 aspect ratio */
}

.card-img-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.card-img-wrapper:hover img {
  transform: scale(1.05);
}

/* Category/Service image styles */
.service-one__item img,
.category-card img,
.course-one__item img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: var(--border-radius);
}

/* Testimonial images - circular */
.testimonial-one__author img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 50%;
}

/* Blog/Article images */
.blog-card__image,
.article-image {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius);
  background-color: var(--bg-light);
}

.blog-card__image img,
.article-image img {
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.blog-card__image:hover img,
.article-image:hover img {
  transform: scale(1.05);
}

/* Error handling for broken images */
.img-error {
  min-height: 100px;
  background-color: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-error::before {
  content: '';
  display: block;
}

.img-error-container {
  background-color: var(--bg-light);
  min-height: 100px;
}

/* Background images lazy loading */
[data-bg] {
  background-color: var(--bg-light);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg-loaded {
  background-color: transparent;
}

/* Thumbnail images */
.thumb,
.thumb--nest {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-sm);
}

/* Tests/Quiz images */
.tests-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: 0 auto;
}

/* Avatar/Profile images */
.avatar,
.profile-img,
.author-image {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

.avatar--lg {
  width: 80px;
  height: 80px;
}

.avatar--xl {
  width: 120px;
  height: 120px;
}

/* Logo responsive sizing */
.main-menu__logo img,
.main-footer__logo img,
.mobile-nav__wrapper .logo-box img {
  max-width: 160px;
  height: auto;
  width: auto;
}

/* Hero/Banner images */
.hero-banner__image,
.slider-image {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: cover;
}

/* Gallery images */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.gallery-item:hover img {
  transform: scale(1.1);
}

/* Image with overlay text */
.img-overlay {
  position: relative;
  overflow: hidden;
}

.img-overlay::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  pointer-events: none;
}

.img-overlay__content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--spacing-md);
  color: white;
  z-index: 1;
}

/* Responsive image grid */
.img-grid {
  display: grid;
  gap: var(--spacing-sm);
}

.img-grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.img-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.img-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 767.98px) {
  .img-grid--3,
  .img-grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 575.98px) {
  .img-grid--2,
  .img-grid--3,
  .img-grid--4 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .mobile-nav__wrapper,
  .scroll-top,
  .about-one__thumb__box,
  .main-menu__toggler,
  .search-popup {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* ==========================================================================
   Reduced Motion (Accessibility)
   ========================================================================== */

@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;
  }

  .wow {
    animation: none !important;
    visibility: visible !important;
  }
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  /* Users who prefer dark mode will see these styles */
  /* Uncomment to enable:
  :root {
    --bg-white: #1a1a2e;
    --bg-light: #16213e;
    --text-color: #e5e5e5;
    --text-light: #a5a5a5;
    --border-color: #2a2a4a;
  }
  */
}
