/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
  --primary-color: #2563eb;
  --secondary-color: #1e40af;
  --accent-color: #3b82f6;
  --dark-color: #0f172a;
  --light-color: #f8fafc;
  --gray-color: #94a3b8;
  --transition: all 0.3s ease;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --font-family: 'Poppins', sans-serif;
}

/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--light-color);
  color: var(--dark-color);
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.section-title {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 3rem;
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: var(--primary-color);
  border-radius: 2px;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.primary-btn {
  background: var(--primary-color);
  color: white;
}

.primary-btn:hover {
  background: var(--secondary-color);
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3);
}

.secondary-btn {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.secondary-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3);
}

/* ===== Header & Navigation ===== */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
}

.nav-logo h2 {
  color: var(--primary-color);
  font-size: 1.6rem;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 1.5rem;
}

.nav-menu a {
  text-decoration: none;
  color: var(--dark-color);
  font-weight: 500;
  transition: var(--transition);
  padding: 0.3rem 0;
  display: inline-block;
}

/* Hide icons in desktop view, keep them in mobile */
@media screen and (min-width: 769px) {
  .nav-menu a i {
    display: none;
  }
}

.nav-menu a:hover {
  color: var(--primary-color);
}

.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
}

.bar {
  width: 25px;
  height: 3px;
  background: var(--dark-color);
  margin: 3px 0;
  transition: var(--transition);
}

/* ===== Hero Section ===== */
.hero {
  padding: 10rem 0 5rem;
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.hero .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.hero-content {
  flex: 1;
}

.hero-content h1 {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.hero-content h1 .highlight {
  color: var(--primary-color);
}

.hero-content h2 {
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
}

.hero-content p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  color: var(--gray-color);
}

.hero-btns {
  display: flex;
  gap: 1rem;
}

.hero-img {
  flex: 1;
  display: flex;
  justify-content: center;
}

.hero-img img {
  width: 100%;
  max-width: 400px;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

/* ===== About Section ===== */
.about {
  padding: 5rem 0;
}

.about-content {
  display: flex;
  flex-wrap: wrap;
  gap: 3rem;
  align-items: center;
}

.about-text {
  flex: 1;
  min-width: 300px;
}

.about-text p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  color: var(--gray-color);
}

.about-stats {
  flex: 1;
  min-width: 300px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem;
  text-align: center;
}

.stat-item h3 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.stat-item p {
  font-size: 1.1rem;
  color: var(--dark-color);
  font-weight: 500;
}

/* ===== Skills Section ===== */
.skills {
  padding: 5rem 0;
  background: #f1f5f9;
}

.skills-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 3rem;
}

.skill-category {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.skill-category h3 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
}

.skill-item {
  margin-bottom: 1.5rem;
}

.skill-item:last-child {
  margin-bottom: 0;
}

.skill-item h4 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.skill-item h4 i {
  margin-right: 0.5rem;
  width: 20px;
  text-align: center;
  color: var(--primary-color);
}

.skill-bar {
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
    margin-bottom: 15px;
}

.skill-progress {
    height: 100%;
    background: var(--primary-color);
    border-radius: 5px;
    position: relative;
    width: 0%;
    transition: width 1.2s ease;
    
    /* Gradient background */
    background-image: linear-gradient(90deg, var(--primary-color) 0%, #4f83ff 50%, var(--primary-color) 100%);
    background-size: 200% 100%;
}

/* Fallback to ensure bars are visible even without JS */
.skill-progress[data-progress="90"] {
    width: 90%;
}
.skill-progress[data-progress="85"] {
    width: 85%;
}
.skill-progress[data-progress="80"] {
    width: 80%;
}
.skill-progress[data-progress="75"] {
    width: 75%;
}
.skill-progress[data-progress="60"] {
    width: 60%;
}

/* Apply animations to filled bars - animations removed */
.skill-progress.filled {
    /* animation: progressShimmer 2.5s linear infinite; */
}


/* ===== Languages Section ===== */
.languages {
  padding: 5rem 0;
  background: #f1f5f9;
}

.languages-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.language-item {
  background: white;
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.language-item h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}
.language-item h3 img {
  width: 1.5rem;
  vertical-align: middle;
  margin-right: 0.5rem;
  display: inline-block;
}
.language-item h3 img {
  width: 1.5rem;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.language-item p {
  color: var(--gray-color);
  margin-bottom: 1rem;
}

.language-item p {
  color: var(--gray-color);
  font-size: 1.1rem;
}

/* ===== Experience Section ===== */
.experience {
  padding: 5rem 0;
}

.timeline {
  position: relative;
}

/* Align the blue circle with the vertical timeline line */
/* .timeline-content::before {
  left: -10px;
} */

/* Mobile adjustments – keep the circle slightly left of the content */
@media screen and (max-width: 992px) {
  .timeline-content::before {
    left: -30px;
    transform: none;
    top: 0;
  }
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 100%;
  background: var(--primary-color);
}

.timeline-item {
  display: flex;
  margin-bottom: 3rem;
}

.timeline-date {
  flex: 1;
  text-align: right;
  padding-right: 3rem;
  padding-left: 1rem;
}

.timeline-date h3 {
  color: var(--primary-color);
  font-size: 1.2rem;
}

.timeline-content {
  flex: 1;
  padding-left: 2rem;
  position: relative;
}

/* Position the blue circle exactly on the vertical timeline line */
/* .timeline-content::before { */
  /* left: -2.5rem; Align with the left edge of the content (the line) */
/* } */

/* .timeline-content::before {
  content: '';
  position: absolute;
  top: 8px; */
  /* left: -1.65rem; Align with the vertical line regler */
  /*left: -2rem;*/ /* Align with the vertical line */ /*original*/
  /* width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
} */

/* Le point bleu, centré sur la ligne (desktop) */
.timeline-item { 
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  top: 8px;                 /* ajuste verticalement le point */
  left: 50%;                /* même repère que la ligne */
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  z-index: 1;
}


.timeline-content h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.timeline-content h4 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.timeline-content p {
  color: var(--gray-color);
}

/* ===== Education Section ===== */
.education {
  padding: 5rem 0;
  background: #f1f5f9;
}

.education-content {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.education-item {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.education-item h3 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.education-item h4 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.education-item h5 {
  color: var(--gray-color);
  margin-bottom: 1rem;
}

.education-item p {
  color: var(--gray-color);
}

/* ===== Projects Section ===== */
.projects {
  padding: 5rem 0;
}

.projects-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.project-card {
  background: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.project-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.project-img {
  height: 200px;
  overflow: hidden;
}

.project-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.project-card:hover .project-img img {
  transform: scale(1.1);
}

.project-info {
  padding: 1.5rem;
}

.project-info h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.project-info p {
  color: var(--gray-color);
  margin-bottom: 1.5rem;
}

.project-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===== Contact Section ===== */
.contact {
  padding: 5rem 0;
  background: #f1f5f9;
}

.contact-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 3rem;
}

.contact-info h3 {
  font-size: 1.8rem;
  margin-bottom: 2rem;
  color: var(--primary-color);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.contact-item i {
  color: var(--primary-color);
  font-size: 1.2rem;
}

.social-links {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  transition: var(--transition);
}

.social-links a:hover {
  background: var(--secondary-color);
  transform: translateY(-3px);
}

.contact-form h3 {
  font-size: 1.8rem;
  margin-bottom: 2rem;
  color: var(--primary-color);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 1rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-group textarea {
  resize: none; /* Prevent resizing of textarea */
}

/* ===== Project Summary Modal ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 2rem;
  border: 1px solid #888;
  border-radius: var(--border-radius);
  width: 80%;
  max-width: 600px;
  box-shadow: var(--shadow);
  position: relative;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  position: absolute;
  top: 10px;
  right: 15px;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

#modalTitle {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

#modalSummary {
  color: var(--dark-color);
  line-height: 1.6;
}

/* ===== Footer ===== */
footer {
  background: var(--dark-color);
  color: white;
  padding: 2rem 0;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: white;
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary-color);
}

/* ===== Responsive Design ===== */
@media screen and (max-width: 992px) {
  .hero-content h1 {
    font-size: 3rem;
  }
  
   .timeline::before {
    left: 30px;
    transform: none;
  }

  /* On enlève la marge qui décale l'item et on met un padding interne */
  .timeline-item {
    flex-direction: column;
    margin-left: 0;         /* ← au lieu de 30px */
    padding-left: 60px;     /* espace pour le texte sans décaler le repère */
  }

  .timeline-date {
    text-align: left;
    padding-right: 0;
    padding-bottom: 1rem;
    padding-left: 0;        /* plus besoin de 3rem */
  }

  .timeline-content {
    padding-left: 0;
    padding-top: 1rem;
  }

  /* Le point pile sur la ligne (même repère 30px) */
  .timeline-item::before {
    left: 31px !important;
    transform: translateX(-50%);
    top: 0;
  }

  /* .timeline-content::before {  
    left: -2px;
    top: 0;
  } */
}

@media screen and (max-width: 768px) {
  .hamburger {
    display: flex;
  }
  
  .nav-menu {
    position: fixed;
    left: -100%;
    top: 0;
    flex-direction: column;
    background-color: white;
    width: 70%;
    text-align: left;
    transition: 0.3s;
    box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    height: 100vh;
    justify-content: flex-start;
  }
  
  .nav-menu.active {
    left: 0;
  }
  
  .nav-menu li {
    margin: 0.5rem 0;
    text-align: left;
    padding-left: 0.1rem;
    position: relative;
  }
  
  .nav-menu li::before {
    content: "";
  }
  
  .hero .container {
    flex-direction: column;
    text-align: center;
  }
  
  .hero-btns {
    justify-content: center;
  }
  
  .about-content {
    flex-direction: column;
  }
  
  .hero-content h1 {
    font-size: 2.5rem;
  }
  
  .section-title {
    font-size: 2rem;
  }
}

@media screen and (max-width: 576px) {
  .hero {
    padding: 8rem 0 3rem;
  }
  
  .hero-content h1 {
    font-size: 2rem;
  }
  
  .hero-content h2 {
    font-size: 1.5rem;
  }
  
  .hero-btns {
    flex-direction: column;
    align-items: center;
  }
  
  .btn {
    width: 100%;
    max-width: 200px;
  }
  
  .project-links {
    flex-direction: column;
  }
  
  .project-links .btn {
    width: 100%;
  }
}
/* Overlay behind the mobile menu */
.nav-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* ensure hidden overlay never intercepts taps/clicks */
  transition: opacity .2s ease, visibility .2s ease;
  z-index: 999; /* under the menu, above page content */
}

/* Show overlay when menu is open */
.nav-overlay.show{
  opacity: 1;
  visibility: visible;
  pointer-events: auto; /* interactive only when visible */
}

/* Prevent scrolling behind the open menu */
body.no-scroll{
  overflow: hidden;
}

/* Ensure the menu appears above the overlay on mobile */
@media (max-width: 768px){
  .nav-menu{ z-index: 1000; }
}
/* Animation de remplissage des barres (restaurée) */
.skill-progress {
  width: 0;
  transition: width 1.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .skill-progress {
    transition: none;
  }
}
/* ===== Decorative, subtle animations (with reduced-motion support) ===== */

/* Navbar link underline grow */
.nav-menu a {
  position: relative;
}
.nav-menu a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: var(--primary-color);
  transition: width .25s ease;
}
.nav-menu a:hover::after {
  width: 100%;
}

/* Hero image gentle float */
.hero-img img {
  animation: floatY 6s ease-in-out infinite;
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Timeline dot pulse (soft) */
.timeline-item::before {
  animation: pulseDot 2.2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35); }
  70%  { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* Shimmer animation - removed */
.skill-progress.filled {
    /* animation: progressShimmer 2.5s linear infinite; */
}

/* Pulse glow effect - removed */
.skill-progress.filled::after {
    /* content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: translateX(-100%);
    animation: progressPulse 2s ease-in-out infinite; */
}

@keyframes progressShimmer {
    0%   { background-position: 0% 0; }
    100% { background-position: -200% 0; }
}

@keyframes progressPulse {
    0% { transform: translateX(-100%); }
    50%, 100% { transform: translateX(100%); }
}

/* Fallback styles to ensure visibility */
.skill-progress[data-progress="90"] { width: 90%; }
.skill-progress[data-progress="85"] { width: 85%; }
.skill-progress[data-progress="80"] { width: 80%; }
.skill-progress[data-progress="75"] { width: 75%; }
.skill-progress[data-progress="60"] { width: 60%; }

/* Reveal children (skills items and projects) when section gets .animated */
.skills .skill-item,
.projects .project-card {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s ease, transform .6s ease;
}
.skills.animated .skill-item,
.projects.animated .project-card {
  opacity: 1;
  transform: none;
}
/* Staggered delays for a nicer cascade */
.skills .skill-item:nth-child(1),
.projects .project-card:nth-child(1) { transition-delay: .05s; }
.skills .skill-item:nth-child(2),
.projects .project-card:nth-child(2) { transition-delay: .12s; }
.skills .skill-item:nth-child(3),
.projects .project-card:nth-child(3) { transition-delay: .19s; }
.skills .skill-item:nth-child(4),
.projects .project-card:nth-child(4) { transition-delay: .26s; }
.skills .skill-item:nth-child(5),
.projects .project-card:nth-child(5) { transition-delay: .33s; }
.skills .skill-item:nth-child(6),
.projects .project-card:nth-child(6) { transition-delay: .40s; }

/* Reduced motion: disable decorative animations */
@media (prefers-reduced-motion: reduce) {
  .hero-img img,
  .timeline-item::before,
  .skill-progress.filled {
    animation: none !important;
  }
  .skills .skill-item,
  .projects .project-card {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
/* ===== Hero Typewriter (visual layer + cursor) ===== */
.hero-content h1 {
  position: relative;
}
.hero-content h1.is-typing {
  color: transparent; /* keep text in DOM for SEO/AT, hide visually during typing */
}
.typewriter-overlay {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--dark-color); /* visible typed text */
  font: inherit;
  line-height: inherit;
  white-space: pre-wrap;
  pointer-events: none;
}
.typewriter-overlay .highlight {
  color: var(--primary-color);
}
.typewriter-overlay .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--primary-color);
  margin-left: 2px;
  vertical-align: -0.1em;
  animation: cursor-blink 1s steps(1) infinite;
}
@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
/* Reduced motion: no typing, no cursor animation (JS returns early) */
@media (prefers-reduced-motion: reduce) {
  .typewriter-overlay .cursor {
    animation: none !important;
  }
}
/* ===== Chat FAB + Popup (prefixed chat-) ===== */

/* Visually hidden (for a11y labels) */
.chat-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Floating Action Button (FAB) */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; /* remove iOS tap flash */
  touch-action: manipulation; /* reduce click delay and prevent gesture conflicts */
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease;
  z-index: 998; /* above content, below nav overlay (999) */
}
.chat-fab i {
  font-size: 22px;
  line-height: 1;
}
.chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
  background: var(--secondary-color);
}
.chat-fab:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}
.chat-fab:focus-visible {
  outline: 3px solid rgba(37,99,235,.35);
  outline-offset: 3px;
}

/* Mobile: anchor FAB on the left */
@media (max-width: 768px) {
  .chat-fab {
    right: auto;
    left: 24px;
  }
}

/* Dedicated chat overlay (distinct from navbar overlay) */
.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
  z-index: 1002; /* above navbar/menu/its overlay and project modal (1001) */
}
.chat-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Chat popup container (dialog) */
.chat-popup {
  position: fixed;
  /* sit above FAB by ~16px (60px FAB height + 24px bottom + 16px gap) */
  bottom: calc(24px + 60px + 16px);
  right: 24px;
  width: 400px;
  max-width: 95vw;
  height: 66vh;
  max-height: 720px;
  background: #fff;
  color: var(--dark-color);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1003;
  /* hidden by default via aria-hidden */
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

/* Show when aria-hidden="false" */
.chat-popup[aria-hidden="false"] {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Mobile positioning: anchor left and use ~95% width */
@media (max-width: 768px) {
  .chat-popup {
    right: auto;
    left: 2.5vw;
    width: 95vw;
    bottom: calc(24px + 60px + 16px);
    height: 65vh;
  }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: #fff;
}
.chat-header h2 {
  font-size: 1.1rem;
  color: var(--dark-color);
}
.chat-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--dark-color);
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease;
}
.chat-close:hover {
  background: rgba(0,0,0,.06);
}
.chat-close:active {
  transform: scale(.98);
}
.chat-close:focus-visible {
  outline: 3px solid rgba(37,99,235,.35);
  outline-offset: 2px;
}

/* Body (messages area) */
.chat-body {
  flex: 1 1 auto;
  padding: 12px;
  overflow: auto;
  background: #f7f9fc;
}

/* Message bubbles */
.chat-msg {
  display: flex;
  margin: 8px 0;
}
.chat-msg .chat-bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  font-size: .95rem;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-msg--bot {
  justify-content: flex-start;
}
.chat-msg--bot .chat-bubble {
  background: #eef2ff; /* light primary-ish */
  color: #111827;
  border-top-left-radius: 6px;
}
.chat-msg--user {
  justify-content: flex-end;
}
.chat-msg--user .chat-bubble {
  background: var(--primary-color);
  color: #fff;
  border-top-right-radius: 6px;
}

/* Footer (composer) */
.chat-footer {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(0,0,0,.06);
  background: #fff;
}
.chat-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.chat-input::placeholder {
  color: #9ca3af;
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}
.chat-send {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--primary-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 40px;
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.chat-send i {
  font-size: 16px;
}
.chat-send:hover {
  background: var(--secondary-color);
  box-shadow: 0 6px 16px rgba(37,99,235,.22);
}
.chat-send:active {
  transform: translateY(0);
  box-shadow: none;
}
.chat-send:focus-visible {
  outline: 3px solid rgba(37,99,235,.35);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .chat-fab,
  .chat-overlay,
  .chat-popup,
  .chat-close,
  .chat-input,
  .chat-send {
    transition: none !important;
  }
}
/* ===== iOS-safe Chat Modal Portal (Chrome iOS fix) ===== */

/* Lock background scroll when chat is open */
html.chat-open,
html.chat-open body {
  overflow: hidden;
  height: 100%;
}

/* Fullscreen fixed portal that covers the whole viewport (iOS-safe) */
#chat-modal {
  position: fixed;
  inset: 0;
  height: var(--vvh, 100dvh); /* fixes Safari/iOS viewport issue vs 100vh */
  z-index: 2147483647; /* on top of everything */
  -webkit-overflow-scrolling: touch;
  display: block; /* hidden is controlled by [hidden] attribute */
  background: transparent; /* overlay provided below */
}

/* Hide portal when [hidden] is set (HTML attribute) */
#chat-modal[hidden] {
  display: none !important;
}

/* Optional overlay dim behind the chat window */
#chat-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.25);
}

/* Chat window pane anchored bottom-right inside the portal */
#chat-window {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  max-height: 90%;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  overflow: hidden;
}

/* Mobile: take full width for better usability */
@media (max-width: 768px) {
  #chat-window {
    width: 100%;
  }
}

/* When .chat-popup is inside #chat-window, override fixed positioning and hidden defaults */
#chat-window .chat-popup {
  position: relative;       /* was fixed; make it container-based */
  bottom: auto;
  right: auto;
  width: 100%;
  height: auto;
  max-height: none;
  opacity: 1;               /* visible (portal visibility handled by #chat-modal[hidden]) */
  transform: none;
  pointer-events: auto;
  box-shadow: none;         /* shadow is on #chat-window */
  border-radius: 0;         /* radius is on #chat-window */
}
/* ===== Chat keyboard-aware responsive sizing (fills remaining height when keyboard is open) ===== */

/* Ensure the chat window can size its child via flex */
#chat-window {
  display: flex;
  flex-direction: column;
  height: min(66vh, var(--vvh, 100dvh));
}

/* On mobile, make the chat window take the full dynamic viewport height (portal is 100dvh) */
@media (max-width: 768px) {
  #chat-window {
    height: 100%;
    max-height: 100%;
  }
}

/* Make the internal chat container fill its parent and lay out header/body/footer via flex */
#chat-window .chat-popup {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Message area grows to fill the space between header and footer; scroll is smooth and isolated */
.chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0; /* important for nested flex containers to allow shrinking */
}