/* GlutenGo Admin Workspace
   Capa estructural del shell. Los estilos de cada módulo siguen en admin.css. */
:root {
  --workspace-rail: 88px;
  --workspace-context: 224px;
  --workspace-header: 82px;
  --workspace-bg: #f4f6f5;
  --workspace-surface: #ffffff;
  --workspace-line: #d9e0dc;
  --workspace-line-strong: #bdc9c2;
  --workspace-text: #1b2620;
  --workspace-muted: #627068;
  --workspace-green: #0d4d2b;
  --workspace-green-soft: #e8f4ec;
  --workspace-accent: #d95c32;
  --workspace-accent-soft: #fff1eb;
  --workspace-shadow: 0 8px 24px rgba(22, 34, 27, .09);
}

[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

#admin-app {
  min-height: 100dvh;
  background: var(--workspace-bg);
}

/* Primary area rail */
.top-bar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 160;
  display: flex;
  width: var(--workspace-rail);
  height: 100dvh;
  min-height: 0;
  padding: 12px 8px 10px;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  background: var(--workspace-surface);
  border: 0;
  border-right: 1px solid var(--workspace-line);
  box-shadow: none;
}

.top-bar::after {
  display: none;
}

.top-logo {
  display: grid;
  width: 100%;
  min-width: 0;
  justify-items: center;
  gap: 3px;
  font-family: "DM Sans", sans-serif;
  line-height: 1;
}

.top-logo span:last-child,
.workspace-brand-role {
  display: block !important;
  margin: 0 !important;
  color: #758279 !important;
  font: 700 9px/1.1 "DM Sans", sans-serif !important;
  letter-spacing: .04em !important;
  opacity: 1 !important;
  text-transform: uppercase;
}

.workspace-brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--workspace-green);
  color: #fff !important;
  font: 700 20px/1 "DM Sans", sans-serif;
}

.workspace-brand-name {
  color: var(--workspace-text) !important;
  font-size: 11px;
  font-weight: 700;
}

.workspace-area-nav {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.workspace-area-link,
.mobile-area-link {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #56635b;
  font: 700 10px/1.15 "DM Sans", sans-serif;
  cursor: pointer;
}

.workspace-area-link {
  display: flex;
  min-height: 54px;
  padding: 6px 2px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 6px;
  text-align: center;
}

.workspace-area-link svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.workspace-area-link:hover {
  background: #f1f4f2;
  color: var(--workspace-green);
}

.workspace-area-link.active {
  background: var(--workspace-accent-soft);
  border-color: #f2c8b8;
  color: #9f3c1d;
  box-shadow: inset 3px 0 0 var(--workspace-accent);
}

.top-right {
  display: flex;
  width: 100%;
  margin: auto 0 0;
  flex-direction: column;
  gap: 5px;
}

.top-badge {
  max-width: 100%;
  min-height: 28px;
  padding: 5px 3px;
  overflow: hidden;
  border: 0;
  background: #f1f4f2;
  color: var(--workspace-muted);
  font-size: 9px;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
}

.top-logout {
  display: flex;
  width: 100%;
  min-height: 38px;
  padding: 6px 2px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #6d3930;
  font-size: 9px;
}

.top-logout svg {
  width: 15px;
  height: 15px;
}

.top-logout:hover {
  border-color: #f1c5bd;
  background: #fff4f2;
}

/* Contextual view navigation */
.module-nav {
  position: fixed;
  inset: 0 auto 0 var(--workspace-rail);
  z-index: 150;
  display: block;
  width: var(--workspace-context);
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 18px 12px;
  overflow: hidden auto;
  background: #fbfcfb;
  border: 0;
  border-right: 1px solid var(--workspace-line);
  border-radius: 0;
  box-shadow: none;
  scrollbar-width: thin;
}

.context-nav-head {
  display: flex;
  min-height: 58px;
  padding: 2px 8px 14px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-bottom: 1px solid var(--workspace-line);
}

.context-nav-eyebrow {
  color: #7a867f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

#context-nav-title {
  color: var(--workspace-text);
  font-size: 17px;
  line-height: 1.2;
}

.module-group {
  display: flex;
  width: 100%;
  padding: 14px 0 0;
  flex-direction: column;
  gap: 3px;
  border: 0;
  background: transparent;
}

.module-group-label {
  margin: 0 8px 6px;
  color: #7a867f;
  font-size: 10px;
  letter-spacing: .06em;
}

.module-tab {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 9px;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #435048;
  font-size: 12px;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
}

.module-tab svg,
.module-tab > i {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke-width: 1.8;
}

.module-tab > span {
  width: auto;
  min-width: 0;
  font-size: inherit;
  line-height: inherit;
  text-align: left;
}

.module-tab:not(.active):hover {
  border-color: transparent;
  background: #edf1ee;
  color: var(--workspace-green);
}

.module-tab.active {
  border-color: #b8d8c3;
  background: var(--workspace-green-soft);
  color: var(--workspace-green);
  box-shadow: inset 3px 0 0 var(--workspace-green);
}

.module-tab-secondary {
  padding-left: 35px !important;
  color: #5e6a63 !important;
  font-size: 11px !important;
}

/* Page header and global search */
.main {
  width: auto;
  max-width: none;
  margin: 0 0 0 calc(var(--workspace-rail) + var(--workspace-context));
  padding: 0 24px 40px;
}

.workspace-page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  min-height: var(--workspace-header);
  margin: 0 -24px 14px;
  padding: 13px 24px 12px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: center;
  gap: 24px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--workspace-line);
  backdrop-filter: blur(10px);
}

.workspace-page-copy {
  min-width: 0;
}

.workspace-breadcrumb {
  display: flex;
  min-width: 0;
  margin-bottom: 3px;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  color: var(--workspace-muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace-breadcrumb svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.workspace-page-header h1 {
  margin: 0;
  color: var(--workspace-text);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.workspace-page-header p {
  max-width: 74ch;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--workspace-muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-search {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
}

.workspace-search > svg {
  position: absolute;
  left: 11px;
  z-index: 1;
  width: 17px;
  height: 17px;
  color: #68756d;
  pointer-events: none;
}

#admin-global-search {
  width: 100%;
  height: 40px;
  min-height: 40px !important;
  padding: 8px 38px 8px 36px;
  border: 1px solid var(--workspace-line-strong) !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: var(--workspace-text) !important;
  font-size: 12px;
}

#admin-global-search:focus {
  border-color: var(--workspace-green) !important;
  box-shadow: 0 0 0 3px rgba(13, 77, 43, .14) !important;
}

.workspace-search-clear {
  position: absolute;
  right: 6px;
  display: grid;
  width: 29px;
  height: 29px;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #5d6a62;
  cursor: pointer;
}

.workspace-search-clear:hover {
  background: #edf1ee;
}

.workspace-search-clear svg {
  width: 15px;
  height: 15px;
}

.workspace-search-results {
  position: absolute;
  inset: calc(100% + 6px) 0 auto;
  z-index: 300;
  max-height: min(430px, calc(100dvh - 110px));
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--workspace-line-strong);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--workspace-shadow);
}

.workspace-search-result {
  display: grid;
  width: 100%;
  min-height: 48px;
  padding: 7px 8px;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--workspace-text);
  text-align: left;
  cursor: pointer;
}

.workspace-search-result:hover,
.workspace-search-result[aria-selected="true"] {
  background: #edf4ef;
}

.workspace-search-result-type {
  color: #8b4a35;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.workspace-search-result-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.workspace-search-result-copy strong,
.workspace-search-result-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-search-result-copy strong {
  font-size: 12px;
}

.workspace-search-result-copy small {
  color: var(--workspace-muted);
  font-size: 10px;
}

.workspace-search-empty {
  margin: 0;
  padding: 14px 10px;
  color: var(--workspace-muted);
  font-size: 11px;
  line-height: 1.4;
}

.admin-compact-bar {
  margin-top: 0;
}

.mobile-area-nav,
.mobile-more-menu,
.mobile-more-backdrop {
  display: none;
}

@media (max-width: 1180px) and (min-width: 801px) {
  :root {
    --workspace-rail: 78px;
    --workspace-context: 202px;
  }

  .workspace-area-link {
    min-height: 51px;
    font-size: 9px;
  }

  .module-nav {
    padding-inline: 9px;
  }

  .workspace-page-header {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 310px);
    gap: 14px;
  }
}

/* Tablet and mobile: top brand, contextual scroller, five bottom destinations. */
@media (max-width: 800px) {
  :root {
    --mobile-top: 56px;
    --mobile-bottom: calc(62px + env(safe-area-inset-bottom));
  }

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

  .top-bar {
    position: sticky;
    inset: 0;
    z-index: 160;
    display: flex;
    width: 100%;
    height: var(--mobile-top);
    min-height: var(--mobile-top);
    padding: 7px 12px;
    flex-direction: row;
    align-items: center;
    gap: 9px;
    background: #fff;
    border-right: 0;
    border-bottom: 1px solid var(--workspace-line);
    box-shadow: 0 2px 9px rgba(22, 34, 27, .07);
  }

  .top-logo {
    display: flex;
    width: auto;
    flex: 0 1 auto;
    grid-template-columns: none;
    flex-direction: row;
    align-items: center;
    justify-items: initial;
    gap: 7px;
  }

  .workspace-brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    font-size: 18px;
  }

  .workspace-brand-name {
    font-size: 14px;
  }

  .workspace-brand-role {
    padding-left: 7px;
    border-left: 1px solid var(--workspace-line);
    font-size: 9px !important;
  }

  .workspace-area-nav,
  .top-right {
    display: none;
  }

  .main {
    width: 100%;
    margin: 0;
    padding: 0 12px calc(var(--mobile-bottom) + 14px);
  }

  .module-nav {
    position: sticky;
    inset: var(--mobile-top) auto auto;
    z-index: 140;
    display: flex;
    width: auto;
    height: 51px;
    max-height: 51px;
    margin: 0 -12px;
    padding: 7px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(251, 252, 251, .98);
    border-right: 0;
    border-bottom: 1px solid var(--workspace-line);
    box-shadow: 0 2px 7px rgba(22, 34, 27, .045);
    scrollbar-width: none;
  }

  .module-nav::-webkit-scrollbar {
    display: none;
  }

  .context-nav-head,
  .module-group-label {
    display: none;
  }

  .module-group {
    display: flex;
    width: max-content;
    padding: 0;
    flex-direction: row;
    gap: 4px;
  }

  .module-tab {
    width: auto;
    min-width: max-content;
    min-height: 36px;
    padding: 7px 10px;
    gap: 6px;
    border-color: #d7dfda;
    background: #fff;
    font-size: 11px;
    white-space: nowrap;
  }

  .module-tab.active {
    border-color: #95c2a5;
    background: var(--workspace-green-soft);
    box-shadow: none;
  }

  .module-tab-secondary {
    padding-left: 10px !important;
    font-size: 11px !important;
  }

  .workspace-page-header {
    position: relative;
    top: auto;
    z-index: 90;
    min-height: 0;
    margin: 0;
    padding: 13px 0 12px;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    background: transparent;
    border-bottom: 0;
    backdrop-filter: none;
  }

  .workspace-page-header h1 {
    font-size: 20px;
  }

  .workspace-page-header p {
    font-size: 11px;
    white-space: normal;
  }

  .workspace-search-results {
    max-height: min(390px, calc(100dvh - 210px));
  }

  .mobile-area-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 210;
    display: grid;
    height: var(--mobile-bottom);
    padding: 5px 5px max(5px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    background: rgba(255, 255, 255, .98);
    border-top: 1px solid var(--workspace-line-strong);
    box-shadow: 0 -5px 18px rgba(22, 34, 27, .09);
  }

  .mobile-area-link {
    display: flex;
    min-width: 0;
    min-height: 50px;
    padding: 4px 2px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 4px;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.1;
  }

  .mobile-area-link svg {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    stroke-width: 1.8;
  }

  .mobile-area-link span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-area-link.active {
    background: var(--workspace-accent-soft);
    color: #9f3c1d;
  }

  .mobile-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 220;
    display: block;
    background: rgba(18, 27, 22, .38);
  }

  .mobile-more-menu {
    position: fixed;
    inset: auto 0 0;
    z-index: 230;
    display: flex;
    width: 100%;
    max-height: min(70dvh, 420px);
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom));
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    border-radius: 10px 10px 0 0;
    background: #fff;
    box-shadow: 0 -12px 30px rgba(22, 34, 27, .16);
  }

  .mobile-more-head {
    display: flex;
    min-height: 42px;
    padding: 0 4px 8px 8px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--workspace-line);
  }

  .mobile-more-head strong {
    font-size: 15px;
  }

  .mobile-more-head button {
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--workspace-text);
  }

  .mobile-more-head svg {
    width: 19px;
    height: 19px;
  }

  .mobile-more-link {
    display: grid;
    width: 100%;
    min-height: 56px;
    padding: 8px 9px;
    grid-template-columns: 24px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--workspace-text);
    text-align: left;
  }

  .mobile-more-link:hover,
  .mobile-more-link.active {
    background: var(--workspace-green-soft);
  }

  .mobile-more-link > svg {
    width: 19px;
    height: 19px;
    color: var(--workspace-green);
  }

  .mobile-more-link > span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-more-link strong {
    font-size: 12px;
  }

  .mobile-more-link small {
    color: var(--workspace-muted);
    font-size: 10px;
  }

  .mobile-more-logout {
    margin-top: 4px;
    border-top: 1px solid var(--workspace-line);
    border-radius: 0;
    color: #8b3528;
  }

  .mobile-more-logout > svg {
    color: #a83e2e;
  }
}

@media (max-width: 390px) {
  .main {
    padding-inline: 9px;
  }

  .module-nav {
    margin-inline: -9px;
    padding-inline: 9px;
  }

  .workspace-brand-role {
    display: none !important;
  }

  .workspace-page-header h1 {
    font-size: 19px;
  }

  .mobile-area-link {
    font-size: 8.5px;
  }

  .module-tab {
    padding-inline: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workspace-search-results,
  .mobile-more-menu,
  .mobile-more-backdrop {
    scroll-behavior: auto;
  }
}
