/* DH Tools - Studio Pro Luxury Theme (Ultra Modern & Clean App Experience) */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+Devanagari:wght@400;500;600;700;800&display=swap');

:root {
  --font-display: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', 'Noto Sans Devanagari', system-ui, -apple-system, sans-serif;

  /* Theme Canvas */
  --canvas-bg: #f4f6fb;
  --canvas-surface: #ffffff;
  --canvas-subtle: #f8fafc;
  --canvas-muted: #eef2f6;

  /* Typography */
  --text-heading: #0f172a;
  --text-body: #334155;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;

  /* Brand Accents */
  --brand-primary: #4f46e5;
  --brand-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
  --brand-glow: rgba(79, 70, 229, 0.25);
  
  /* Category Colors */
  --cat-converters: #2563eb;
  --cat-financial: #059669;
  --cat-health: #e11d48;
  --cat-utility: #d97706;
  --cat-digital: #7c3aed;
  --cat-scientific: #0284c7;
  --cat-math: #9333ea;

  /* Borders & Shadows */
  --border-card: rgba(226, 232, 240, 0.9);
  --border-focus: #4f46e5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.08), 0 4px 12px -4px rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 20px 40px -12px rgba(79, 70, 229, 0.16), 0 8px 16px -6px rgba(15, 23, 42, 0.05);
  --shadow-drawer: 25px 0 60px -15px rgba(15, 23, 42, 0.18);

  --radius-card: 1.5rem;
  --radius-input: 0.875rem;
  --radius-btn: 0.875rem;
  --sidebar-width: 320px;
}

/* ==========================================================================
   DARK THEME PALETTE & DEEP GLASS
   ========================================================================== */
html.dark {
  --canvas-bg: #090e1a;
  --canvas-surface: #111a2e;
  --canvas-subtle: #16223b;
  --canvas-muted: #1c2b4a;

  --text-heading: #f8fafc;
  --text-body: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --border-card: rgba(51, 65, 85, 0.8);
  --border-focus: #6366f1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.75);
  --shadow-hover: 0 20px 40px -12px rgba(99, 102, 241, 0.35);
  --shadow-drawer: 25px 0 60px -15px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--canvas-bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(124, 58, 237, 0.05) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(37, 99, 235, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-body);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 5.5rem;
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
}

html.dark body {
  background-color: var(--canvas-bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.18) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(124, 58, 237, 0.14) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(37, 99, 235, 0.12) 0px, transparent 50%);
  color: var(--text-body);
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  color: var(--text-heading);
}

/* ==========================================================================
   SMART HIDE-ON-SCROLL HEADER & CATEGORY BAR
   ========================================================================== */
#smartHeaderWrap {
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.app-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02);
}

html.dark .app-header {
  background: rgba(17, 26, 46, 0.95);
  border-bottom: 1px solid rgba(51, 65, 85, 0.8);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.app-cat-bar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.75);
}

html.dark .app-cat-bar {
  background: rgba(17, 26, 46, 0.94);
  border-bottom: 1px solid rgba(51, 65, 85, 0.7);
}

/* ==========================================================================
   MOBILE STICKY BOTTOM NAVIGATION BAR (NATIVE APP FEEL)
   ========================================================================== */
#appBottomNav {
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.app-bottom-nav {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
  padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
}

html.dark .app-bottom-nav {
  background: rgba(17, 26, 46, 0.97);
  border-top: 1px solid rgba(51, 65, 85, 0.85);
  box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.55);
}

.bottom-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.75rem;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 700;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  cursor: pointer;
  flex: 1;
  text-align: center;
}

.bottom-tab-item i {
  font-size: 1.15rem;
  transition: transform 0.2s ease;
}

.bottom-tab-item.active, .bottom-tab-item:active {
  color: #4f46e5;
}

.bottom-tab-item.active i {
  transform: scale(1.12);
}

html.dark .bottom-tab-item {
  color: #94a3b8;
}

html.dark .bottom-tab-item.active, html.dark .bottom-tab-item:active {
  color: #818cf8;
}

.bottom-fab-btn {
  width: 3.25rem;
  height: 3.25rem;
  margin-top: -1.25rem;
  border-radius: 9999px;
  background: var(--brand-gradient);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px -2px rgba(79, 70, 229, 0.45);
  border: 3px solid #ffffff;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  cursor: pointer;
}

html.dark .bottom-fab-btn {
  border-color: #111a2e;
  box-shadow: 0 8px 24px -2px rgba(99, 102, 241, 0.55);
}

.bottom-fab-btn:hover, .bottom-fab-btn:active {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px -2px rgba(79, 70, 229, 0.6);
}

/* ==========================================================================
   STUDIO MODERN CARD WITH TOP ACCENT GLOW
   ========================================================================== */
.studio-card {
  background: var(--canvas-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.studio-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.studio-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(79, 70, 229, 0.45);
}

.studio-card:hover::before {
  opacity: 1;
}

html.dark .studio-card {
  background: var(--canvas-surface);
  border-color: var(--border-card);
}

html.dark .studio-card:hover {
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.7), 0 0 24px rgba(99, 102, 241, 0.25);
}

/* ==========================================================================
   SQUIRCLES & GRADIENTS
   ========================================================================== */
.icon-squircle {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
}

.studio-card:hover .icon-squircle {
  transform: scale(1.08) rotate(3deg);
}

.gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-bg {
  background: var(--brand-gradient);
}

/* ==========================================================================
   INPUTS & RANGE SLIDERS
   ========================================================================== */
.app-input, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-input);
  background: #ffffff;
  color: var(--text-heading);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  outline: none;
}

.app-input:focus, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus, select:focus, textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

html.dark .app-input, 
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), 
html.dark select, 
html.dark textarea {
  background: #0d1527 !important;
  border-color: rgba(51, 65, 85, 0.85) !important;
  color: #f8fafc !important;
}

html.dark .app-input:focus, 
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus, 
html.dark select:focus, 
html.dark textarea:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3) !important;
}

/* Range Sliders with Glowing Thumb */
input[type="range"] {
  -webkit-appearance: none;
  height: 8px;
  border-radius: 9999px;
  background: #e2e8f0;
  outline: none;
  width: 100%;
}

html.dark input[type="range"] {
  background: #1c2b4a;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4f46e5;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.45);
  border: 3px solid #ffffff;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

html.dark input[type="range"]::-webkit-slider-thumb {
  border-color: #111a2e;
  background: #6366f1;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.6);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #4338ca;
}

/* ==========================================================================
   CATEGORY FILTER PILLS
   ========================================================================== */
.cat-pill {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  cursor: pointer;
}

.cat-pill.active {
  background: var(--brand-primary) !important;
  color: #ffffff !important;
  border-color: var(--brand-primary) !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.32) !important;
}

html.dark .cat-pill:not(.active) {
  background: #111a2e !important;
  border-color: rgba(51, 65, 85, 0.8) !important;
  color: #cbd5e1 !important;
}

html.dark .cat-pill:not(.active):hover {
  background: #19243d !important;
  color: #ffffff !important;
  border-color: #6366f1 !important;
}

/* ==========================================================================
   SLIDE-OUT SIDEBAR DRAWER & BACKDROP
   ========================================================================== */
.sidebar-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  max-width: 86vw;
  height: 100vh;
  height: 100dvh;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-drawer);
  overflow-y: auto;
}

.sidebar-drawer.open {
  transform: translateX(0);
}

html.dark .sidebar-drawer {
  background: #111a2e;
  border-right-color: rgba(51, 65, 85, 0.85);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  transition: all 0.18s ease;
  cursor: pointer;
  text-decoration: none;
}

.sidebar-link:hover, .sidebar-link.active {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 700;
}

html.dark .sidebar-link {
  color: #94a3b8;
}

html.dark .sidebar-link:hover, html.dark .sidebar-link.active {
  background: #1c2b4a;
  color: #f8fafc;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff;
  font-weight: 700;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.35);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #ffffff;
  color: #1e293b;
  font-weight: 700;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  cursor: pointer;
}

html.dark .btn-secondary {
  background: #111a2e;
  color: #f8fafc;
  border-color: rgba(51, 65, 85, 0.85);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

html.dark .btn-secondary:hover {
  background: #16223b;
  border-color: #6366f1;
}

/* ==========================================================================
   CALCULATOR KEYPADS
   ========================================================================== */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}

.calc-btn {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  color: #0f172a;
  padding: 1.1rem 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  transition: all 0.15s ease;
}

html.dark .calc-btn {
  background: #111a2e;
  border-color: rgba(51, 65, 85, 0.85);
  color: #f8fafc;
}

.calc-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

html.dark .calc-btn:hover {
  background: #16223b;
  border-color: #6366f1;
}

.calc-btn:active {
  transform: scale(0.96);
  background: #f1f5f9;
}

.calc-btn-op {
  background: #eef2ff;
  color: #4f46e5;
  border-color: #c7d2fe;
}

html.dark .calc-btn-op {
  background: #1c2b4a;
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.4);
}

.calc-btn-accent {
  background: var(--brand-gradient);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* ==========================================================================
   DARK MODE COMPREHENSIVE TAILWIND COMPONENT OVERRIDES
   ========================================================================== */
html.dark .bg-white {
  background-color: var(--canvas-surface) !important;
}

html.dark .bg-slate-50, html.dark .bg-slate-50\/70, html.dark .bg-slate-50\/80 {
  background-color: #0d1527 !important;
}

html.dark .bg-slate-100 {
  background-color: #16223b !important;
}

html.dark .bg-slate-200\/60, html.dark .bg-slate-200\/70 {
  background-color: #1c2b4a !important;
}

html.dark .text-slate-900, html.dark .text-slate-800 {
  color: #f8fafc !important;
}

html.dark .text-slate-700, html.dark .text-slate-600 {
  color: #cbd5e1 !important;
}

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

html.dark .border-slate-200, 
html.dark .border-slate-200\/80, 
html.dark .border-slate-200\/60, 
html.dark .border-slate-200\/70, 
html.dark .border-slate-100 {
  border-color: rgba(51, 65, 85, 0.75) !important;
}

html.dark details[open] {
  background-color: #111a2e !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
}

/* ==========================================================================
   ANIMATION & UTILITY
   ========================================================================== */
.animate-fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.scrollbar-none::-webkit-scrollbar, .no-scrollbar::-webkit-scrollbar {
  display: none;
}
.scrollbar-none, .no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
