/* ==========================================================================
   CalcHub Senior UI/UX Theme & Animation Stylesheet (Cool Palette Edition)
   - Strictly COOL Color Palette: Deep Obsidian, Ice Cyan, Emerald, Electric Indigo
   - Zero Warm Colors (No reds, oranges, yellows, peaches, or browns)
   - Micro-interactions, Glassmorphism, Unit Switchers & Inline Helpers
   - Mobile-First Zero-Horizontal-Overflow Responsive Layout System
   ========================================================================== */

:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-subtle: rgba(203, 213, 225, 0.8);
  --accent-primary: #0284c7;    /* Cool Sky Blue */
  --accent-secondary: #06b6d4;  /* Electric Cyan */
  --accent-success: #059669;    /* Mint Emerald */
  --accent-indigo: #4f46e5;     /* Deep Indigo */
  --slider-track: #e2e8f0;
}

html.dark {
  --bg-primary: #080c14;        /* Deep Space Obsidian */
  --bg-surface: #0f172a;        /* Midnight Slate */
  --bg-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --accent-primary: #38bdf8;    /* Luminous Sky */
  --accent-secondary: #22d3ee;  /* Luminous Cyan */
  --accent-success: #10b981;    /* Aurora Emerald */
  --accent-indigo: #818cf8;     /* Cyber Indigo */
  --slider-track: #1e293b;
}

/* Zero Horizontal Overflow Shield */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  transition: background-color 0.25s ease, color 0.25s ease;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Ensure all flex and grid children can shrink below content size */
.premium-card, main, section, article, header, nav, div {
  min-width: 0;
}

/* Media element constraints */
img, canvas, svg, video {
  max-width: 100%;
  height: auto;
}

/* Form element protection */
input, select, textarea {
  max-width: 100%;
}

/* Clean Cool Premium Cards */
.premium-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

html.dark .premium-card {
  box-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

html.dark .premium-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 0 20px 0 rgba(34, 211, 238, 0.12);
  transform: translateY(-2px);
}

html:not(.dark) .premium-card:hover {
  border-color: rgba(2, 132, 199, 0.3);
  box-shadow: 0 12px 24px -4px rgba(15, 23, 42, 0.06), 0 4px 6px -2px rgba(15, 23, 42, 0.03);
  transform: translateY(-2px);
}

/* Zero-Clipping Number Input Protection (Eliminates hidden arrows taking up width) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Custom Range Slider (Cool Theme with Tactile Click, Hold & Drag Feel) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: var(--slider-track);
  height: 10px;
  border-radius: 9999px;
  outline: none;
  transition: background 0.2s ease;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  touch-action: none; /* Prevents mobile scroll from intercepting slider drag */
  user-select: none;
  -webkit-user-select: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0284c7;
  cursor: grab;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.45);
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease, background-color 0.15s ease;
  touch-action: none;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.28);
  box-shadow: 0 0 0 8px rgba(2, 132, 199, 0.22), 0 4px 14px rgba(2, 132, 199, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0284c7;
  cursor: grab;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.45);
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease, background-color 0.15s ease;
  touch-action: none;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.28);
  box-shadow: 0 0 0 8px rgba(2, 132, 199, 0.22), 0 4px 14px rgba(2, 132, 199, 0.5);
}

html.dark input[type="range"]::-webkit-slider-thumb {
  background: #06b6d4;
  border: 3px solid #0b0f19;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.6);
}

html.dark input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.28);
  box-shadow: 0 0 0 8px rgba(6, 182, 212, 0.28), 0 0 22px rgba(6, 182, 212, 0.9);
}

html.dark input[type="range"]::-moz-range-thumb {
  background: #06b6d4;
  border: 3px solid #0b0f19;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.6);
}

html.dark input[type="range"]::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.28);
  box-shadow: 0 0 0 8px rgba(6, 182, 212, 0.28), 0 0 22px rgba(6, 182, 212, 0.9);
}

/* Glassmorphism Top Navigation */
.nav-blur {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Toast Notification (Cool Slate / Cyan) */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: calc(100vw - 48px);
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* Inline Helper Tooltips */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--slider-track);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}

/* Hidden Ad Container (Zero visual clutter before approval) */
.ad-slot-container {
  display: none !important;
}

body.ads-active .ad-slot-container {
  display: block !important;
}

/* Cool Unit Toggle Switch (e.g. Metric vs Imperial) */
.unit-toggle {
  display: inline-flex;
  padding: 3px;
  background-color: var(--bg-subtle);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  max-width: 100%;
}

.unit-toggle-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  transition: all 0.2s ease;
  color: var(--text-muted);
  white-space: nowrap;
}

.unit-toggle-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

html.dark .unit-toggle-btn.active {
  background-color: #1e293b;
  color: #38bdf8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Responsive Table Wrapper */
.table-scroll-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  direction: ltr;
}

.table-scroll-container::-webkit-scrollbar {
  height: 6px;
}

.table-scroll-container::-webkit-scrollbar-track {
  background: var(--slider-track);
  border-radius: 9999px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 9999px;
}

/* Mobile Layout Tweaks (< 640px) */
@media (max-width: 639px) {
  .unit-toggle {
    display: flex;
    width: 100%;
  }
  .unit-toggle-btn {
    flex: 1 1 0%;
    text-align: center;
    padding: 6px 4px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .toast-notification {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
    justify-content: center;
  }
}

/* ========================================================
   CATEGORY FILTER BUTTONS (Home Search Selection)
   100% Reliable Contrast & Active States in Light & Dark Modes
   Prevents touch-hover conflicts and invisible text
   ======================================================== */
.filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Inactive State - Light Mode (High contrast dark slate text on white) */
.filter-btn:not(.active) {
  background-color: #ffffff !important;
  color: #334155 !important; /* slate-700 */
  border: 1px solid #cbd5e1 !important; /* slate-300 */
  font-weight: 700 !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.filter-btn:not(.active):hover {
  background-color: #f1f5f9 !important; /* slate-100 */
  color: #0f172a !important; /* slate-900 */
  border-color: #94a3b8 !important; /* slate-400 */
}

/* Inactive State - Dark Mode */
.dark .filter-btn:not(.active) {
  background-color: #111827 !important; /* obsidian-800 */
  color: #cbd5e1 !important; /* slate-300 */
  border: 1px solid #334155 !important; /* slate-700 */
  box-shadow: none;
}

.dark .filter-btn:not(.active):hover {
  background-color: #1e293b !important; /* slate-800 */
  color: #ffffff !important;
  border-color: #475569 !important;
}

/* Active State - Light Mode (Crisp Slate-900 with Pure White Text) */
.filter-btn.active {
  background-color: #0f172a !important; /* slate-900 */
  color: #ffffff !important;
  border: 1px solid #0f172a !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.2), 0 2px 4px -2px rgba(15, 23, 42, 0.2) !important;
}

.filter-btn.active:hover {
  background-color: #1e293b !important; /* slate-800 */
  color: #ffffff !important;
  border: 1px solid #1e293b !important;
}

/* Active State - Dark Mode (Electric Cyan-500 with Deep Slate-950 Text & Cyan Glow) */
.dark .filter-btn.active {
  background-color: #06b6d4 !important; /* cyan-500 */
  color: #020617 !important; /* slate-950 */
  border: 1px solid #06b6d4 !important;
  font-weight: 800 !important;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.45) !important;
}

.dark .filter-btn.active:hover {
  background-color: #22d3ee !important; /* cyan-400 */
  color: #020617 !important;
  border: 1px solid #22d3ee !important;
}

/* ========================================================
   OFFICIAL PRINT & PDF EXPORT STYLING (TheCalcHQ)
   Generates crisp white professional documentation
   ======================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 12pt !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  header, footer, nav, .nav-blur, #mobileMenu, #mobileMenuBtn,
  .language-selector-mount, .currency-selector-mount, .theme-toggle-mount,
  .no-print, button, input[type="range"], .tab-buttons {
    display: none !important;
  }
  .premium-card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #0f172a !important;
    page-break-inside: avoid;
  }
  .print-header {
    display: block !important;
    border-bottom: 2px solid #06b6d4;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }
  a {
    text-decoration: none !important;
    color: inherit !important;
  }
}
@media screen {
  .print-header {
    display: none;
  }
}
