/* === Global Reset & Base === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: "Arial", sans-serif;
  background: #f9f9f9;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body.dark {
  background: #121212;
  color: #eaeaea;
}
body.dark header {
  border-bottom-color: #222;
}
body.dark nav ul li a {
  color: #eaeaea;
}
body.dark nav ul li a:hover,
body.dark nav ul li a.active {
  color: #ffd700;
  background: rgba(255,255,255,0.1);
}
body.dark footer {
  border-top-color: #222;
}

/* === Kenyan Flag Header === */
header {
  display: flex;
  align-items: center;
  justify-content: space-between; /* This pushes items to opposite sides */
  flex-wrap: wrap;
  padding: 10px 20px;
  background: linear-gradient(
    to right,
    #000000 33%,
    #ff0000 33%,
    #ff0000 66%,
    #006400 66%
  );
  border-bottom: 5px solid #ffffff;
  color: #fff;
  position: relative;
  min-height: 60px;
  gap: 15px;
}

/* Website Title on LEFT side */
.header-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
}

header h1 {
  margin: 0;
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
}

header .logo {
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Navigation and Menu Toggle on RIGHT side */
.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 15px;
}

/* === Navigation === */
nav {
  display: flex;
  align-items: center;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

nav ul li a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

nav ul li a i {
  font-size: 0.8rem;
  min-width: 16px;
  text-align: center;
}

nav ul li a:hover,
nav ul li a.active {
  color: #ffd700;
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

/* === Mobile Menu Toggle === */
.menu-toggle {
  display: none;
  font-size: 1.5rem;
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
  padding: 8px 12px;
  margin: 0;
  z-index: 1001;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.theme-toggle {
  font-size: 1rem;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.25);
}
body.dark .theme-toggle {
  background: rgba(255,255,255,0.1);
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #ffd700;
}

.menu-toggle:focus {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

/* === Mobile Responsive Layout === */
@media (max-width: 900px) {
  header {
    padding: 8px 15px;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  /* Left side - Website title */
  .header-left {
    flex: 1;
    justify-content: flex-start;
    order: 1;
  }

  /* Right side - Menu toggle */
  .header-right {
    justify-content: flex-end;
    order: 2;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
  }

  /* Navigation takes full width below header */
  nav {
    order: 3;
    width: 100%;
    margin-top: 0;
  }

  /* Mobile menu styles */
  nav ul {
    flex-direction: column;
    width: 100%;
    background: rgba(0, 0, 0, 0.98);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    margin: 0;
    padding: 0;
  }

  nav ul.open {
    max-height: calc(100vh - 60px) !important;
    height: calc(100vh - 60px) !important;
    overflow-y: auto !important; /* ✅ SCROLL ENABLED */
    -webkit-overflow-scrolling: touch; /* ✅ Smooth scroll on phones */
    padding: 0 !important;
    border-top: 3px solid #ffd700;
  }

  nav ul li {
    width: 100%;
    text-align: left;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
  }

  nav ul li:last-child {
    border-bottom: none;
  }

  nav ul li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    font-size: 0.95rem;
    min-height: 44px;
    white-space: nowrap;
    gap: 10px;
    transition: all 0.2s ease;
  }

  nav ul li a i {
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
  }

  /* Custom scrollbar */
  nav ul.open::-webkit-scrollbar {
    width: 4px;
  }

  nav ul.open::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
  }

  nav ul.open::-webkit-scrollbar-thumb {
    background: #ffd700;
    border-radius: 2px;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  header {
    padding: 6px 12px;
    min-height: 55px;
  }
  
  .header-left h1 {
    font-size: 1rem;
  }
  
  header .logo {
    height: 32px;
  }
  
  .menu-toggle {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }
  
  nav ul {
    top: 55px !important;
  }
  
  nav ul.open {
    max-height: calc(100vh - 55px) !important;
    height: calc(100vh - 55px) !important;
    overflow-y: auto !important; /* ✅ Scroll on very small screens too */
    -webkit-overflow-scrolling: touch;
  }
}

/* === Footer === */
footer {
  text-align: center;
  padding: 15px 10px;
  background: linear-gradient(
    to right,
    #000000 33%,
    #ff0000 33%,
    #ff0000 66%,
    #006400 66%
  );
  border-top: 5px solid #ffffff;
  color: #fff;
  font-size: 0.85rem;
}

footer p {
  margin: 0;
}

.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #006400;
  color: #fff;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 1200;
}
.back-to-top.show {
  display: flex;
}

/* Menu backdrop */
.menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  backdrop-filter: blur(3px);
}

/* Body scroll lock */
body.menu-open {
  overflow: hidden;
}
