:root {
  --primary-color: #0abab5;
  --secondary-color: #56dfcf;
  --accent-color: #adeed9;
  --background-color: #ffedf3;
  --text-color: #2c3e50;
  --card-background: #fff;
  --input-background: #ecf0f1;
  --border-color: #bdc3c7;
  --error-color: #e74c3c;
  --success-color: #2ecc71;
  --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --primary-color: #56dfcf;
  --secondary-color: #0abab5;
  --accent-color: #adeed9;
  --background-color: #1a1a1a;
  --text-color: #f5f5f5;
  --card-background: #2c3e50;
  --input-background: #34495e;
  --border-color: #7f8c8d;
  --error-color: #e74c3c;
  --success-color: #2ecc71;
  --shadow-color: rgba(0, 0, 0, 0.5);
}

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

html {
  font-size: 16px; /* Base font size */
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  flex-grow: 1;
  width: 90%;
}

/* --- Navbar --- */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--card-background);
  box-shadow: 0 2px 10px var(--shadow-color);
  position: relative;
  flex-wrap: wrap;
  /* gap: 250px; */
}

.logo {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--primary-color);
  text-decoration: none;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.hamburger-menu {
  display: none; /* Hidden by default on desktop */
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  cursor: pointer;
}
.close-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  cursor: pointer;
  position: absolute;
  top: 1rem;
  right: 2rem;
  z-index: 1000;
}

.nav-links-container {
  display: flex;
  align-items: center;
  flex-grow: 1;
  justify-content: space-around;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}
.nav-links a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}
.nav-links a:hover {
  color: var(--primary-color);
}

.nav-auth-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.3s;
}
.theme-toggle:hover {
  color: var(--primary-color);
}

.button {
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: all 0.3s;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button {
  background-color: var(--primary-color);
  color: white;
  border: 2px solid var(--primary-color);
}
.primary-button:hover {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  box-shadow: 0 4px 8px var(--shadow-color);
}

.secondary-button {
  background-color: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}
.secondary-button:hover {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 8px var(--shadow-color);
}

.large {
  font-size: 1.2rem;
  padding: 1rem 2rem;
}

.hidden {
  display: none !important;
}

/* --- Hero Section --- */
.hero-section {
  text-align: center;
  padding: 8rem 2rem;
}
.hero-section h1 {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}
.hero-section p {
  font-size: 1.2rem;
  margin-bottom: 2.5rem;
}

/* --- Forms --- */
.form-card {
  background-color: var(--card-background);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 20px var(--shadow-color);
  max-width: 450px;
  margin: 5rem auto;
  width: 90%;
}
.form-card h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary-color);
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: bold;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--input-background);
  color: var(--text-color);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 5px var(--accent-color);
}
.password-group {
  position: relative;
}
.password-toggle {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(25%);
  cursor: pointer;
  color: var(--border-color);
}
.error-message {
  color: var(--error-color);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.form-card .button {
  width: 100%;
  text-align: center;
}

.profile-upload {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
}
.profile-upload .profile-preview {
  width: 80px;
  height: 80px;
  background-color: var(--input-background);
  border-radius: 50%;
  margin-right: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  border: 2px solid var(--primary-color);
}
.profile-upload .profile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-upload label {
  cursor: pointer;
  color: var(--primary-color);
  text-decoration: underline;
  font-weight: normal;
}
.profile-upload input[type="file"] {
  display: none;
}

/* --- Calculator & History Pages --- */
.calculator-container,
.history-container,
.formulas-container {
  background-color: var(--card-background);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 20px var(--shadow-color);
  margin-top: 3rem;
  width: 100%;
}
.calculator-container h2,
.history-container h2,
.formulas-container h2 {
  margin-bottom: 2rem;
  text-align: center;
  color: var(--primary-color);
  font-size: 2rem;
}

.calculator-card {
  display: flex;
  flex-direction: column;
}
.calculator-card .form-group {
  margin-bottom: 1.5rem;
}
.calculator-card .result-section {
  margin-top: 2rem;
  border-top: 2px solid var(--border-color);
  padding-top: 2rem;
}
.calculator-card .result-section p {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}
.calculator-card .result-section span {
  font-weight: bold;
  color: var(--primary-color);
}

/* --- History Page --- */
.history-item {
  background-color: var(--input-background);
  padding: 1.2rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 5px var(--shadow-color);
  flex-wrap: wrap;
  gap: 1rem;
}
.history-item span {
  font-weight: bold;
}
.clear-history-btn {
  background-color: var(--error-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s;
}
.clear-history-btn:hover {
  background-color: #c0392b;
}

/* --- Formulas Page --- */
.formulas-container .formula-item {
  margin-bottom: 2.5rem;
}
.formulas-container .formula-item h3 {
  color: var(--secondary-color);
  margin-bottom: 0.75rem;
}
.formulas-container .formula-item p {
  background-color: var(--input-background);
  padding: 1rem;
  border-radius: 8px;
  font-family: "Courier New", Courier, monospace;
  overflow-x: auto;
}

/* --- Footer --- */
.footer {
  background-color: var(--card-background);
  color: var(--text-color);
  padding: 2rem 2rem 0;
  box-shadow: 0 -2px 10px var(--shadow-color);
  margin-top: auto;
  font-size: 0.9rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding-bottom: 1.5rem;
  gap: 2rem;
}

.footer-section {
  flex: 1;
  min-width: 200px;
}

.footer-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
  text-decoration: none;
  display: block;
  margin-bottom: 0.5rem;
}

.footer-about p {
  color: #7f8c8d;
  line-height: 1.5;
}

.footer-links h3,
.footer-contact h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.footer-links ul {
  list-style: none;
}

.footer-links a {
  display: block;
  padding: 0.25rem 0;
  color: var(--text-color);
  text-decoration: none;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: var(--primary-color);
}

.social-icons a {
  font-size: 1.5rem;
  color: var(--text-color);
  margin-right: 1rem;
  transition: color 0.3s;
}

.social-icons a:hover {
  color: var(--primary-color);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  text-align: center;
  padding: 1rem 0;
  color: #7f8c8d;
}

/* --- Custom Modal --- */
.modal {
  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: 1000;
}
.modal-content {
  background-color: var(--card-background);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow-color);
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.modal-content p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}
.modal-buttons {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
}

/* --- Responsive Design --- */

/* Tablets and small laptops (max-width: 1024px) */
@media (max-width: 1024px) {
  .navbar {
    padding: 1rem;
  }
  .hero-section h1 {
    font-size: 2.5rem;
  }
  .hero-section p {
    font-size: 1rem;
  }
  .form-card,
  .calculator-container,
  .history-container,
  .formulas-container {
    padding: 2rem;
  }
  .button.large {
    font-size: 1rem;
    padding: 0.8rem 1.6rem;
  }
  .footer-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .footer-section {
    min-width: unset;
    width: 100%;
  }
  .footer-links ul {
    display: flex;
    justify-content: center;
    gap: 1rem;
  }
  .footer-links li {
    display: inline-block;
  }
  .social-icons {
    display: flex;
    justify-content: center;
    gap: 1rem;
  }
}

/* Mobile phones and tablets (max-width: 768px) */
@media (max-width: 768px) {
  .navbar {
    flex-wrap: nowrap;
    padding: 1rem;
  }

  .hamburger-menu {
    display: block; /* Show hamburger button on mobile */
    order: 2;
    margin-left: auto;
  }
  .close-menu {
    display: block;
  }
  .navbar.nav-active .hamburger-menu {
    display: none;
  }
  .navbar.nav-active .close-menu {
    display: block;
  }

  .nav-links-container {
    position: fixed;
    top: 0;
    right: -100%; /* Initially off-screen */
    width: 70%;
    height: 100vh;
    background-color: var(--card-background);
    box-shadow: -2px 0 10px var(--shadow-color);
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 5rem 2rem 2rem;
    transition: right 0.3s ease-in-out;
    z-index: 999;
  }

  .nav-links-container.nav-active {
    right: 0; /* Slide into view */
  }

  .nav-links {
    flex-direction: column;
    text-align: center;
    width: 100%;
    gap: 1rem;
    margin-bottom: 2rem;
  }

  .nav-auth-buttons {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }

  .nav-auth-buttons .button {
    width: 100%;
  }

  .hero-section {
    padding: 4rem 1rem;
  }
  .hero-section h1 {
    font-size: 2rem;
  }
  .hero-section p {
    font-size: 1rem;
  }
  .form-card {
    padding: 1.5rem;
    margin: 2rem auto;
  }
  .calculator-container,
  .history-container,
  .formulas-container {
    padding: 1.5rem;
  }
  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .history-item span {
    font-size: 0.9rem;
  }
}

/* Small mobile devices (max-width: 480px) */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
  .logo {
    font-size: 1.5rem;
  }
  .nav-auth-buttons a {
    padding: 0.5rem 1rem;
  }
  .hero-section h1 {
    font-size: 1.8rem;
  }
  .hero-section p {
    font-size: 0.9rem;
  }
  .form-card,
  .calculator-container,
  .history-container,
  .formulas-container {
    padding: 1rem;
  }
  .modal-content {
    padding: 1.5rem;
  }
  .modal-content p {
    font-size: 1rem;
  }
  .modal-buttons {
    flex-direction: column;
  }
}
