/* Reset and basics */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Gradient Background for Page */
body {
  background: linear-gradient(135deg, #e0f7fa, #bbdefb, #90caf9);
  background-attachment: fixed;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* Header and Navbar Styles - Matched with about.css */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #333;
  padding: 15px 20px;
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease;
}

/* Logo Styles */
.logo {
  display: flex;
  align-items: center;
}

.logo img {
  height: 40px; /* Adjust based on your logo size */
  width: auto;
}

/* Navigation Links */
.navbar {
  display: flex;
  align-items: center;
}

.navbar ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar li {
  margin: 0 15px;
}

.navbar li:last-child {
  margin-right: 25px; /* Extra spacing for the last item to prevent edge proximity */
}

.navbar a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 1.1rem;
  padding: 8px 15px;
  border-radius: 20px;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
}

.navbar a:hover {
  color: #5efce8;
  background-color: rgba(255, 255, 255, 0.1);
}

.navbar a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  background: #5efce8;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  transition: width 0.3s ease;
}

.navbar a:hover::after {
  width: 80%;
}

.navbar .active a {
  color: #5efce8;
  background-color: rgba(255, 255, 255, 0.1);
}

.icon {
  margin-right: 8px;
}

/* Hamburger Menu for Mobile */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 21px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 3px;
  width: 100%;
  background-color: white;
  border-radius: 3px;
  transition: all 0.3s ease;
}

/* Admin Logout Button Styles within Navbar */
.admin-only {
  display: none; /* Hidden by default for non-admins */
}

.admin-only:not(.hidden) {
  display: block; /* Shown only when admin mode is active and hidden class is removed */
}

.admin-logout {
  background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 500;
  transition: background 0.3s, transform 0.2s;
}

.admin-logout:hover {
  background: linear-gradient(135deg, #ff8e53, #ff6b6b);
  transform: scale(1.05);
}

.admin-logout.hidden, .edit-text-btn.hidden {
  display: none;
}

/* Calendar Page Styles */
.calendar-wrapper {
  padding: 80px 20px; /* Adjusted for fixed navbar */
  max-width: 100vw;
  margin: 0 auto;
  min-height: calc(100vh - 80px); /* Ensure full height minus navbar */
  display: flex;
  justify-content: center;
}

.calendar-container {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  width: 100%;
  min-height: 100%; /* Ensure container takes full height */
  justify-content: center;
}

.calendar-panel {
  flex: 2;
  min-width: 300px;
  background: #fff;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  min-height: 100%; /* Ensure panel takes full height */
  box-sizing: border-box;
  overflow: visible; /* Allow content to expand */
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #f0f4f8, #e0e8f0);
  padding: 15px;
  border-radius: 8px;
}

.calendar-header button {
  background: none;
  border: none;
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  cursor: pointer;
  color: #555;
  transition: color 0.3s, transform 0.2s;
  padding: 5px 10px;
}

.calendar-header button:hover {
  color: #1e3a8a;
  transform: scale(1.1);
}

#month-year {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: #1e3a8a;
  font-weight: bold;
}

#date-search {
  width: 100%;
  max-width: 250px;
  padding: 12px;
  margin-bottom: 20px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1.1rem;
  background: #f9f9f9;
  cursor: pointer;
  transition: border-color 0.3s;
}

#date-search:focus {
  border-color: #61a5ff;
  outline: none;
}

#calendar {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow flex to handle height properly */
}

#calendar tbody {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Ensure tbody doesn't restrict height */
}

#calendar tr {
  flex: 1;
  display: flex;
  min-height: 0; /* Ensure rows scale with content */
}

#calendar th, #calendar td {
  padding: 10px;
  text-align: center;
  border: 2px solid #e0e0e0;
  font-weight: 500;
  transition: background 0.3s, transform 0.2s;
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 60px; /* Minimum height for cells */
}

#calendar th {
  background: linear-gradient(135deg, #1e3a8a, #3045c4);
  color: #fff;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 15px;
}

#calendar td {
  cursor: pointer;
  background: #f9f9f9;
  flex-direction: column;
  justify-content: flex-start;
}

#calendar td:hover {
  background: #eef2ff;
  transform: scale(1.02);
}

#calendar td.has-event {
  background: #e0f7fa;
  font-weight: bold;
  color: #1e3a8a;
}

#calendar td.has-event:hover {
  background: #b2ebf2;
}

.event-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  justify-content: center;
}

.event-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.event-panel {
  flex: 1;
  min-width: 300px;
  background: #fff;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: calc(100% - 40px);
  overflow-y: auto;
}

.event-panel.hidden {
  display: none;
}

.event-panel h2 {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  color: #1e3a8a;
  margin-bottom: 10px;
  font-weight: bold;
}

.user-view {
  flex: 1;
  overflow-y: auto;
  display: block; /* Ensure visibility */
  min-height: 100px; /* Provide minimum space for content */
}

.user-view h3 {
  font-size: 1.3rem;
  color: #333;
  margin-bottom: 8px;
  font-weight: bold;
  word-break: break-word; /* Prevent overflow of long titles */
}

.user-view p {
  font-size: 1.1rem;
  color: #555;
  line-height: 1.6;
  margin-bottom: 20px;
  word-break: break-word; /* Prevent overflow of long descriptions */
}

.event-item {
  margin-bottom: 20px;
  padding: 10px;
  border-left: 4px solid;
  background: #f9f9f9;
  border-radius: 5px;
  display: block; /* Ensure block display for content */
  width: 100%; /* Full width to avoid clipping */
}

.admin-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.admin-view input, .admin-view textarea, .admin-view select {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1.1rem;
  transition: border-color 0.3s;
}

.admin-view input:focus, .admin-view textarea:focus, .admin-view select:focus {
  border-color: #61a5ff;
  outline: none;
}

.admin-view textarea {
  min-height: 120px;
  resize: vertical;
}

.admin-view label {
  font-size: 1.1rem;
  color: #444;
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.admin-view button, .event-panel > button {
  padding: 12px 24px;
  background: linear-gradient(135deg, #61a5ff, #5efce8);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  font-size: 1.1rem;
  margin: 0 auto;
}

.admin-view button:hover, .event-panel > button:hover {
  background: linear-gradient(135deg, #5efce8, #61a5ff);
  transform: scale(1.05);
}

.admin-view.hidden {
  display: none;
}

#existing-events {
  flex: 1;
  overflow-y: auto;
  margin-top: 10px;
}

.existing-event-item {
  margin-bottom: 15px;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 5px;
  border-left: 4px solid;
}

.existing-event-item h4 {
  font-size: 1.1rem;
  margin-bottom: 5px;
  color: #333;
}

.existing-event-item p {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 10px;
}

.existing-event-item button {
  padding: 5px 10px;
  font-size: 0.8rem;
  margin-right: 5px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .calendar-container {
    flex-direction: column;
    gap: 25px;
    height: auto;
  }

  .calendar-header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  #date-search {
    max-width: 100%;
  }

  #calendar th, #calendar td {
    padding: 8px;
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    min-height: 50px;
  }

  .event-dots {
    gap: 3px;
  }

  .event-dot {
    width: 8px;
    height: 8px;
  }

  .calendar-panel {
    min-width: 100%;
    height: auto;
    padding: 15px; /* Reduced padding for smaller screens */
    min-height: auto; /* Override for mobile to avoid forced height */
  }

  .event-panel {
    height: auto;
    padding: 15px;
    min-height: 200px; /* Ensure enough space for content */
  }

  .event-panel h2 {
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  }

  .user-view {
    min-height: 150px; /* Adjust for mobile to ensure visibility */
    overflow-y: auto;
  }

  .user-view h3 {
    font-size: clamp(1.1rem, 2.2vw, 1.2rem);
    margin-bottom: 5px;
  }

  .user-view p {
    font-size: clamp(0.9rem, 2vw, 1rem);
    margin-bottom: 10px;
  }

  .event-item {
    margin-bottom: 15px;
    padding: 8px;
  }

  .admin-view input, .admin-view textarea, .admin-view select {
    padding: 10px;
    font-size: clamp(0.9rem, 2vw, 1rem);
  }

  .admin-view button, .event-panel > button {
    padding: 10px 20px;
    font-size: clamp(0.9rem, 2vw, 1rem);
  }

  .nav-toggle {
    display: flex;
    z-index: 1001;
  }

  .navbar ul {
    display: none;
    position: absolute;
    top: 70px;
    right: 0;
    background-color: #333;
    width: 100%;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.3s ease;
  }

  .navbar ul.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
  }

  .navbar li {
    margin: 15px 0;
    width: 100%;
    text-align: center;
  }

  .navbar li:last-child {
    margin-right: 0; /* Reset extra margin on mobile for centered alignment */
  }

  .navbar a, .admin-logout {
    padding: 10px 20px;
    display: block;
  }
}

@media (max-width: 480px) {
  #calendar th, #calendar td {
    padding: 5px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    min-height: 40px;
  }

  .event-dots {
    gap: 2px;
  }

  .event-dot {
    width: 6px;
    height: 6px;
  }

  .calendar-wrapper {
    padding: 70px 10px;
  }

  .calendar-header {
    padding: 10px;
  }

  .event-panel {
    padding: 10px;
    min-height: 250px; /* Provide more space for smaller screens */
  }

  .user-view {
    min-height: 120px; /* Adjust for very small screens */
  }

  .event-panel h2 {
    font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  }

  .admin-view input, .admin-view textarea, .admin-view select {
    padding: 8px;
    font-size: clamp(0.85rem, 1.8vw, 0.95rem);
  }

  .admin-view button, .event-panel > button {
    padding: 8px 16px;
    font-size: clamp(0.85rem, 1.8vw, 0.95rem);
  }
}

/* Navbar scroll effect */
.header.scrolled {
  background-color: rgba(51, 51, 51, 0.95);
}