/* 
 * Academic Calculators - Global Styles
 * Mobile-first, Vanilla CSS, High Performance
 */

:root {
  /* Brand Colors */
  --primary: #4F46E5; /* Indigo 600 */
  --primary-hover: #4338CA; /* Indigo 700 */
  --secondary: #EC4899; /* Pink 500 */
  --accent: #8B5CFFFF; /* Violet */
  --background: #F9FAFB;
  --surface: #FFFFFF;
  --text-main: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;

  /* Spacing & Sizes */
  --container-max: 1200px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.3);

  /* Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; transition: color 0.2s; }
button, input, select, textarea { font-family: inherit; }

/* --- Layout --- */
.container {
  width: 92%;
  max-width: var(--container-max);
  margin: 0 auto;
}

main {
  flex: 1;
  padding: 2rem 0 4rem;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h1 { font-size: 2.25rem; background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: inline-block; }
h2 { font-size: 1.75rem; margin-top: 2rem; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin-bottom: 1rem; color: var(--text-muted); }

/* --- Header & Nav --- */
.site-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
}

.nav-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.logo svg { height: 32px; width: 32px; fill: var(--primary); }

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-link {
  font-weight: 500;
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 0.5rem;
}
.nav-link:hover { color: var(--primary); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-trigger { display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}
.dropdown:hover .dropdown-menu { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.dropdown-item {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 500;
}
.dropdown-item:hover { background: #EEF2FF; color: var(--primary); }

.mobile-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; }

/* --- Mobile Menu --- */
@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    padding: 2rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    transform: translateY(-150%);
    transition: transform 0.3s ease;
    align-items: flex-start;
  }
  .nav-links.active { transform: translateY(0); box-shadow: var(--shadow-lg); }
  .mobile-toggle { display: block; }
  .dropdown-menu { position: static; transform: none; box-shadow: none; border: none; padding-left: 1rem; opacity: 1; visibility: visible; display: none; }
  .dropdown.active .dropdown-menu { display: block; }
  .dropdown-trigger::after { content: '+'; font-weight: bold; }
}

/* --- Components --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  gap: 0.5rem;
}

.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-glow); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: #EEF2FF; }
.btn-danger { background: #FEE2E2; color: var(--error); }
.btn-block { width: 100%; }

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.calculator-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 900px) { .calculator-wrapper { grid-template-columns: 1fr; } }

.form-group { margin-bottom: 1.25rem; position: relative; }
.form-label { display: block; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-main); font-size: 0.9rem; }
.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--primary); outline: 3px solid rgba(79, 70, 229, 0.1); }
.form-control.error { border-color: var(--error); background: #FEF2F2; }
.error-msg { font-size: 0.85rem; color: var(--error); margin-top: 0.25rem; display: none; }
.form-control.error + .error-msg { display: block; }

/* Toggle Switch */
.toggle-switch { display: flex; gap: 0.5rem; background: #E5E7EB; padding: 4px; border-radius: var(--radius-sm); width: fit-content; }
.toggle-btn { padding: 4px 12px; border-radius: 4px; border: none; background: transparent; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.toggle-btn.active { background: white; color: var(--primary); shadow: var(--shadow-sm); }

/* Results Panel */
.result-box {
  background: radial-gradient(circle at top right, #EEF2FF, #FFFFFF);
  text-align: center;
}
.result-value { font-size: 3rem; font-weight: 800; color: var(--primary); margin: 0.5rem 0; line-height: 1; }
.result-label { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

.breakdown-table { width: 100%; margin-top: 1rem; border-collapse: collapse; font-size: 0.95rem; }
.breakdown-table th, .breakdown-table td { padding: 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
.breakdown-table th { font-weight: 600; color: var(--text-muted); background: #F9FAFB; }
.breakdown-table tr:last-child td { border-bottom: none; }

/* Accordion */
.accordion { margin-top: 2rem; border-top: 1px solid var(--border); }
.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-trigger {
  width: 100%;
  text-align: left;
  padding: 1.25rem 0;
  background: none;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-main);
}
.accordion-content { display: none; padding-bottom: 1.25rem; font-size: 0.95rem; color: var(--text-muted); line-height: 1.7; }
.accordion-item.active .accordion-content { display: block; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* Footer */
.site-footer {
  background: #1F2937;
  color: #D1D5DB;
  padding: 3rem 0;
  margin-top: auto;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; }
.footer-title { color: white; font-weight: 700; margin-bottom: 1rem; }
.footer-links li { margin-bottom: 0.5rem; }
.footer-links a:hover { color: white; text-decoration: underline; }

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #10B981;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateY(150%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
}
.toast.show { transform: translateY(0); }
