/* Shared UI layer for accessibility and cross-page consistency */
:root {
  --focus-ring: rgba(21, 94, 117, 0.28);
}

body.has-sidebar {
  overflow-x: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.app-main {
  min-width: 0;
}

.app-main .container {
  max-width: 1220px;
}

.sidebar {
  position: sticky;
  top: 14px;
  align-self: start;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  padding: 14px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-title {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0f172a;
}

.sidebar-close {
  display: none;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-weight: 800;
  cursor: pointer;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-nav form {
  margin: 0;
}

.sidebar-nav button.sidebar-link {
  width: 100%;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.sidebar-link {
  display: block;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 11px;
  text-decoration: none;
  color: #0f172a;
  font-weight: 700;
  font-size: 13px;
}

.sidebar-link:hover {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.85);
}

.sidebar-link.active {
  border-color: rgba(21, 94, 117, 0.36);
  background: rgba(21, 94, 117, 0.11);
  color: #155e75;
}

body.has-sidebar .top {
  margin-bottom: 18px !important;
}

body.has-sidebar .top h1 {
  margin-top: 4px;
}

body.has-sidebar .meta {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  padding: 8px 10px;
  display: inline-block;
}

body.has-sidebar .card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.9));
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.11) !important;
}

body.has-sidebar .card-header {
  padding: 14px 16px !important;
}

body.has-sidebar .card-body {
  padding: 16px !important;
}

body.has-sidebar input,
body.has-sidebar select,
body.has-sidebar textarea {
  min-height: 42px;
}

body.has-sidebar table {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
}

body.has-sidebar thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fbfc !important;
}

body.has-sidebar tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.015);
}

body.has-sidebar .sidebar-toggle {
  margin-bottom: 8px;
}

.sidebar-toggle {
  display: none;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
}

* {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.lang-toggle {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 9999;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: #ffffff;
  color: #0f172a;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.15);
  cursor: pointer;
}

.lang-toggle:hover {
  border-color: rgba(21, 94, 117, 0.4);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 680px) {
  .lang-toggle {
    right: 10px;
    bottom: 10px;
    padding: 9px 11px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    max-width: 320px;
    border-radius: 0 16px 16px 0;
    border-left: 0;
    z-index: 9998;
    transform: translateX(-104%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding-top: 18px;
  }

  body.has-sidebar .meta {
    display: block;
    margin-top: 8px;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

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

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

  body.sidebar-locked {
    overflow: hidden;
  }
}

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