/* --------------------
  Root Variables (Light & Dark)
--------------------- */
:root {
  --primary: #005bea;
  --primary-dark: #0041c4;
  --accent: #00c6fb;
  --background-gradient: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-blur: 20px;
  --text: #1a2233;
  --disabled: #bdbdbd;
  --disabled-text: #eee;
  --border-radius: 24px;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --input-bg: rgba(255, 255, 255, 0.75);
  --input-border: #e3eafc;
  --input-focus: #005bea;
  --label: #005bea;
  --result-bg: rgba(0, 186, 255, 0.1);
  --icon-size: 1.3em;
  --navbar-bg: rgba(255,255,255,0.95);
}

body.dark-mode {
  --primary: #00c6fb;
  --primary-dark: #005bea;
  --accent: #005bea;
  --background-gradient: linear-gradient(135deg, #232526 0%, #414345 100%);
  --glass-bg: rgba(30, 34, 51, 0.92);
  --glass-blur: 24px;
  --text: #f5faff;
  --disabled: #444a5a;
  --disabled-text: #bdbdbd;
  --border-radius: 24px;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
  --input-bg: rgba(30, 34, 51, 0.85);
  --input-border: #2a2e3a;
  --input-focus: #00c6fb;
  --label: #00c6fb;
  --result-bg: rgba(0, 186, 255, 0.13);
  --icon-size: 1.3em;
  --navbar-bg: rgba(30,34,51,0.98);
}

/* --------------------
  Global Resets & Typography
--------------------- */
html {
  box-sizing: border-box;
  font-size: 16px;
  scroll-behavior: smooth;
}
*, *::before, *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Poppins', sans-serif;
  background: var(--background-gradient);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-x: hidden;
  transition: background 0.4s, color 0.4s;
}

/* --------------------
  Animated Background
--------------------- */
.animated-bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}
.animated-bg::before,
.animated-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  animation: blobMove 18s infinite alternate;
}
.animated-bg::before {
  width: 520px;
  height: 520px;
  left: -100px;
  top: -100px;
  background: linear-gradient(120deg, #00c6fb, #005bea);
}
.animated-bg::after {
  width: 420px;
  height: 420px;
  right: -100px;
  bottom: -100px;
  background: linear-gradient(120deg, #ffecd2, #fcb69f);
  animation-delay: 6s;
}
body.dark-mode .animated-bg::before {
  background: linear-gradient(120deg, #232526, #005bea);
}
body.dark-mode .animated-bg::after {
  background: linear-gradient(120deg, #232526, #00c6fb);
}
@keyframes blobMove {
  0% { transform: scale(1) translateY(0) rotate(0); }
  100% { transform: scale(1.2) translateY(40px) rotate(30deg); }
}

/* --------------------
  Navbar (Modern)
--------------------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  background: var(--navbar-bg);
  box-shadow: 0 2px 16px rgba(0,0,0,0.07);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7em 2em;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  transition: background 0.4s;
}
.navbar .nav-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex-shrink: 0;
}
.navbar .nav-links {
  display: flex;
  gap: 1.2em;
  flex-wrap: wrap;
  justify-content: center;
}
.navbar .nav-link {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
  font-size: 1.08rem;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.3em;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: var(--primary);
  text-shadow: 0 2px 8px #b3e0ff;
}

/* --------------------
  Dark Mode Toggle Button
--------------------- */
.dark-toggle {
  background: var(--glass-bg);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  margin-left: 1em;
}
.dark-toggle:focus {
  outline: 2px solid var(--primary);
}
.dark-toggle i {
  font-size: 1.3em;
  color: var(--primary-dark);
  transition: color 0.2s;
}
body.dark-mode .dark-toggle i {
  color: var(--accent);
}

/* --------------------
  Container (Card)
--------------------- */
.container {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  padding: 40px 28px 32px 28px;
  max-width: 500px;
  width: 100%;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  z-index: 1;
  animation: fadeIn 1s cubic-bezier(0.4,0,0.2,1);
  text-align: center;
  margin-top: 80px;
  margin-bottom: 32px;
  transition: background 0.4s, box-shadow 0.4s;
}
@media (max-width: 700px) {
  .container {
    border-radius: 0;
    padding: 18px 4px 12px 4px;
    margin-top: 60px;
  }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* --------------------
  Headings
--------------------- */
h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  margin-bottom: 0.2em;
}
.subtitle {
  font-size: 1.2rem;
  color: var(--primary-dark);
  margin-bottom: 1.5em;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* --------------------
  Form & Inputs
--------------------- */
form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 24px;
}
.form-group {
  position: relative;
  width: 100%;
}
input[type="number"],
select {
  width: 100%;
  padding: 18px 12px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  font-size: 1.1rem;
  font-weight: 600;
  transition: var(--transition);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 4px 16px rgba(0, 94, 255, 0.13);
}
.form-group label {
  position: absolute;
  top: 18px;
  left: 16px;
  font-size: 1.05rem;
  color: var(--label);
  pointer-events: none;
  transition: var(--transition);
  opacity: 0.85;
  background: transparent;
}
input:focus + label,
input:not(:placeholder-shown) + label,
select:focus + label,
select:not([value=""]) + label {
  top: 2px;
  left: 12px;
  font-size: 0.92rem;
  background: var(--glass-bg);
  padding: 0 6px;
  border-radius: 6px;
  color: var(--primary-dark);
}
input:disabled,
select:disabled {
  background: var(--disabled);
  color: var(--disabled-text);
  cursor: not-allowed;
}

/* --------------------
  Button (Modern)
--------------------- */
button.option-card {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 14px 0;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  box-shadow: 0 6px 24px rgba(0, 94, 255, 0.13);
  position: relative;
  overflow: hidden;
  outline: none;
}
button.option-card:focus {
  box-shadow: 0 0 0 3px var(--accent), 0 6px 24px rgba(0, 94, 255, 0.13);
}
button.option-card::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
  z-index: 0;
}
button.option-card:active::after {
  width: 200px;
  height: 200px;
}
button.option-card:hover {
  background: linear-gradient(90deg, var(--primary-dark), var(--accent));
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 36px rgba(0, 94, 255, 0.22);
}
button.option-card.disabled,
button.option-card:disabled {
  background: var(--disabled);
  color: var(--disabled-text);
  cursor: not-allowed;
  box-shadow: none;
}

/* Floating Action Button (FAB) */
.fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: white;
  border: none;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 94, 255, 0.18);
  font-size: 2rem;
  cursor: pointer;
  z-index: 20;
  transition: background 0.2s, box-shadow 0.2s;
}
.fab:focus {
  outline: 2px solid var(--accent);
}
.fab:hover {
  background: linear-gradient(90deg, var(--primary-dark), var(--accent));
  box-shadow: 0 16px 48px rgba(0, 94, 255, 0.28);
}

/* --------------------
  Results
--------------------- */
#result {
  margin-top: 18px;
  background: var(--result-bg);
  border-radius: 16px;
  padding: 22px 14px;
  text-align: left;
  font-size: 1.13rem;
  box-shadow: 0 2px 8px rgba(0, 94, 255, 0.04);
  animation: fadeIn 0.7s cubic-bezier(0.4,0,0.2,1);
  transition: background 0.4s;
}

/* --------------------
  Chart
--------------------- */
.breakdown-chart-container {
  background: var(--result-bg);
  border-radius: 16px;
  padding: 18px 10px 10px;
  margin-top: 18px;
  box-shadow: 0 2px 8px rgba(0, 94, 255, 0.04);
  overflow-x: auto;
  text-align: left;
  transition: background 0.4s;
}
.breakdown-chart-heading {
  font-size: 1.13rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 10px 4px;
}
canvas {
  min-width: 600px;
  width: 100%;
  height: 240px !important;
  display: block;
}

/* --------------------
  Link
--------------------- */
.help-link {
  margin-top: 28px;
  display: inline-block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
.help-link:hover {
  color: var(--primary-dark);
  text-shadow: 0 2px 8px #b3e0ff;
}

/* --------------------
  Accordion (Help)
--------------------- */
.accordion {
  background: none;
  border: none;
  font-weight: 700;
  padding: 12px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--input-border);
  color: var(--primary-dark);
  transition: background 0.2s;
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.accordion.faq-accordion {
    padding: 15px 10px;
}
.accordion::after {
    content: '\f067'; /* Font Awesome plus icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    color: var(--accent);
    font-size: 1.1rem;
    transition: transform 0.3s;
}
.accordion.active::after {
    content: '\f068'; /* Font Awesome minus icon */
    transform: rotate(180deg);
}

.accordion.active {
  background: rgba(0, 186, 255, 0.07);
}
.panel {
  padding: 0 18px;
  background-color: transparent;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  border-bottom: 1px solid var(--input-border);
}
.panel p {
    padding: 12px 0;
    font-size: 1.05rem;
    line-height: 1.6;
}

.faq-heading {
    margin-top: 40px;
    margin-bottom: 12px;
    font-size: 1.8rem;
    color: var(--primary);
    text-align: center;
}

/* Help Page Specific */
.calculator-accordion h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.5rem;
}
.calculator-info {
    padding: 12px 0;
}
.help-container h2 {
    font-size: 1.6rem;
    color: var(--primary);
    margin-top: 28px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 0.6em;
    border-bottom: 2px solid var(--input-border);
    padding-bottom: 8px;
}
.help-header {
    text-align: center;
    margin-bottom: 24px;
}
.calculator-info p {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 12px;
}
.example {
    background: var(--result-bg);
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
}
.example h4 {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

/* --------------------
   Breakdown Table Styles
--------------------- */
.breakdown-table-container {
  background: var(--result-bg);
  border-radius: 16px;
  padding: 18px 10px 10px;
  margin-top: 18px;
  box-shadow: 0 2px 8px rgba(0, 94, 255, 0.04);
  overflow-x: auto;
  text-align: left;
  transition: background 0.4s;
}
.breakdown-table-heading {
  font-size: 1.13rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 10px 4px;
}
.breakdown-table {
  border-collapse: collapse;
  min-width: 600px;
  width: 100%;
  font-size: 1rem;
  background: transparent;
}
.breakdown-table th, .breakdown-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #e3eafc;
  text-align: right;
}
.breakdown-table th {
  background: #f5faff;
  color: var(--primary-dark);
  font-weight: 700;
  text-align: right;
}
.breakdown-table tr:last-child td {
  border-bottom: none;
}
.breakdown-table td:first-child, .breakdown-table th:first-child {
  text-align: left;
}
@media (max-width: 700px) {
  .breakdown-table {
    min-width: 400px;
    font-size: 0.95rem;
  }
  .breakdown-table-heading {
    font-size: 1rem;
  }
  .breakdown-table-container {
    padding: 10px 2px 6px 2px;
  }
}

/* --------------------
  Responsive
--------------------- */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
  .navbar {
    padding: 0.8em 1em;
    flex-direction: column;
    gap: 0.8em;
  }
  .navbar .nav-links {
    gap: 0.8em;
    order: 2;
  }
  .navbar .nav-title {
    order: 1;
  }
  .navbar .dark-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    order: 3;
  }
  .container {
    padding: 24px 16px;
    margin-top: 140px;
    border-radius: 18px;
  }
  h1 {
    font-size: 2.2rem;
  }
  .breakdown-table {
    min-width: 500px;
    font-size: 0.9rem;
  }
  .breakdown-table-container {
    padding: 12px 4px;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
  .navbar {
    padding: 0.6em;
  }
  .navbar .nav-links {
    gap: 0.5em 0.8em;
  }
  .navbar .nav-link {
    font-size: 1.05rem;
  }
  .container {
    padding: 20px 8px;
    margin-top: 150px;
  }
  h1 {
    font-size: 2rem;
    gap: 0.3em;
    flex-direction: column;
  }
  .form-group {
    gap: 20px;
  }
  .breakdown-table {
    min-width: 400px;
    font-size: 0.85rem;
  }
  .breakdown-table th, .breakdown-table td {
    padding: 6px 8px;
  }
}

/* --------------------
  Footer
--------------------- */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--navbar-bg);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.07);
  padding: 0.5em 1em;
  text-align: center;
  font-weight: 600;
  color: var(--primary-dark);
  z-index: 10;
}