/* === 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%;
}

/* === Kenyan Flag Header === */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: linear-gradient(
    to right,
    #000000 33%,
    #ff0000 33%,
    #ff0000 66%,
    #006400 66%
  );
  border-bottom: 5px solid #ffffff;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 70px;
  gap: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* 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(1rem, 3.5vw, 1.4rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

header .logo {
  height: 45px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  flex-shrink: 0;
}

/* Navigation and Menu Toggle on RIGHT side */
.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 15px;
}

/* === Desktop Navigation === */
nav {
  display: flex;
  align-items: center;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
}

nav ul li {
  margin: 0;
}

nav ul li a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
}

nav ul li a i {
  font-size: 0.85rem;
  min-width: 16px;
  text-align: center;
}

nav ul li a:hover,
nav ul li a.active {
  color: #ffd700;
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

nav ul li a.active {
  background: rgba(255, 215, 0, 0.15);
  border: 2px solid rgba(255, 215, 0, 0.3);
}

/* === Mobile Menu Toggle === */
.menu-toggle {
  display: none;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
  padding: 10px 14px;
  margin: 0;
  z-index: 1002;
  border-radius: 8px;
  transition: all 0.3s ease;
  width: 50px;
  height: 50px;
  display: none;
  align-items: center;
  justify-content: center;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #ffd700;
  transform: scale(1.05);
}

.menu-toggle:focus {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.menu-toggle:active {
  transform: scale(0.95);
}

/* === Tablet Responsive (Medium screens) === */
@media (max-width: 1100px) {
  nav ul {
    gap: 6px;
  }
  
  nav ul li a {
    font-size: 0.85rem;
    padding: 7px 12px;
    gap: 5px;
  }
  
  nav ul li a i {
    font-size: 0.8rem;
  }
}

/* === Mobile Responsive Layout === */
@media (max-width: 900px) {
  header {
    padding: 10px 15px;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    min-height: 65px;
  }

  /* Left side - Website title */
  .header-left {
    flex: 1;
    justify-content: flex-start;
    order: 1;
    min-width: 0;
  }

  header h1 {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
  }

  header .logo {
    height: 40px;
  }

  /* Right side - Menu toggle */
  .header-right {
    justify-content: flex-end;
    order: 2;
    flex-shrink: 0;
  }

  .menu-toggle {
    display: flex;
  }

  /* Hide desktop navigation */
  nav {
    order: 3;
    width: 100%;
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    z-index: 999;
  }

  /* Mobile menu styles */
  nav ul {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    background: linear-gradient(180deg, #000000 0%, #1a1a1a 100%);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    margin: 0;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    pointer-events: none;
  }

  nav ul.open {
    max-height: calc(100vh - 65px);
    height: calc(100vh - 65px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0 20px 0;
    border-top: 3px solid #ffd700;
    pointer-events: auto;
  }

  nav ul li {
    width: 100%;
    text-align: left;
    margin: 0;
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  nav ul.open li {
    opacity: 1;
    transform: translateX(0);
  }

  /* Stagger animation for menu items */
  nav ul.open li:nth-child(1) { transition-delay: 0.05s; }
  nav ul.open li:nth-child(2) { transition-delay: 0.1s; }
  nav ul.open li:nth-child(3) { transition-delay: 0.15s; }
  nav ul.open li:nth-child(4) { transition-delay: 0.2s; }
  nav ul.open li:nth-child(5) { transition-delay: 0.25s; }
  nav ul.open li:nth-child(6) { transition-delay: 0.3s; }
  nav ul.open li:nth-child(7) { transition-delay: 0.35s; }
  nav ul.open li:nth-child(8) { transition-delay: 0.4s; }
  nav ul.open li:nth-child(9) { transition-delay: 0.45s; }
  nav ul.open li:nth-child(10) { transition-delay: 0.5s; }
  nav ul.open li:nth-child(11) { transition-delay: 0.55s; }
  nav ul.open li:nth-child(12) { transition-delay: 0.6s; }
  nav ul.open li:nth-child(13) { transition-delay: 0.65s; }

  nav ul li:last-child {
    border-bottom: none;
  }

  nav ul li a {
    display: flex;
    align-items: center;
    padding: 16px 25px;
    font-size: 1rem;
    min-height: 55px;
    white-space: nowrap;
    gap: 12px;
    transition: all 0.3s ease;
    background: transparent;
  }

  nav ul li a:hover {
    background: rgba(255, 215, 0, 0.15);
    padding-left: 35px;
    transform: translateY(0);
  }

  nav ul li a.active {
    background: rgba(255, 215, 0, 0.2);
    border-left: 4px solid #ffd700;
  }

  nav ul li a i {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
  }

  /* Custom scrollbar for mobile menu */
  nav ul.open::-webkit-scrollbar {
    width: 6px;
  }

  nav ul.open::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
  }

  nav ul.open::-webkit-scrollbar-thumb {
    background: #ffd700;
    border-radius: 3px;
  }

  nav ul.open::-webkit-scrollbar-thumb:hover {
    background: #ffed4e;
  }
}

/* === Extra small devices === */
@media (max-width: 480px) {
  header {
    padding: 8px 12px;
    min-height: 60px;
  }
  
  .header-left h1 {
    font-size: 0.85rem;
    gap: 0.4rem;
  }
  
  header .logo {
    height: 35px;
  }
  
  .menu-toggle {
    width: 46px;
    height: 46px;
    font-size: 1.4rem;
    padding: 8px 10px;
  }
  
  nav {
    top: 60px;
  }
  
  nav ul {
    top: 60px;
  }
  
  nav ul.open {
    max-height: calc(100vh - 60px);
    height: calc(100vh - 60px);
  }

  nav ul li a {
    padding: 14px 20px;
    font-size: 0.95rem;
    min-height: 50px;
  }

  nav ul li a:hover {
    padding-left: 30px;
  }
}

/* === Very small devices === */
@media (max-width: 360px) {
  header h1 {
    font-size: 0.75rem;
  }
  
  header .logo {
    height: 30px;
  }
  
  .menu-toggle {
    width: 42px;
    height: 42px;
  }

  nav ul li a {
    font-size: 0.9rem;
    padding: 12px 18px;
  }
}

/* === Footer === */
footer {
  text-align: center;
  padding: 20px 15px;
  background: linear-gradient(
    to right,
    #000000 33%,
    #ff0000 33%,
    #ff0000 66%,
    #006400 66%
  );
  border-top: 5px solid #ffffff;
  color: #fff;
  font-size: 0.9rem;
  margin-top: 50px;
}

footer p {
  margin: 0;
}

/* Menu backdrop */
.menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 998;
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.menu-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Body scroll lock when menu is open */
body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Smooth transitions for all interactive elements */
a, button, input, select, textarea {
  transition: all 0.3s ease;
}

/* Focus styles for accessibility */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

/* Loading animation */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Ensure content doesn't jump when menu opens */
main, section {
  position: relative;
  z-index: 1;
}

/* Print styles */
@media print {
  header, footer, .menu-toggle, nav {
    display: none !important;
  }
}