/* ==========================================================================
   SuperToolsX — Unified Production Design System
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2eaf5;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #475569;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 24px rgba(24, 54, 99, 0.07);
  --radius-sm: 11px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

html {
  font-family: 'Plus Jakarta Sans', 'Noto Kufi Arabic', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.has-mobile-nav {
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 1024px) {
  body.has-mobile-nav {
    padding-bottom: 0;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  max-width: 100%;
}

img, video, canvas, svg {
  max-width: 100%;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.42);
  outline-offset: 3px;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 3px 18px rgba(20, 48, 90, 0.045);
  padding: 0.75rem 1rem;
}

.header-container {
  width: min(100%, 1240px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  flex-shrink: 0;
}

.logo-wrap svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.search-bar-wrap {
  position: relative;
  flex: 1;
  max-width: 460px;
}

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

.search-bar-wrap input {
  width: 100%;
  padding-block: 0.6rem;
  padding-inline-start: 2.5rem;
  padding-inline-end: 1rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  outline: none;
  font-size: 0.88rem;
  text-align: start;
  transition: all 0.2s ease;
}

.search-bar-wrap input:focus {
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.header-actions {
  display: none;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 768px) {
  .header-actions {
    display: flex;
  }
}

.nav-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-sub);
  transition: color 0.15s;
}

.nav-link:hover {
  color: var(--primary);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  min-height: 44px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

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

/* Language Switcher */
.language {
  position: relative;
}

.language-toggle {
  height: 38px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: 10px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
}

.language-menu {
  display: none;
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  width: 185px;
  padding: 7px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.language-menu.open {
  display: grid;
}

.language-menu a {
  padding: 9px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: start;
}

.language-menu a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero-section {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  margin-top: 1.5rem;
  padding-inline: 1rem;
}

.hero-card {
  background: linear-gradient(125deg, #f7faff 0%, #edf3ff 100%);
  border: 1px solid #dce7fb;
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  box-shadow: 0 12px 34px rgba(37, 99, 235, 0.065);
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: center;
}

@media (min-width: 1024px) {
  .hero-card {
    grid-template-columns: 1.2fr 0.8fr;
    padding: 3rem 2.5rem;
  }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  background: #ffffff;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 0.8rem;
  border: 1px solid #bfdbfe;
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.035em;
  margin-bottom: 0.75rem;
  overflow-wrap: break-word;
}

@media (min-width: 640px) {
  .hero-title {
    font-size: 2.25rem;
  }
}

.hero-title span {
  color: var(--primary);
}

.hero-subtitle {
  font-size: 0.92rem;
  color: var(--text-sub);
  margin-bottom: 1.25rem;
  max-width: 540px;
}

.hero-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   Layout, Sidebar & Grids
   ========================================================================== */

.main-layout {
  width: min(100%, 1240px);
  margin: 1.5rem auto;
  padding-inline: 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .main-layout {
    flex-direction: row;
    align-items: flex-start;
  }
}

.content-area {
  flex: 1;
  min-width: 0;
}

.sidebar {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .sidebar {
    width: 320px;
    flex-shrink: 0;
    position: sticky;
    top: 5rem;
  }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-link {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

@media (min-width: 540px) {
  .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 840px) {
  .tools-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ==========================================================================
   Tool Cards
   ========================================================================== */

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 14px rgba(28, 61, 110, 0.045);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
  text-align: start;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: #b7cdf9;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.10);
}

.tool-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.icon-blue   { background: #eff6ff; color: #2563eb; }
.icon-green  { background: #f0fdf4; color: #16a34a; }
.icon-amber  { background: #fffbeb; color: #d97706; }
.icon-purple { background: #faf5ff; color: #9333ea; }
.icon-cyan   { background: #ecfeff; color: #0891b2; }
.icon-indigo { background: #eef2ff; color: #4f46e5; }
.icon-red    { background: #fef2f2; color: #dc2626; }

.tool-arrow {
  color: #cbd5e1;
  font-weight: 700;
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.tool-card:hover .tool-arrow {
  transform: translateX(4px);
  color: var(--primary);
}

.tool-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.tool-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ==========================================================================
   Tool Workspaces, Surfaces & Controls
   ========================================================================== */

.calc-card, .tool-workspace, .loan-card, .b64-card, .json-card, .case-card,
.pct-card, .pwd-card, .qr-card, .ic-workspace, .cv-card, .wc-card,
.contact-card, .about-card, .policy-card, .terms-card, .cookie-card,
.security-card, .hub-card, .offline-card, .sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 0;
}

input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea,
.calc-input-field, .loan-input-num, .pct-input-field, .qr-input, .qr-select, .qr-textarea,
.case-textarea, .wc-textarea, .ic-select {
  border: 1px solid #d7e1ef;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  outline: none;
  background: #ffffff;
}

button, .btn-secondary, .btn-calc, .btn-reset, .btn-add-course,
.tool-btn, .case-btn, .wc-btn, .cv-btn, .ic-btn, .pct-tab-btn, .pwd-tab-btn,
.b64-tab-btn, .qr-tab-btn, .unit-tab-btn {
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.sidebar-widget {
  padding: 1.25rem;
}

.widget-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.widget-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.widget-text {
  font-size: 0.8rem;
  color: var(--text-sub);
  line-height: 1.45;
}

.widget-link {
  display: inline-block;
  margin-top: 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

/* ==========================================================================
   Ad Placements & Placeholders
   ========================================================================== */

.ad-slot-container, .ad-slot-sidebar, .cv-ad {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: #f8fbff;
  border: 1px dashed #d7e2f1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
}

.ad-slot-sidebar {
  min-height: 250px;
}

.ad-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ad-placeholder-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.no-results-msg {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
}

.no-results-msg h4 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.no-results-msg p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Footer & Mobile Navigation
   ========================================================================== */

.site-footer {
  margin-top: auto;
  background: #0f172a;
  color: #94a3b8;
  padding: 2.5rem 1rem;
  text-align: center;
  border-top: 1px solid #1e293b;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}

.footer-links a:hover {
  color: #ffffff;
}

.footer-copy {
  font-size: 0.75rem;
  color: #64748b;
}

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom, 0px)) 0;
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-md);
  transition: color 0.15s;
}

.bottom-nav-item.active, .bottom-nav-item:hover {
  color: var(--primary);
}

.bottom-nav-icon {
  font-size: 1.1rem;
}

/* ==========================================================================
   RTL Rules (العربية)
   ========================================================================== */

[dir="rtl"] .tool-card:hover .tool-arrow {
  transform: translateX(-4px);
}

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

/* ==========================================================================
   Responsive Adaptability & Performance
   ========================================================================== */

@media (max-width: 767px) {
  .site-header { padding: 0.7rem 0.85rem; }
  .hero-section { padding-inline: 0.85rem; }
  .hero-card { border-radius: 19px; padding: 1.25rem 1rem; }
  .hero-title { font-size: clamp(1.55rem, 6.8vw, 2.1rem); line-height: 1.2; }
  .main-layout { padding-inline: 0.85rem; gap: 1rem; }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .tool-card { min-width: 0; min-height: auto; padding: 0.85rem; }
  .sidebar, .ad-slot-sidebar { display: none !important; }
}

@media (max-width: 359px) {
  .tools-grid { grid-template-columns: 1fr; }
  .tool-card { padding: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}