/* ============================================
   SupplementBuilder.app - Main Stylesheet
   ============================================ */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6 { line-height: 1.2; font-weight: 700; }

/* --- CSS Variables --- */
:root {
  /* Primary - Trust blue */
  --color-primary: #1e40af;
  --color-primary-light: #3b82f6;
  --color-primary-dark: #1e3a8a;
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;

  /* Neutral */
  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-bg-card: #ffffff;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #1e293b;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;

  /* Status */
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;

  /* Accent */
  --color-accent: #f59e0b;
  --color-accent-dark: #d97706;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Layout */
  --max-width-marketing: 1200px;
  --max-width-app: 960px;
  --nav-height: 64px;

  /* Type Scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
}

/* --- Layout --- */
.container { width: 100%; max-width: var(--max-width-marketing); margin: 0 auto; padding: 0 var(--space-md); }
.container-app { width: 100%; max-width: var(--max-width-app); margin: 0 auto; padding: 0 var(--space-md); }
.section { padding: 40px 0; }
@media (min-width: 768px) { .section { padding: var(--space-3xl) 0; } }

/* --- Site Header (Marketing) --- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width-marketing);
  margin: 0 auto;
  padding: 0 var(--space-md);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon { flex-shrink: 0; }
.logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}
.logo-accent { color: var(--color-primary); }
.header-nav {
  display: none;
  align-items: center;
  gap: var(--space-xl);
}
.header-nav a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color 0.15s;
}
.header-nav a:hover { color: var(--color-primary); }
.header-actions {
  display: none;
  align-items: center;
  gap: var(--space-sm);
}
@media (min-width: 768px) {
  .header-nav, .header-actions { display: flex; }
  .hamburger { display: none !important; }
}

/* Hamburger */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  cursor: pointer;
  background: none;
  border: none;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: all 0.2s;
}
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Mobile Nav Overlay */
.mobile-nav {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0; bottom: 0;
  background: var(--color-bg);
  z-index: 99;
  padding: var(--space-lg);
  flex-direction: column;
  gap: var(--space-md);
}
.mobile-nav.open { display: flex; }
.mobile-nav a, .mobile-nav button {
  display: block;
  padding: var(--space-md);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  text-align: left;
  width: 100%;
}
.mobile-nav a:hover { background: var(--color-bg-alt); }

/* --- App Header --- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}
.app-header .header-inner {
  max-width: var(--max-width-app);
}
.app-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.usage-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-50);
  color: var(--color-primary);
  white-space: nowrap;
}
.account-dropdown { position: relative; }
.account-btn {
  width: 36px; height: 36px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.avatar-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs) 0;
  z-index: 200;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--color-bg-alt); }

/* --- Footer --- */
.site-footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: var(--space-3xl) 0 var(--space-lg);
}
.footer-inner {
  max-width: var(--max-width-marketing);
  margin: 0 auto;
  padding: 0 var(--space-md);
}
.footer-brand { margin-bottom: var(--space-xl); }
.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}
.footer-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}
.footer-col h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}
.footer-col a {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-xs) 0;
}
.footer-col a:hover { color: var(--color-primary); }
.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-lg);
}
.footer-bottom p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-secondary { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-primary-50); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); border-color: transparent; }
.btn-ghost:hover { color: var(--color-primary); background: var(--color-primary-50); }
.btn-accent { background: var(--color-accent); color: #1e293b; border-color: var(--color-accent); }
.btn-accent:hover { background: var(--color-accent-dark); border-color: var(--color-accent-dark); }
.btn-danger { background: var(--color-error); color: #fff; border-color: var(--color-error); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { padding: 6px 14px; font-size: var(--text-sm); min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: var(--text-lg); min-height: 52px; }

/* --- Cards --- */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--color-border-strong); }

/* --- Forms --- */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--text-base);
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 44px;
  transition: border-color 0.15s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-textarea { min-height: 100px; resize: vertical; }

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
}
.badge-draft { background: var(--color-bg-alt); color: var(--color-text-muted); }
.badge-completed { background: var(--color-success-bg); color: var(--color-success); }
.badge-exported { background: var(--color-primary-50); color: var(--color-primary); }

/* --- Page Content Spacing --- */
.page-content { padding-top: calc(var(--nav-height) + var(--space-lg)); padding-bottom: var(--space-3xl); }

/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* --- Grid --- */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* --- App Bottom Nav (Mobile) --- */
.app-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  z-index: 100;
  padding: 0;
}
.app-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-sm);
  min-height: 44px;
}
.app-bottom-nav a.active { color: var(--color-primary); }
.app-bottom-nav svg { width: 24px; height: 24px; }
@media (min-width: 768px) { .app-bottom-nav { display: none; } }

/* --- Tab Bar --- */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}
.tab-bar button {
  flex: 1;
  padding: var(--space-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
}
.tab-bar button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* --- Pricing Table --- */
.pricing-card { text-align: center; position: relative; }
.pricing-card.featured { border-color: var(--color-primary); border-width: 2px; }
.pricing-card .popular-badge {
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 16px;
  border-radius: var(--radius-pill);
}
.pricing-price { font-size: var(--text-4xl); font-weight: 700; color: var(--color-text); }
.pricing-period { font-size: var(--text-sm); color: var(--color-text-muted); }
.pricing-features { text-align: left; margin: var(--space-lg) 0; }
.pricing-features li {
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}
.pricing-features li::before {
  content: '';
  display: inline-block;
  width: 20px; height: 20px;
  min-width: 20px;
  background: var(--color-success);
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='currentColor' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='currentColor' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* --- FAQ --- */
.faq-item { border-bottom: 1px solid var(--color-border); }
.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  min-height: 44px;
}
.faq-question::after {
  content: '+';
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: var(--space-md);
}
.faq-item.open .faq-question::after { content: '-'; }
.faq-answer {
  display: none;
  padding: 0 0 var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
}
.faq-item.open .faq-answer { display: block; }

/* --- Blog --- */
.blog-card { display: flex; flex-direction: column; }
.blog-card-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}
.blog-card h3 { font-size: var(--text-lg); margin-bottom: var(--space-sm); }
.blog-card p { font-size: var(--text-sm); color: var(--color-text-secondary); }
.blog-card:hover h3 { color: var(--color-primary); }

/* Article */
.article-content { max-width: 720px; margin: 0 auto; }
.article-content h2 { font-size: var(--text-2xl); margin: var(--space-2xl) 0 var(--space-md); }
.article-content h3 { font-size: var(--text-xl); margin: var(--space-xl) 0 var(--space-sm); }
.article-content p { margin-bottom: var(--space-md); color: var(--color-text-secondary); }
.article-content ul, .article-content ol { margin-bottom: var(--space-md); padding-left: var(--space-lg); }
.article-content li { margin-bottom: var(--space-sm); color: var(--color-text-secondary); list-style: disc; }
.article-content ol li { list-style: decimal; }
.article-content strong { color: var(--color-text); }
.article-content blockquote {
  border-left: 3px solid var(--color-primary);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-primary-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: var(--space-md);
}

/* --- Hero --- */
.hero {
  padding: calc(var(--nav-height) + 40px) 0 40px;
  text-align: center;
}
.hero h1 {
  font-size: var(--text-3xl);
  max-width: 700px;
  margin: 0 auto var(--space-md);
}
.hero .hero-sub {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-xl);
}
.hero-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}
@media (min-width: 768px) {
  .hero { padding: calc(var(--nav-height) + 80px) 0 60px; }
  .hero h1 { font-size: var(--text-4xl); }
}

/* --- CTA Section --- */
.cta-section {
  text-align: center;
  background: var(--color-primary-50);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-lg);
  margin: var(--space-2xl) 0;
}
.cta-section h2 { font-size: var(--text-2xl); margin-bottom: var(--space-sm); }
.cta-section p { color: var(--color-text-secondary); margin-bottom: var(--space-lg); }

/* --- Collapsible Panels --- */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
}
.collapsible-header::after {
  content: '';
  width: 20px; height: 20px;
  background: var(--color-text-muted);
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='currentColor' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='currentColor' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform 0.2s;
}
.collapsible.open .collapsible-header::after { transform: rotate(180deg); }
.collapsible-body { display: none; padding: 0 var(--space-md) var(--space-md); }
.collapsible.open .collapsible-body { display: block; }

/* --- Loading / Spinner --- */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* --- Print --- */
@media print {
  .site-header, .app-header, .site-footer, .app-bottom-nav, .no-print { display: none !important; }
  body { background: #fff; }
  .page-content { padding-top: 0; }
}
