:root {
  --hover-color: #f7a922; /* Golden accent color */
  --bg-primary: #f5f5f5; /* Light gray background */
  --bg-secondary: #fff; /* White */
  --text-primary: #333; /* Dark gray */
  --text-secondary: #777; /* Medium gray for secondary text */
  --text-tertiary: #999; /* Light gray for tertiary text */
  --header-bg: #444; /* For card headers */
  --border-color: #eee; /* For borders */
  --alert-bg: #fff3cd; /* For alerts/notifications */
  --alert-text: #856404; /* For alert text */
  --shadow-normal: 0 3px 10px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 5px 15px rgba(0, 0, 0, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #f5f5f5;
}

#about-popup {
  display: none;
}

/* Header & Logo */
header {
  height: 10vh;
  background-color: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 4;
}

.header-container {
  width: 95%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 2rem;
  font-weight: bold;
  /* Set a minimum width to prevent squeezing */
  min-width: 100px;
  flex-shrink: 0;
}

.logo a {
  text-decoration: none;
  color: var(--hover-color);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.logo img {
  max-width: 100%;
  height: 75px;
  display: block;
}

.header-container {
  display: flex;
  align-items: center;
  min-height: 60px;
}

/* Menu Toggle */
.menu-toggle {
  display: none;
}

.menu-toggle-label {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 21px;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.menu-toggle-label span {
  display: block;
  width: 100%;
  height: 3px;
  background-color: var(--hover-color);
  transition: all 0.3s ease-in-out;
}

/* Menu Styles */
.menu-group {
  /* Give the menu group a fixed width ratio */
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-items {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.menu-link {
  color: var(--bg-primary);
  text-decoration: none;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.menu-link:hover {
  background-color: var(--alert-text);
}

.user-menu {
  margin-left: 1rem;
}

/* Login/Logout Buttons */
.login.button,
.logout-button {
  background-color: var(--hover-color);
  border: none;
  color: #fff;
  height: 40px;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 1rem;
  border-radius: 4px;
  transition: background-color 0.3s ease;
  /* Fixed width for login button */
  width: auto;
  max-width: 150px;
  margin-left: 1rem;
  flex-shrink: 0;
  justify-content: center;
}

.login.button:hover,
.logout-button:hover {
  background-color: var(--text-primary);
}

.logout-button img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

/* Footer */
footer {
  height: 10vh;
  background-color: var(--header-bg);
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 4;
}

.footer-container {
  width: 95%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin: 0 auto;
}

.footer-text {
  color: var(--bg-secondary);
  text-align: center;
}

.footer-text-brand {
  display: flex;
  justify-content: flex-start;
  width: auto;
  color: var(--text-tertiary);
  font-weight: bold;
}

.social-icons {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}

.social-icon {
  color: var(--text-tertiary);
  transition: color 0.2s ease;
}

.social-icon:hover {
  color: var(--text-tertiary);
}

.social-icon:hover svg path {
  color: #1da1f2;
}

.social-icon:nth-child(2):hover svg path,
.social-icon:nth-child(2):hover svg rect,
.social-icon:nth-child(2):hover svg line {
  color: #e1306c;
}

/* Remove the specific fix for 769-863px range as we're fixing the root cause */

/* Global Custom Alert Styles */
.custom-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.custom-alert-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Note History Styles */
.note-history-item {
  background-color: #f9f9f9;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.note-date {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.note-type {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.note-type.monthly {
  background-color: #e3f2fd;
  color: #1976d2;
}

.note-type.payment {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.note-content {
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  white-space: pre-wrap;
}

.custom-alert {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 20px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: translateY(-20px);
  transition: transform 0.3s;
}

.custom-alert-overlay.show .custom-alert {
  transform: translateY(0);
}

.custom-alert-icon {
  margin-bottom: 15px;
  font-size: 48px;
  line-height: 1;
}

.custom-alert-icon.success {
  color: var(--primary);
}

.custom-alert-icon.error {
  color: #e74c3c;
}

.custom-alert-icon.info {
  color: #3498db;
}

.custom-alert-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
}

.custom-alert-message {
  margin-bottom: 20px;
  color: #555;
}

.custom-alert-button {
  background-color: #2e7d32; /* Fallback if CSS variable doesn't work */
  background-color: var(--primary, #2e7d32);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-block;
  min-width: 100px;
  text-align: center;
}

.custom-alert-button:hover {
  background-color: #1b5e20; /* Darker green fallback */
  background-color: var(--primary-dark, #1b5e20);
}

/* Popup Styling - Global */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* Higher z-index to ensure it appears above everything */
}

.popup-content {
  background: var(--bg-secondary);
  padding: 30px;
  width: 90%;
  max-width: 600px;
  border-radius: 10px;
  box-shadow: var(--shadow-hover);
  text-align: left;
  position: relative; /* Keep relative for the close button positioning */
  animation: fadeIn 0.3s ease-in-out;
  color: var(--text-primary);
  max-height: 80vh;
  overflow-y: auto;
  /* Remove any margin that might offset the centering */
  margin: 0;
}

body.popup-open {
  overflow: hidden;
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  font-weight: bold;
  color: var(--text-primary);
  cursor: pointer;
  transition: color 0.2s ease;
}

.popup-close:hover {
  color: var(--hover-color);
}

#about-content {
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.8;
  padding: 10px 0;
}

#about-content a {
  color: var(--hover-color);
  text-decoration: underline;
  font-weight: bold;
}

#about-content a:hover {
  opacity: 0.8;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile and Tablet Styles - Increased breakpoint to prevent menu overflow */
@media screen and (max-width: 1100px) {
  .menu-toggle-label {
    display: flex;
  }

  /* Special handling for logged-out menu in mobile */
  body:not(.logged-in) .menu-group {
    position: static; /* Keep the menu visible for logged-out users */
    width: auto;
    padding: 0;
    background-color: transparent;
  }

  /* Regular mobile menu behavior for logged-in users */
  body.logged-in .menu-group {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background-color: var(--header-bg);
    padding: 6rem 2rem 2rem;
    transition: right 0.3s ease;
    z-index: 5;
  }

  /* Menu Toggle Animation - only for logged-in users */
  body.logged-in .menu-toggle:checked ~ .menu-group {
    right: 0;
  }

  .menu-toggle:checked ~ .menu-toggle-label span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .menu-toggle:checked ~ .menu-toggle-label span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle:checked ~ .menu-toggle-label span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
  }

  /* For logged-out users, keep horizontal layout */
  body:not(.logged-in) .nav-menu {
    flex-direction: row;
    align-items: center;
  }

  /* For logged-in users, use column layout */
  body.logged-in .nav-menu {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 1rem;
    width: 100%;
  }

  body.logged-in .menu-items {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0.5rem;
  }

  .menu-link {
    width: 100%;
    padding: 0.75rem 1rem;
  }

  .user-menu {
    margin-left: 0;
    margin-top: 1rem;
    width: 100%;
  }

  /* Fix login button in mobile */
  .login.button {
    width: auto;
    min-width: 100px;
    justify-content: center;
    margin-left: 0.5rem;
  }

  /* Fix logout button in mobile - ensure it's not shrunk */
  .logout-button {
    width: 100%;
    max-width: none;
    justify-content: flex-start;
    margin-left: 0;
  }

  /* Make sure logout text is visible */
  .logout-button span {
    display: inline-block;
    margin-left: 0.5rem;
  }

  /* Footer mobile fixes */
  .footer-container {
    gap: 1rem;
  }

  .footer-text-brand {
    font-size: 0.9rem;
  }

  .social-icons {
    gap: 12px;
  }

  /* Ensure logo remains visible on small screens */
  .logo {
    max-width: 40%;
  }

  .logo img {
    height: auto;
    max-height: 60px;
  }
}

@media screen and (max-width: 768px) {
  .popup-content {
    width: 90%;
    max-width: 90%;
    padding: 20px;
  }
}

/* 404 Page Container */
.error-404-container {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--text-tertiary);
  padding: 20px;
}

/* Bouncing 404 Code */
.error-code {
  font-size: 8rem;
  color: var(--hover-color);
  margin: 0;
  animation: bounce 2s infinite;
}

/* Error Message */
.error-message {
  font-size: 1.5rem;
  color: var(--bg-secondary);
  margin: 20px 0;
  line-height: 1.4;
}
