/* Base Styles */
:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #f3f4f6;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --border-color: #e5e7eb;
  --card-bg: #ffffff;
  --error-color: #ef4444;
  --success-color: #10b981;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  --teal-color: #0d9488;
  --teal-hover: #0f766e;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  color: var(--text-color);
  line-height: 1.5;
  background-color: #f9fafb;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Header Styles */
.header {
  background-color: var(--card-bg);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary-color);
  text-decoration: none;
}

.logo i {
  font-size: 1.5rem;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary-color);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  cursor: pointer;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--card-bg);
  z-index: 200;
  padding: 2rem;
  flex-direction: column;
  gap: 1.5rem;
}

.mobile-nav.active {
  display: flex;
}

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.close-menu-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  cursor: pointer;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 1.125rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.mobile-nav-link.active {
  color: var(--primary-color);
}

/* Main Content Styles */
.main {
  padding: 0.5rem 0 0rem;
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0rem;
}

.main-title {
  font-size: 2.25rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0rem;
  color: var(--teal-color);
}

.main-description {
  text-align: center;
  color: var(--text-light);
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

/* Main Tools Buttons */
.main-tools {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.main-tool-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--secondary-color);
  color: var(--text-color);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  flex: 1 1 calc(50% - 0.5rem);
  max-width: 1200px;
  text-align: center;
  border: 2px solid transparent;
}

.main-tool-button:hover {
  background-color: #e5e7eb;
}

.main-tool-button.active {
  background-color: var(--teal-color);
  color: white;
}

.main-tool-button i {
  font-size: 1.25rem;
}

/* Card Styles */
.card {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.calculator-card {
  max-width: 1200px;
  margin: 0 0rem 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title i {
  color: var(--teal-color);
}

.info-card {
  max-width: 1200px;
  margin: 0 0 1rem;
}

.info-card p {
  margin-bottom: 1rem;
}

/* Calculator Form Styles */
.calculator-form {
  display: none;
}

.calculator-form.active {
  display: block;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.form-row .form-group {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}

.form-row .btn-sm {
  margin-bottom: 0.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
  background-color: #f0f9f9;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--teal-color);
}

.result-input input {
  background-color: var(--secondary-color);
  font-weight: 600;
  color: var(--teal-color);
}

.form-hint {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-light);
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Button Styles */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-primary {
  background-color: var(--teal-color);
  color: white;
  border: none;
}

.btn-primary:hover {
  background-color: var(--teal-hover);
}

.btn-outline {
  background-color: transparent;
  color: var(--teal-color);
  border: 1px solid var(--teal-color);
}

.btn-outline:hover {
  background-color: var(--teal-color);
  color: white;
}

/* Alert Styles */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  display: none;
}

.error-alert {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
  border: 1px solid var(--error-color);
}

/* Result Box Styles */
.result-box {
  background-color: var(--secondary-color);
  padding: 1.5rem;
  border-radius: var(--radius);
  display: none;
  margin-bottom: 1.5rem;
}

.result-box h3 {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.result-box p {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--teal-color);
}

/* Formula Box Styles */
.formula-box {
  background-color: var(--secondary-color);
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  text-align: center;
  font-weight: 500;
}

/* Instruction List Styles */
.instruction-list {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.instruction-list li {
  margin-bottom: 0.5rem;
}

/* Table Styles */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  width: 100%;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  position: relative;
}

.calculation-table,
.grading-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calculation-table th,
.calculation-table td,
.grading-table th,
.grading-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--border-color);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.calculation-table th,
.grading-table th {
  background-color: var(--secondary-color);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.calculation-table tr:nth-child(even),
.grading-table tr:nth-child(even) {
  background-color: var(--secondary-color);
}

.table-note {
  font-size: 0.875rem;
  color: var(--text-light);
  font-style: italic;
}

/* Add scroll indicator for tables */
.table-wrapper::after {
  content: "→ Scroll horizontally →";
  position: absolute;
  bottom: -20px;
  right: 0;
  font-size: 0.75rem;
  color: var(--text-light);
  opacity: 0;
  transition: opacity 0.3s;
}

@media (max-width: 768px) {
  .table-wrapper::after {
    opacity: 1;
  }

  .table-wrapper {
    margin-bottom: 2rem;
  }
}

/* Component Details List */
.component-details-list {
  list-style: none;
  margin: 1rem 0;
}

.component-details-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.total-weight-info {
  margin-top: 1rem;
  font-weight: 600;
}

/* Grade Calculator Styles */
#grade-calculator-container {
  background-color: #e6f7f5;
  padding: 1.5rem;
  border-radius: var(--radius);
}

.subject-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.subject-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subject-row label {
  font-weight: 500;
  min-width: 80px;
}

.subject-row select {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: white;
}

.grade-calculator-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Footer Styles */
.footer {
  background-color: var(--card-bg);
  padding: 3rem 0 1.5rem;
  border-top: 1px solid var(--border-color);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.footer-section p {
  color: var(--text-light);
  margin-bottom: 1rem;
}

.footer-section h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary-color);
}

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-light);
  font-size: 0.875rem;
}

/* Other Tools Section */
.other-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.tool-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--teal-color);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.2s;
  justify-content: center;
  text-align: center;
}

.tool-button:hover {
  background-color: var(--teal-hover);
}

.tool-button i {
  font-size: 1.25rem;
}

/* Responsive Styles */
@media (max-width: 768px) {
  .desktop-nav {
    display: none;
  }

  .mobile-menu-btn {
    display: block;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .main-title {
    font-size: 1.75rem;
  }

  .card-title {
    font-size: 1.25rem;
  }

  .button-group {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .button-group .btn {
    flex: 1 1 auto;
    min-width: 120px;
    max-width: 200px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  /* Keep main tools in row format */
  .main-tools {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .main-tool-button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 120px;
    font-size: 0.9rem;
    padding: 0.6rem 0.5rem;
  }

  .subject-inputs {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  /* Keep main tools in row format with 2 per row */
  .main-tools {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .main-tool-button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    font-size: 0.85rem;
    padding: 0.6rem 0.5rem;
  }

  /* Table responsive improvements */
  .table-wrapper {
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem);
    border-radius: 0;
  }

  .calculation-table td,
  .grading-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .calculation-table th,
  .grading-table th {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .grade-calculator-buttons {
    flex-direction: row;
    justify-content: space-between;
  }

  .grade-calculator-buttons .btn {
    flex: 1 1 auto;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .tool-button {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
  }

  .tool-button i {
    font-size: 0.9rem;
  }

  .main-tool-button {
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
  }

  .main-tool-button i {
    font-size: 0.85rem;
  }

  .subject-row {
    flex-direction: row;
    align-items: center;
  }

  .subject-row label {
    min-width: 70px;
    font-size: 0.9rem;
  }
}

