/* 
 * Academic Calculators - Global Styles
 * Mobile-first, Vanilla CSS, High Performance
 * Updated for AI-friendly content structure
 */

:root {
  /* Brand Colors */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #EC4899;
  --accent: #8B5CFFFF;
  --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; 
  background-clip: text;
  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); }
p.lead { font-size: 1.1rem; line-height: 1.7; }

/* Content sections for AI-friendly structure */
.content-intro {
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-left: 4px solid var(--primary);
}

.content-intro p {
  color: var(--text-main);
  margin-bottom: 0;
}

.formula-box {
  background: #1F2937;
  color: #F9FAFB;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.example-box {
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1rem 0;
}

.example-box h4 {
  color: #065F46;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.example-box p {
  color: #047857;
  margin-bottom: 0.5rem;
}

.example-box .result {
  font-weight: 700;
  color: #059669;
  font-size: 1.1rem;
}

.use-cases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.use-case-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.use-case-item .icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.use-case-item p {
  margin: 0;
  font-size: 0.95rem;
}

.limitations-box {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.limitations-box h4 {
  color: #92400E;
  margin-bottom: 0.75rem;
}

.limitations-box ul {
  margin: 0;
  padding-left: 1.25rem;
  color: #B45309;
}

.limitations-box li {
  margin-bottom: 0.5rem;
}

/* Related Calculators */
.related-calculators {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.related-calculators h3 {
  margin-bottom: 1rem;
  color: var(--text-main);
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.related-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #EEF2FF;
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s;
}

.related-link:hover {
  background: var(--primary);
  color: white;
}

/* Citations */
.citations-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.citations-section h3 {
  margin-bottom: 1rem;
}

.citations-list {
  list-style: decimal;
  padding-left: 1.5rem;
  color: var(--text-muted);
}

.citations-list li {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* --- Header & Nav --- */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
  padding: 0;
  width: 100%;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.logo span {
  color: #e94560;
}

/* Breadcrumbs */
.bulk-breadcrumbs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 20px;
  font-size: 0.9rem;
  color: #333;
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: #f7f7f7;
  border-bottom: 1px solid #e5e5e5;
  position: relative;
  z-index: 2;
  visibility: visible !important;
  opacity: 1 !important;
}

.bulk-breadcrumbs a {
  color: #1a1a2e;
  text-decoration: none;
}

.bulk-breadcrumbs a:hover {
  text-decoration: underline;
}

.bulk-breadcrumb-sep {
  color: #999;
}

.bulk-breadcrumb-current {
  color: #555;
}

/* --- 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 / FAQ */
.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 */
footer {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  padding: 50px 20px 20px;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h3 {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.footer-section p {
  color: #9CA3AF;
  font-size: 0.9rem;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: #9CA3AF;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: #fff;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-bottom p {
  color: #9CA3AF;
  font-size: 0.85rem;
}

/* Home Page Grid */
.calculator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.calculator-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  text-decoration: none;
  display: block;
}

.calculator-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.calculator-card .icon-wrap {
  height: 48px;
  width: 48px;
  background: #EEF2FF;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.calculator-card h3 {
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.calculator-card p {
  font-size: 0.9rem;
  margin: 0;
}

/* 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); }

/* Mobile Responsive - Base styles only, header handled separately */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }
  
  .result-value { font-size: 2.5rem; }
}

/* Print styles */
@media print {
  header, footer, .btn, .menu-toggle { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}


/* ========================================
   ORIGINAL HEADER STYLES
======================================== */
header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    padding: 0;
    width: 100%;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    margin: 0;
}

.logo span {
    color: #e94560;
}

header nav {
    display: flex;
    align-items: center;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 5px;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
    margin: 0;
    padding: 0;
}

.nav-link {
    color: #fff;
    text-decoration: none;
    padding: 25px 18px;
    display: block;
    font-weight: 700;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: #e94560;
}

.has-submenu > .nav-link::after {
    content: '▼';
    font-size: 0.6rem;
    margin-left: 6px;
    transition: transform 0.3s ease;
}

.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1a2e;
    min-width: 220px;
    padding: 10px 0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    list-style: none;
    z-index: 1000;
}

.nav-item:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.submenu li a {
    color: #ccc;
    padding: 12px 20px;
    display: block;
    transition: all 0.3s ease;
    text-decoration: none;
}

.submenu li a:hover {
    color: #e94560;
    background: rgba(255, 255, 255, 0.05);
    padding-left: 25px;
}

/* Menu toggle for mobile */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    height: 3px;
    background: #fff;
    border-radius: 3px;
    transition: all 0.3s ease;
}

#menu-checkbox {
    display: none;
}

/* ========================================
   ORIGINAL FOOTER STYLES
======================================== */
footer {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    padding: 60px 20px 20px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #e94560;
    position: relative;
    padding-bottom: 10px;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background: #e94560;
}

.footer-section p {
    color: #aaa;
    line-height: 1.8;
}

.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-links li {
    margin-bottom: 12px;
}

.footer-links a {
    color: #aaa;
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-links a:hover {
    color: #e94560;
    padding-left: 5px;
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.social-links a {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.social-links a:hover {
    background: #e94560;
    transform: translateY(-3px);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    text-align: center;
    color: #aaa;
}

/* ========================================
   RESPONSIVE STYLES FOR HEADER/FOOTER
======================================== */
@media (max-width: 992px) {
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    /* Breadcrumbs mobile */
    .bulk-breadcrumbs {
        display: flex !important;
        margin: 0 auto;
        padding: 8px 16px;
        font-size: 0.85rem;
        background: #fff;
        position: relative;
        z-index: 1;
    }

    /* Show mobile menu toggle */
    .menu-toggle {
        display: flex !important;
        z-index: 1001;
    }

    /* Mobile navigation - slide in from right */
    header nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: #1a1a2e;
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 80px;
        transition: right 0.3s ease;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
        display: flex !important;
        visibility: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 999;
    }

    /* When checkbox is checked, show nav */
    .header-container #menu-checkbox:checked ~ nav {
        right: 0;
        visibility: visible;
    }

    /* Hamburger to X animation */
    .header-container #menu-checkbox:checked ~ .menu-toggle span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 6px);
    }

    .header-container #menu-checkbox:checked ~ .menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    .header-container #menu-checkbox:checked ~ .menu-toggle span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -6px);
    }

    /* Nav menu mobile styles - HIGH SPECIFICITY */
    header nav .nav-menu {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0 !important;
        display: flex !important;
        position: static !important;
        transform: none !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        list-style: none !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Nav items visible */
    header nav .nav-item {
        display: block !important;
        width: 100% !important;
        position: relative !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Nav links - EXPLICIT WHITE COLOR */
    header nav .nav-link {
        display: block !important;
        padding: 15px 25px !important;
        color: #ffffff !important;
        background: transparent !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        border-radius: 0 !important;
    }

    header nav .nav-link:hover {
        color: #e94560 !important;
        background: rgba(255, 255, 255, 0.05) !important;
    }

    /* Mobile submenu - initially hidden */
    header nav .submenu {
        position: static !important;
        background: rgba(0, 0, 0, 0.3) !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        transition: max-height 0.3s ease !important;
        padding: 0 !important;
        margin: 0 !important;
        list-style: none !important;
    }

    /* Show submenu on hover/focus */
    header nav .nav-item:hover > .submenu,
    header nav .nav-item:focus-within > .submenu,
    header nav .nav-item.active > .submenu {
        max-height: 1000px !important;
    }

    /* Show all submenus when menu is open */
    .header-container #menu-checkbox:checked ~ nav .submenu {
        max-height: 1000px !important;
        display: block !important;
        overflow: visible !important;
    }

    /* Submenu links */
    header nav .submenu li {
        display: block !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    }

    header nav .submenu li a {
        display: block !important;
        color: #cccccc !important;
        padding: 12px 25px 12px 40px !important;
        font-size: 14px !important;
        text-decoration: none !important;
        background: transparent !important;
    }

    header nav .submenu li a:hover {
        background: rgba(255, 255, 255, 0.05) !important;
        color: #e94560 !important;
    }

    /* Footer mobile */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-section {
        text-align: center;
    }

    .footer-section h3::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .social-links {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.4rem;
    }

    .header-container {
        height: 60px;
    }

    footer {
        padding: 40px 15px 15px;
    }
}
