/* Modern Theme & Custom Styles for EtsyCalculator.com */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  --primary: #528FF7; /* Logo signature brand blue */
  --primary-hover: #3C7DE8;
  --primary-light: #F0F6FF;
  --primary-subtle: #E1EDFE;
  --secondary: #1E293B;
  --accent: #7BC7FF; /* Logo sky blue accent */
  --accent-light: #F0F9FF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --border-color: #E2E8F0;
  --input-bg: #FFFFFF;
  --input-text: #0F172A;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(82 143 247 / 0.12), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 20px 25px -5px rgb(82 143 247 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Dark Mode Theme Variables & Full Overrides */
html.dark {
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --bg-page: #0B0F17;
  --bg-card: #151D2C;
  --border-color: #27354A;
  --input-bg: #0F172A;
  --input-text: #FFFFFF;
  --primary-light: #16243E;
  --primary-subtle: #1C3054;
}

html.dark body {
  background-color: #0B0F17 !important;
  color: #F8FAFC !important;
}

html.dark h1, 
html.dark h2, 
html.dark h3, 
html.dark h4, 
html.dark h5, 
html.dark h6, 
html.dark .text-slate-900,
html.dark .text-slate-800 {
  color: #FFFFFF !important;
}

html.dark .text-slate-700 {
  color: #E2E8F0 !important;
}

html.dark .text-slate-600,
html.dark .text-slate-500 {
  color: #94A3B8 !important;
}

html.dark .text-slate-400 {
  color: #94A3B8 !important;
}

/* Ensure all prose, paragraph text, lists, and strong elements stay bright in dark mode */
html.dark .prose,
html.dark .prose p,
html.dark .prose li,
html.dark .prose span {
  color: #CBD5E1 !important;
}

html.dark .prose strong,
html.dark strong {
  color: #FFFFFF !important;
}

html.dark ol, 
html.dark ul, 
html.dark li {
  color: #CBD5E1 !important;
}

/* Form toggle switch labels and helper text in dark mode */
html.dark .toggle-switch span,
html.dark .toggle-switch label,
html.dark label span {
  color: #E2E8F0 !important;
}

/* Hero Section in Dark Mode */
html.dark .bg-gradient-to-b, 
html.dark [class*="from-orange-50"],
html.dark [class*="from-emerald-50"],
html.dark [class*="from-blue-50"],
html.dark [class*="from-purple-50"],
html.dark [class*="from-pink-50"],
html.dark [class*="from-indigo-50"],
html.dark [class*="from-red-50"],
html.dark [class*="from-yellow-50"] {
  background: linear-gradient(180deg, #131A29 0%, #0B0F17 100%) !important;
  border-color: #1E293B !important;
}

/* Background Utility Overrides in Dark Mode */
html.dark .bg-white {
  background-color: #151D2C !important;
}

html.dark .bg-slate-50 {
  background-color: #0B0F17 !important;
}

html.dark .bg-slate-100 {
  background-color: #1E293B !important;
  color: #E2E8F0 !important;
}

html.dark [class*="bg-orange-50"],
html.dark [class*="bg-brand-50"] {
  background-color: #16243E !important;
  border-color: #27354A !important;
}

html.dark [class*="bg-orange-100"],
html.dark [class*="bg-brand-100"] {
  background-color: #1C3054 !important;
  border-color: #3C7DE8 !important;
  color: #7BC7FF !important;
}

html.dark .border-slate-100, 
html.dark .border-slate-200 {
  border-color: #27354A !important;
}

/* Cards & Forms in Dark Mode */
html.dark .calc-card {
  background-color: #151D2C !important;
  border-color: #27354A !important;
}

html.dark .form-label {
  color: #E2E8F0 !important;
}

html.dark .form-control, 
html.dark .form-select {
  background-color: #0B0F17 !important;
  color: #FFFFFF !important;
  border-color: #334155 !important;
}

html.dark .form-control:focus, 
html.dark .form-select:focus {
  border-color: var(--primary) !important;
}

html.dark .input-prefix, 
html.dark .input-suffix {
  color: #94A3B8 !important;
}

/* Navbar in Dark Mode */
html.dark .navbar {
  background-color: #0F172A !important;
  border-color: #1E293B !important;
}

html.dark .nav-link {
  color: #CBD5E1 !important;
}

html.dark .nav-link:hover, 
html.dark .nav-link.active {
  color: var(--primary) !important;
  background-color: rgba(82, 143, 247, 0.15) !important;
}

html.dark #mobileDrawer {
  background-color: #0F172A !important;
  border-color: #1E293B !important;
}

html.dark #mobileDrawer a {
  color: #CBD5E1 !important;
}

html.dark #mobileDrawer a:hover {
  background-color: #1E293B !important;
}

/* Tool Cards & FAQs in Dark Mode */
html.dark .tool-card {
  background-color: #151D2C !important;
  border-color: #27354A !important;
  color: #F8FAFC !important;
}

html.dark .faq-item {
  background-color: #151D2C !important;
  border-color: #27354A !important;
}

html.dark .faq-item:hover {
  border-color: #3C7DE8 !important;
}

html.dark .faq-question {
  color: #FFFFFF !important;
}

html.dark .faq-question:hover {
  color: var(--accent) !important;
}

html.dark .faq-question .faq-icon {
  background: rgba(82, 143, 247, 0.2) !important;
  color: #7BC7FF !important;
}

html.dark .faq-item.active .faq-question .faq-icon {
  background: var(--primary) !important;
  color: #FFFFFF !important;
}

html.dark .faq-answer {
  color: #CBD5E1 !important;
}

html.dark .faq-answer strong {
  color: #FFFFFF !important;
}

/* Tables in Dark Mode */
html.dark table {
  border-color: #27354A !important;
}

html.dark th, 
html.dark td {
  border-color: #27354A !important;
}

html.dark thead tr {
  background-color: #1E293B !important;
  color: #FFFFFF !important;
}

html.dark tbody tr.bg-slate-50 {
  background-color: #0F172A !important;
}

html.dark tbody tr td {
  color: #E2E8F0 !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Responsive Container with Generous Side Margins */
.container-custom {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem; /* 16px on compact mobile screens */
}

@media (min-width: 640px) {
  .container-custom {
    padding: 0 1.5rem; /* 24px small tablet / large phone */
  }
}

@media (min-width: 768px) {
  .container-custom {
    padding: 0 2.5rem; /* 40px tablet */
  }
}

@media (min-width: 1200px) {
  .container-custom {
    padding: 0 3.5rem; /* 56px wide screen side margins */
  }
}

/* Navbar */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8125rem; /* 13px */
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap !important; /* Force Single Line */
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

/* Badges */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-orange, .badge-blue {
  background-color: #F0F6FF;
  color: #3B82F6;
  border: 1px solid #BFDBFE;
}

html.dark .badge-orange, html.dark .badge-blue {
  background-color: #172554;
  color: #93C5FD;
  border-color: #1E3A8A;
}

.badge-green {
  background-color: #ECFDF5;
  color: #059669;
  border: 1px solid #D1FAE5;
}

html.dark .badge-green {
  background-color: #06281E;
  color: #34D399;
  border-color: #0B523E;
}

/* Cards */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
  transition: all 0.2s ease;
}

.calc-card:hover {
  box-shadow: var(--shadow-lg);
}

/* Form Inputs */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.375rem;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9375rem;
  pointer-events: none;
}

.input-suffix {
  position: absolute;
  right: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--input-text);
  background-color: var(--input-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.15s ease-in-out;
}

.form-control.has-prefix {
  padding-left: 2rem;
}

.form-control.has-suffix {
  padding-right: 2.5rem;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(82, 143, 247, 0.25);
}

/* Select */
.form-select {
  width: 100%;
  padding: 0.65rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--input-text);
  background-color: var(--input-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(82, 143, 247, 0.25);
}

/* Switches / Toggles */
.toggle-switch {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 0.75rem;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: #94A3B8;
  border-radius: 24px;
  transition: 0.2s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Results Card (Always High-Contrast Dark Gradient) */
.results-card {
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%) !important;
  color: #FFFFFF !important;
  border: 1px solid #334155 !important;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-xl);
  position: sticky;
  top: 5rem;
}

.profit-stat {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #10B981;
}

.profit-stat.negative {
  color: #EF4444;
}

/* Breakdown Line Item - Ultra High Readability */
.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.875rem;
}

.breakdown-row:last-child {
  border-bottom: none;
}

.breakdown-row .label {
  color: #CBD5E1; /* High contrast light slate */
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}

.breakdown-row .val {
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #FFFFFF !important; /* 100% Crisp White */
  font-size: 0.9375rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Tool Grid Cards with Breathing Room */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem; /* Generous gap between cards */
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

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

.tool-card .icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}

.btn-secondary:hover {
  border-color: var(--primary);
}

/* FAQ Accordion Component */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.2s ease;
  margin-bottom: 0.75rem;
}

.faq-item:hover {
  border-color: rgba(82, 143, 247, 0.4);
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  gap: 1rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.faq-question:hover {
  color: var(--primary);
}

.faq-question .faq-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(82, 143, 247, 0.1);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.25s ease, background-color 0.15s ease;
}

.faq-item.active .faq-question .faq-icon {
  transform: rotate(45deg);
  background: var(--primary);
  color: #FFFFFF;
}

.faq-answer {
  display: none;
  padding: 0 1.25rem 1.25rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  border-top: 1px solid transparent;
}

.faq-item.active .faq-answer {
  display: block;
}

/* Floating Bottom Right Controls (Dark Mode & History) */
.floating-bottom-bar {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  padding: 0.35rem 0.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-bottom-bar:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.5);
}

.fab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #FFFFFF;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  user-select: none;
  text-decoration: none;
}

.fab-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.fab-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.2);
}

/* Calculation History Slide-out Drawer */
.history-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  background: #0F172A;
  color: #FFFFFF;
  border-left: 1px solid #334155;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.history-drawer.open {
  right: 0;
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
}

.history-overlay.open {
  display: block;
}

/* Print Styles */
@media print {
  .navbar, .floating-bottom-bar, .history-drawer, .history-overlay, footer, .ad-banner {
    display: none !important;
  }
}

/* Mobile-Specific Responsive Optimizations */
@media (max-width: 768px) {
  /* Prevent iOS automatic zoom on form input focus by guaranteeing 16px minimum font size */
  .form-control,
  .form-select,
  input[type="text"],
  input[type="number"],
  select {
    font-size: 16px !important;
  }

  /* Unstick sticky results card on mobile to prevent blocking user scrolling */
  .results-card {
    position: static !important;
    top: auto !important;
    margin-top: 1.5rem !important;
    padding: 1.25rem !important;
  }

  .profit-stat {
    font-size: 2rem !important;
  }

  /* Make data tables scroll smoothly horizontally with subtle scroll indicator */
  .overflow-x-auto,
  table {
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure history drawer fits 100% of mobile viewport comfortably */
  .history-drawer {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Compact floating bottom right controls on small screens */
  .floating-bottom-bar {
    bottom: 1rem !important;
    right: 1rem !important;
    padding: 0.25rem 0.4rem !important;
  }

  .fab-btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.7rem !important;
  }

  /* Touch-friendly buttons and toggles */
  .toggle-switch {
    min-height: 40px;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  /* FAQ Accordion compact padding on phones */
  .faq-question {
    padding: 0.85rem 1rem !important;
    font-size: 0.9rem !important;
  }

  .faq-answer {
    padding: 0 1rem 1rem 1rem !important;
    font-size: 0.825rem !important;
  }

  /* Mobile Header Menu: Compact, cleanly organized dropdown that does NOT dominate the whole screen */
  #mobileDrawer {
    max-height: 60vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1) !important;
    border-radius: 0 0 16px 16px !important;
    padding: 0.75rem !important;
  }

  #mobileDrawer a {
    padding: 0.6rem 0.85rem !important;
    font-size: 0.85rem !important;
    border-radius: 10px !important;
    line-height: 1.3 !important;
  }

  /* Mobile Logo Sizing: Crisp and prominent on mobile devices */
  .navbar .brand-logo-img {
    height: 72px !important;
    max-height: 72px !important;
    width: auto !important;
    padding: 2px 0 !important;
  }
}
