/* Datakar shared shell — global header, search, navigation and cross-app UI rules */

:root {
  --dk-bg: var(--color-bg, #fafafa);
  --dk-surface: var(--color-surface, #ffffff);
  --dk-text: var(--color-text, #222222);
  --dk-muted: var(--color-muted, #666666);
  --dk-border: var(--color-border, #e0e0e0);
  --dk-accent: var(--color-primary, #e67e22);
  --dk-accent-hover: var(--color-primary-light, #d96f16);
  --dk-radius: 10px;
  --dk-header-max: 1180px;
}

.global-header {
  position: relative;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--dk-surface);
  border-bottom: 1px solid var(--dk-border);
}

.global-nav {
  width: min(100%, var(--dk-header-max));
  min-height: 48px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.global-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  color: inherit;
  text-decoration: none;
}

.global-brand img {
  display: block;
  width: auto;
  height: 2rem;
}

.global-header-tools {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.global-desktop-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  white-space: nowrap;
}

.global-desktop-links a {
  color: var(--dk-muted);
  text-decoration: none;
  font-size: 0.94rem;
}

.global-desktop-links a:hover,
.global-desktop-links a:focus-visible {
  color: var(--dk-text);
}

.global-search {
  position: relative;
  width: min(320px, 30vw);
  min-width: 210px;
}

.global-search-input {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 2.35rem 0.55rem 0.8rem;
  border: 1px solid var(--dk-border);
  border-radius: 999px;
  background: var(--dk-bg);
  color: var(--dk-text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}

.global-search-input::placeholder {
  color: var(--dk-muted);
  opacity: 0.92;
}

.global-search-input:focus {
  border-color: color-mix(in srgb, var(--dk-text) 45%, var(--dk-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dk-text) 7%, transparent);
}

.global-search-icon {
  position: absolute;
  inset-inline-start: 0.85rem;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--dk-muted);
}

.global-search-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 0.45rem);
  z-index: 160;
  max-height: min(420px, 70vh);
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid var(--dk-border);
  border-radius: 12px;
  background: var(--dk-surface);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.12);
}

.global-search-results[hidden] {
  display: none;
}

.global-search-result {
  width: 100%;
  display: grid;
  gap: 0.1rem;
  padding: 0.7rem 0.8rem;
  border-radius: 9px;
  color: var(--dk-text);
  text-decoration: none;
}

.global-search-result:hover,
.global-search-result:focus-visible,
.global-search-result.is-active {
  background: color-mix(in srgb, var(--dk-text) 6%, transparent);
}

.global-search-result strong {
  font-size: 0.95rem;
  line-height: 1.45;
}

.global-search-result small {
  color: var(--dk-muted);
  font-size: 0.79rem;
  line-height: 1.4;
}

.global-menu-button,
.global-menu-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--dk-text);
  cursor: pointer;
}

.global-menu-button {
  flex-direction: column;
  gap: 4px;
}

.global-menu-button span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.global-menu-close {
  font-size: 1.7rem;
  line-height: 1;
}

.global-menu-button:hover,
.global-menu-button:focus-visible,
.global-menu-close:hover,
.global-menu-close:focus-visible {
  background: color-mix(in srgb, var(--dk-text) 7%, transparent);
}

.global-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.global-nav-backdrop[hidden] {
  display: none;
}

.global-nav-backdrop.is-open {
  opacity: 1;
}

.global-nav-drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 150;
  width: min(320px, 86vw);
  display: flex;
  flex-direction: column;
  padding: 0.8rem;
  background: var(--dk-surface);
  border-inline-end: 1px solid var(--dk-border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0.2s ease;
}

.global-nav-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.global-drawer-header {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.15rem 0.35rem 0.75rem;
  border-bottom: 1px solid var(--dk-border);
}

.global-drawer-nav {
  display: grid;
  gap: 0.25rem;
  padding-block: 0.8rem;
}

.global-drawer-nav a {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding-inline: 0.85rem;
  border-radius: 10px;
  color: var(--dk-text);
  text-decoration: none;
  font-weight: 700;
}

.global-drawer-nav a:hover,
.global-drawer-nav a:focus-visible {
  background: color-mix(in srgb, var(--dk-text) 7%, transparent);
}

.global-drawer-footer {
  margin-top: auto;
  padding: 0.9rem 0.85rem 0.35rem;
  border-top: 1px solid var(--dk-border);
  color: var(--dk-muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

body.global-menu-open {
  overflow: hidden;
}

/* Harmonize cross-app links */
#more-apps,
.all-apps-link {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: var(--dk-muted);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

#more-apps:hover,
#more-apps:focus-visible,
.all-apps-link:hover,
.all-apps-link:focus-visible {
  color: var(--dk-text);
}

/* Keep dark mode neutral: black/white shades, no forced orange/green. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --color-primary: #f2f2f2 !important;
    --color-primary-light: #ffffff !important;
    --color-complementary: #8d8d8d !important;
    --color-bg: #111111 !important;
    --color-surface: #191919 !important;
    --color-text: #f3f3f3 !important;
    --color-muted: #b8b8b8 !important;
    --color-border: #343434 !important;
    --dk-bg: #111111;
    --dk-surface: #191919;
    --dk-text: #f3f3f3;
    --dk-muted: #b8b8b8;
    --dk-border: #343434;
    --dk-accent: #f2f2f2;
    --dk-accent-hover: #ffffff;
  }

  body,
  header,
  footer,
  section,
  .app-item,
  .results,
  .table-wrapper,
  .qr-result,
  .barcode-result,
  .converter-card,
  .info-card,
  .law-summary {
    border-color: var(--dk-border);
  }

  a:not(.app-button):not([class*="download"]),
  #intro-section a,
  .language-hint-link,
  .footer-language-button.active,
  .language-button.active {
    color: var(--dk-text);
  }

  .heading-with-bar::before {
    background: #8d8d8d !important;
  }

  .app-button,
  #calculate-button,
  #generate-button,
  button.primary,
  .primary-button {
    background: #f1f1f1 !important;
    color: #111111 !important;
  }

  .app-button:hover,
  .app-button:focus-visible,
  #calculate-button:hover,
  #calculate-button:focus-visible,
  #generate-button:hover,
  #generate-button:focus-visible,
  button.primary:hover,
  button.primary:focus-visible,
  .primary-button:hover,
  .primary-button:focus-visible {
    background: #ffffff !important;
    color: #000000 !important;
  }

  input,
  textarea,
  select {
    background: #151515;
    color: var(--dk-text);
    border-color: var(--dk-border);
  }
}

@media (max-width: 760px) {
  .global-header {
    position: sticky;
    top: 0;
    padding: 0.58rem 0.75rem;
    background: color-mix(in srgb, var(--dk-surface) 95%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .global-nav {
    gap: 0.55rem;
  }

  .global-desktop-links {
    display: none;
  }

  .global-header-tools {
    flex: 1;
  }

  .global-search {
    width: 100%;
    min-width: 0;
  }

  .global-search-input {
    min-height: 42px;
    font-size: 0.88rem;
  }

  .global-menu-button,
  .global-menu-close {
    display: inline-flex;
  }

  .global-brand img {
    height: 1.9rem;
  }
}

@media (max-width: 420px) {
  .global-search-input {
    padding-inline-end: 0.62rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .global-nav-drawer,
  .global-nav-backdrop {
    transition: none;
  }
}
