:root {
  /* Premium HSL Color System - Light Mode */
  --bg-primary: hsl(220, 30%, 96%);
  --bg-secondary: hsl(220, 25%, 98%);
  --card-bg: hsla(0, 0%, 100%, 0.8);
  --card-border: hsla(220, 20%, 80%, 0.5);
  --text-primary: hsl(220, 40%, 15%);
  --text-secondary: hsl(220, 15%, 40%);
  --text-muted: hsl(220, 10%, 60%);
  
  --accent-primary: hsl(18, 80%, 63%);
  --accent-secondary: hsl(18, 70%, 55%);
  --accent-hover: hsl(18, 80%, 50%);
  --accent-glow: hsla(18, 80%, 63%, 0.15);
  
  --success: hsl(142, 70%, 45%);
  --error: hsl(0, 75%, 60%);
  
  --glass-bg: hsla(220, 30%, 98%, 0.85);
  --glass-border: hsla(0, 0%, 100%, 0.5);
  
  --shadow-sm: 0 4px 12px hsla(220, 40%, 15%, 0.05);
  --shadow-md: 0 12px 24px hsla(220, 40%, 15%, 0.1);
  --shadow-lg: 0 20px 40px hsla(220, 40%, 15%, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --sidebar-width: 280px;
  --header-height: 64px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[dir="rtl"] {
  --sidebar-width: 280px;
}

[data-theme="dark"] {
  --bg-primary: hsl(222, 47%, 11%);
  --bg-secondary: hsl(222, 47%, 14%);
  --card-bg: hsla(222, 47%, 16%, 0.8);
  --card-border: hsla(222, 47%, 25%, 0.5);
  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 80%);
  --text-muted: hsl(215, 15%, 60%);
  
  --accent-hover: hsl(18, 80%, 50%);
  --glass-bg: hsla(222, 47%, 11%, 0.9);
  --glass-border: hsla(222, 47%, 25%, 0.3);
  
  --shadow-sm: 0 4px 12px hsla(0, 0%, 0%, 0.2);
  --shadow-md: 0 12px 24px hsla(0, 0%, 0%, 0.3);
  --shadow-lg: 0 20px 40px hsla(0, 0%, 0%, 0.4);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  line-height: 1.6;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

[lang="ar"], [lang="ur"] {
  font-family: 'Noto Sans Arabic', sans-serif;
  line-height: 1.8;
  letter-spacing: 0 !important;
}

[lang="ar"] h1, [lang="ar"] h2, [lang="ar"] h3, [lang="ar"] h4, [lang="ar"] h5, [lang="ar"] h6,
[lang="ur"] h1, [lang="ur"] h2, [lang="ur"] h3, [lang="ur"] h4, [lang="ur"] h5, [lang="ur"] h6 {
  font-family: 'Noto Sans Arabic', 'Space Grotesk', sans-serif;
}

[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-arrow-right,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-chevron-right {
  display: inline-block;
  transform: scaleX(-1);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Premium Background Atmosphere */
.atmos {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.atmos .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  animation: float 20s ease-in-out infinite;
  opacity: 0.4;
}

.o1 {
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, var(--accent-primary), transparent);
  top: -20%;
  left: -10%;
  animation-delay: 0s;
}

.o2 {
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, hsl(190, 80%, 60%), transparent);
  bottom: -10%;
  right: -5%;
  animation-delay: -5s;
}

.o3 {
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, hsl(260, 80%, 60%), transparent);
  top: 30%;
  left: 40%;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(4%, -6%) scale(1.1); }
  66% { transform: translate(-3%, 4%) scale(0.95); }
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: hsla(222, 47%, 11%, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-inline-end: 1px solid var(--card-border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
}

[dir="rtl"] .sidebar {
  border-inline-end: none;
  border-inline-start: 1px solid var(--card-border);
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sb-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--card-border);
  transition: opacity var(--transition-fast);
}

.sb-header:hover {
  opacity: 0.8;
}

.sb-logo {
  width: 36px;
  height: 36px;
  background: var(--accent-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-family: 'Space Grotesk';
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.sb-title {
  font-size: 1.1rem;
  color: var(--text-primary);
}

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sb-group-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 16px 12px 8px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.sb-link:hover {
  background: var(--accent-glow);
  color: var(--text-primary);
}

.sb-link.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
  border-color: hsla(18, 80%, 63%, 0.2);
}

.sb-link i {
  width: 20px;
  text-align: center;
  font-size: 0.9rem;
}

.sb-badge {
  margin-inline-start: auto;
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--bg-primary);
  border-radius: 6px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  margin-inline-start: var(--sidebar-width);
  min-height: 100vh;
  transition: margin var(--transition-slow);
}

.main-wrapper.full {
  margin-inline-start: 0;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 90;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.search-container {
  flex: 1;
  max-width: 500px;
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1.5px solid var(--card-border);
  padding: 10px 16px 10px 40px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

[dir="rtl"] .search-input {
  padding: 10px 40px 10px 16px;
}

.search-icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.lang-select {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
}

.lang-select:focus {
  border-color: var(--accent-primary);
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--card-border);
  color: var(--text-primary);
}

/* Glass Card */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Home Section */
.hero {
  padding: 60px 24px;
  text-align: center;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  line-height: 1.1;
  margin-bottom: 24px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary), hsl(340, 80%, 60%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 40px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 0 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.category-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 24px;
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.category-card:hover {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  transform: translateY(-4px);
}

.category-icon {
  width: 50px;
  height: 50px;
  background: var(--bg-secondary);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  margin: 0 auto 16px;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
}

.category-card:hover .category-icon {
  background: var(--accent-primary);
  color: white;
  transform: rotate(10deg);
}

/* Converter UI */
.converter-container {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 24px;
}

.conv-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.conv-title-wrap {
  flex: 1;
}

.conv-title {
  font-size: 1.5rem;
}

.conv-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.conv-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.big-input {
  width: 100%;
  background: var(--bg-primary);
  border: 2px solid var(--card-border);
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.big-input:focus {
  border-color: var(--accent-primary);
}

.result-box {
  background: var(--bg-secondary);
  border: 2px solid var(--accent-primary);
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  min-height: 70px;
  display: flex;
  align-items: center;
  cursor: pointer;
  word-break: break-all;
}

.unit-select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  padding: 12px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  outline: none;
}

.swap-btn-wrap {
  display: flex;
  justify-content: center;
  margin: -12px 0;
  z-index: 10;
}

.swap-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--accent-glow);
  transition: all var(--transition-fast);
}

.swap-btn:hover {
  transform: rotate(180deg) scale(1.1);
  box-shadow: 0 8px 20px var(--accent-glow);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease-out forwards;
}

.toast-success {
  border-inline-start: 4px solid var(--success);
}

.toast-error {
  border-inline-start: 4px solid var(--error);
}

.toast.fade-out {
  animation: none;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* Mobile Adjustments */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 20px 0 40px hsla(0, 0%, 0%, 0.2);
  }
  [dir="rtl"] .sidebar {
    transform: translateX(100%);
    box-shadow: -20px 0 40px hsla(0, 0%, 0%, 0.2);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-inline-start: 0;
  }
  .header {
    padding: 0 16px;
    justify-content: space-between;
  }
  #menuToggle {
    margin-inline-end: 12px;
  }
  .search-container {
    max-width: 180px;
  }
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
  }
  .footer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .info-title {
    font-size: 2.2rem;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 40px 16px;
  }
  .hero-title {
    font-size: 2.2rem;
  }
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px;
  }
  .category-card {
    padding: 16px;
  }
  .glass-card {
    padding: 20px;
  }
  .big-input, .result-box {
    font-size: 1.4rem;
    padding: 12px;
  }
  .conv-title {
    font-size: 1.25rem;
  }
  .header-actions {
    gap: 4px;
  }
  .lang-select {
    padding: 6px 4px;
    font-size: 0.8rem;
    max-width: 80px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
  }
  .search-container {
    max-width: 140px;
  }
}

[dir="rtl"] .sb-link i {
  margin-inline-end: 0;
  margin-inline-start: 12px;
}

[dir="rtl"] .conv-header {
  text-align: start;
}

[dir="rtl"] .input-label {
  text-align: start;
}

[dir="rtl"] .big-input, [dir="rtl"] .unit-select {
  text-align: start;
}

[dir="rtl"] .result-box {
  text-align: start;
}

[dir="rtl"] .sb-badge {
  margin-inline-start: 0;
  margin-inline-end: auto;
}

/* Footer Styles */
.footer {
  margin-top: 60px;
  padding: 60px 40px 30px;
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
}
.footer-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 15px;
  transition: transform var(--transition-fast);
}

.footer-logo:hover {
  transform: scale(1.05);
}
.footer-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}
.footer-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.footer-section a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s;
}
.footer-section a:hover {
  color: var(--accent-primary);
}
.footer-bottom {
  margin-top: 50px;
  padding-top: 25px;
  border-top: 1px solid var(--card-border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Informational Content Styles */
.info-content {
  max-width: 850px;
  margin: 0 auto;
  padding: 40px 20px;
  animation: fadeIn 0.4s ease-out;
}
.info-header {
  margin-bottom: 40px;
}
.info-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 15px;
}
.info-section {
  margin-bottom: 35px;
}
.info-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 15px;
  color: var(--accent-primary);
}
.info-section p, .info-section li {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 1.05rem;
  margin-bottom: 15px;
}
.info-section ul {
  margin: 20px 0;
  padding-inline-start: 20px;
  list-style: none;
}
.info-section li {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 1.05rem;
}
.info-section li i {
  font-size: 0.9rem;
  color: var(--accent-primary);
  opacity: 0.8;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Contact Form Styles */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 60px;
  margin-top: 40px;
}
.contact-info-card {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 24px;
  border: 1px solid var(--card-border);
}
.contact-form {
  display: grid;
  gap: 20px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-input {
  width: 100%;
  padding: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  transition: all 0.2s;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn-submit {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Space Grotesk', sans-serif;
}
.btn-submit:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr; gap: 30px; }
  .contact-grid { grid-template-columns: 1fr; gap: 40px; }
  .form-row { grid-template-columns: 1fr; }
  .info-title { font-size: 2.2rem; }
}

[dir="rtl"] .info-section, [dir="rtl"] .info-header {
  text-align: start;
}

[dir="rtl"] .footer-grid {
  text-align: start;
}

/* Sidebar Group Collapse Transition */
.sb-group-links {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}
.sb-group-links.collapsed {
  max-height: 0 !important;
}
.group-arrow {
  transition: transform var(--transition-fast);
}