/* Admin Layout — theme variables are in skin.css */

/* Pre-login shell gate.
   The framework renders the full admin shell (fixed sidebar, breadcrumbs, content,
   footer) and merely *dims* it behind the login dialog — so the conservative menu
   icons peek through the backdrop before login, reading as half-loaded. We hide the
   whole shell until authenticated so the login dialog sits on a clean background
   (all-or-nothing). `cg-app-authed` is toggled on <body> by Main.updateMenuWithUserProfile.
   Body starts without the class, so the shell is hidden from first paint (no flash). */
body:not(.cg-app-authed) #navbar,
body:not(.cg-app-authed) #app-breadcrumbs,
body:not(.cg-app-authed) #content-wrapper,
body:not(.cg-app-authed) #footer,
body:not(.cg-app-authed) #cg-setup-shortcut,
body:not(.cg-app-authed) #cg-store-badge,
body:not(.cg-app-authed) #cg-emulator-dock-launch,
body:not(.cg-app-authed) #cg-page-screenshot-launch {
  display: none !important;
}

/* Admin container */
.ntelioApp {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--page-background);
}

.toast-container {
  z-index: 2000;
}

.ntelioApp footer {
  height: 0.7em;
  font-size: 0.7em;
  color: var(--color1);
  background-color: transparent;
}
.ntelioApp footer p {
  position: relative;
  top: 50%;
}
.ntelioApp #main {
  height: 100%;
}
.ntelioApp .content {
  flex: 1;
  overflow: hidden;
}
.ntelioApp .menu-column {
  width: 200px;
  overflow-y: auto;
}
.ntelioApp .main-column {
  flex: 1;
  overflow-y: auto;
}

/* Cards */
.ntelioApp .card {
  border-radius: var(--application-border-radius);
  border: 0px solid white;
  height: 100%;
}
.ntelioApp .card-footer {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: var(--card-footer-border-radius);
  border-bottom-right-radius: var(--card-footer-border-radius);
  background-color: #cfcbc1;
  color: var(--cartaja-text-primary);
  border-top-color: #b8b3a8;
}
.ntelioApp .card-header {
  border-top-left-radius: var(--application-border-radius);
  border-top-right-radius: var(--application-border-radius);
  background-color: var(--color1);
  color: white;
}
.ntelioApp .card-body {
  padding: 8px;
}

/* Buttons */
.ntelioApp .btn-primary {
  background-color: var(--color1);
  color: var(--color0);
}
.ntelioApp .btn-primary:hover {
  background-color: var(--color2);
}
.ntelioApp .btn-primary:active {
  background-color: var(--color3);
}

/* Navbar */
.ntelioApp .vertical-navbar {
  width: 220px;
  height: calc(100vh - 50px);
  /* Above .widget-loading-overlay (z-index: 1000) — both ntelioUI2's
     per-widget loading overlay and the navbar default to 1000, and the
     overlay wins on DOM order, partially covering the expanded menu. */
  z-index: 1050;
}
.ntelioApp .vertical-navbar .logo {
  background-image: url("../../static/images/cartaja-logo.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  height: 60px;
}
.ntelioApp .vertical-navbar.expanded .logo,
.ntelioApp .vertical-navbar:hover .logo {
  height: 60px;
  width: 130px;
  background-image: url("../../static/images/cartaja-logo-wide.svg");
}
.ntelioApp .vertical-navbar .menu-label,
.ntelioApp .vertical-navbar-bottom .menu-label {
  font-family: var(--bs-body-font-family);
  color: var(--cartaja-text-primary);
}
.ntelioApp .vertical-navbar .menu-icon,
.ntelioApp .vertical-navbar-bottom .menu-icon {
  color: var(--cartaja-bg-deep);
}
.ntelioApp .vertical-navbar .menu-item:hover .menu-icon,
.ntelioApp .vertical-navbar-bottom .menu-item:hover .menu-icon,
.ntelioApp .vertical-navbar .menu-item:hover .menu-label,
.ntelioApp .vertical-navbar-bottom .menu-item:hover .menu-label {
  color: var(--cartaja-white);
}
.ntelioApp .vertical-navbar .menu-separator {
  border-top-color: var(--cartaja-border-light);
}
.ntelioApp .vertical-navbar.collapsed {
  width: 60px;
  height: calc(100vh - 50px);
}
.ntelioApp .vertical-navbar.expanded,
.ntelioApp .vertical-navbar:hover {
  width: 210px;
}
.ntelioApp .vertical-navbar .menu-item:hover {
  background-color: var(--color1);
}
.ntelioApp .vertical-navbar .menu-item.active {
  background-color: rgba(14, 180, 183, 0.12);
  border-left: 3px solid var(--cartaja-crimson);
  color: var(--cartaja-crimson);
}
.ntelioApp .vertical-navbar .menu-item.active .menu-label {
  color: var(--cartaja-crimson);
}
.ntelioApp .vertical-navbar-bottom .menu-item:hover {
  background-color: var(--color1);
}
/* Distinguish the sticky bottom section (settings/profile/logout) from the
   scrollable upper menu so it doesn't read as part of the same scroll area.
   Negative margin cancels the navbar's 5px horizontal padding so the grey
   fill reaches edge-to-edge; matching radius follows the navbar's right
   rounded corner. */
.ntelioApp .vertical-navbar-bottom {
  background-color: #d4d7db;
  border-top: 1px solid var(--cartaja-border-light, #e0d9d2);
  margin-left: -5px;
  margin-right: -5px;
  width: calc(100% + 10px);
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-right-radius: 20px;
}

/* Toast */
.ntelioApp .toast {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
}

/* Files */
.files .trashcan {
  margin-right: 0.5em;
}
.files {
  margin-top: 0em;
}

/* Sign-in form */
.form-signin {
  max-width: 330px;
  padding: 1rem;
}
.form-signin .form-floating:focus-within {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.form-signin #errorMessage {
  color: red;
  font-size: 0.8em;
  padding: 0.8em;
}

/* Page Layout */
.ntelioApp #content-wrapper {
  display: block;
  overflow: hidden;
  padding: 0;
  margin: 0;
  margin-left: calc(60px + 5px);
  margin-top: 10px;
  /* Bottom-align #content-wrapper with the navbar. Navbar sets
     `height: calc(100vh - 50px); margin-top: 10px` (above), leaving a 40px
     gap below the navbar. The footer occupies the bottom 1.2em (~19px) of
     that gap, so we need the remaining ~21px as margin-bottom on cw so its
     bottom edge lands on the same y-line as the navbar's bottom edge. */
  margin-bottom: calc(18px - 1.2em);
}
.ntelioApp #content-wrapper > [widgetid] {
  height: calc(100% - 1.5em);
}

/* Grid-in-panel pages (Orders, Chatlogs, MobileChatlogs — anything that uses
   the `.card.chatlogs` wrapper around a DataControl / MasterDetailDataControl).
   The panel card already provides the frame: header bar, rounded corners,
   background. The inner DataControl template (`.card.grid`) was double-framing
   the grid with its own padding (2px), border-radius (10px) and aliceblue
   background, while the parent `.card-body`'s 8px padding boxed the whole
   thing further. The result was the grid sitting in a tiny rectangle inside
   the panel with awkward gutters and scrollbars. Let the grid fill the panel
   edge-to-edge so scrolling lines up with the panel frame. */
.ntelioApp .card.chatlogs > .card-body {
  padding: 0;
}
.ntelioApp .card.chatlogs .card.grid {
  padding: 0;
  border-radius: 0;
  background-color: transparent;
  max-height: none;
}
.ntelioApp .card.chatlogs .masterDetail .master {
  margin-bottom: 0;
}

/* Grid-in-panel sizing chain — collapse nested scrollbars on any page using
   the `.card.chatlogs` pattern (Orders, Chatlogs, MobileChatlogs). Default
   MasterDetailDataControl gives each inner `.card.grid` max-height: 90vh,
   which overflows `.main-column` and produces a page-level scrollbar in
   addition to the inner `.data-section` scroll. Lock the chain to the parent
   height so only `.data-section` scrolls. Also scoped to the page wrappers
   (.orders-page / .chatlogs-page) so each fills its column without
   bleeding past it. */
.ntelioApp .orders-page,
.ntelioApp .chatlogs-page,
.ntelioApp .products-page {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
}
.ntelioApp .card.chatlogs,
.ntelioApp .card.products {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ntelioApp .card.chatlogs > .card-header,
.ntelioApp .card.products > .card-header {
  flex: 0 0 auto;
}
.ntelioApp .card.chatlogs > .card-body,
.ntelioApp .card.products > .card-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
}
.ntelioApp .card.chatlogs .masterDetail {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.ntelioApp .card.chatlogs .masterDetail > .master {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.ntelioApp .card.chatlogs .masterDetail > .detail {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.ntelioApp .card.chatlogs .masterDetail > .master .card.grid {
  flex: 1;
  min-height: 0;
  max-height: none;
  width: 100%;
}
.ntelioApp .card.chatlogs .masterDetail:has(> .detail:not(:empty)) > .master {
  flex: 0 0 auto;
}
.ntelioApp .card.chatlogs .masterDetail:has(> .detail:not(:empty)) > .master .card.grid {
  max-height: 60vh;
}
.ntelioApp .card.chatlogs .masterDetail > .detail .card.grid {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-height: none;
}
.ntelioApp .card.chatlogs .card.grid > #header {
  flex: 0 0 auto;
}

/* Agent Panel */
.ntelioApp .agent {
  height: calc(100% - 1.6em);
  min-height: 0;
  overflow: hidden;
}
.ntelioApp .agent .row {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}
.ntelioApp .agent #content {
  overflow-y: auto;
  height: 100%;
}
.ntelioApp .agent #navigation {
  overflow-y: auto;
}
.ntelioApp .agent #content > * {
  height: 100%;
  min-height: 0;
}

/* Breadcrumbs — Cartaja recolor (ntelioUI breadcrumbs.css uses hardcoded grays).
   Each visible crumb is a stop on a warm-ivory → deep-teal scale so the path
   reads as a progression instead of one continuous pale shape (ivory and
   ivory-warm are only ~3% lightness apart and blended together). */
/* Scale starts at ivory-warm (not ivory) because the page background itself
   is --cartaja-ivory — the first crumb would otherwise disappear into it. */
.arrow-item {
  background-color: var(--cartaja-border-light);
  color: var(--cartaja-text-primary);
}
.arrow-item:first-child {
  background-color: var(--cartaja-ivory-warm);
}
/* First visible arrow-item is :nth-child(2) — base CSS hides :first-child. */
.arrow-item:nth-child(2) {
  background-color: var(--cartaja-border-light);
  color: var(--cartaja-text-primary);
}
.arrow-item:nth-child(3) {
  background-color: #b9ad96;
  color: var(--cartaja-text-primary);
}
.arrow-item:nth-child(4) {
  background-color: #7a8a80;
  color: var(--cartaja-white);
}
.arrow-item:nth-child(5) {
  background-color: #4a7e7e;
  color: var(--cartaja-white);
}
.arrow-item:nth-child(6) {
  background-color: #226163;
  color: var(--cartaja-white);
}
.arrow-item:last-child {
  background-color: var(--cartaja-bg-deep);
  color: var(--cartaja-white);
  border-color: var(--cartaja-bg-main);
}
.arrow-item:hover:not(:last-child) {
  background-color: var(--cartaja-border-light);
  color: var(--cartaja-crimson);
}

/* Sign-in error text */
.form-signin #errorMessage {
  color: var(--cartaja-crimson);
}

/* Footer text */
.ntelioApp footer {
  color: var(--cartaja-text-secondary);
}
.ntelioApp #footer .footer-text a {
  color: var(--cartaja-bg-deep);
}

/* Page-root alignment with the breadcrumb left edge.
   #content-wrapper anchors content at 24px padding-left, and so does
   #app-breadcrumbs — so a page widget mounted directly under #content-wrapper
   already lines up. But pages whose root carries Bootstrap `container` /
   `container-fluid` add another 0.75rem (12px) horizontal padding, which
   shoves the panel inside ~12px past the breadcrumb text and looks misaligned.
   The same goes for any extra max-width that a `.container` would impose.
   Strip both at the page root so panels in SiteEditor, WABA, Prompt, etc.
   align with the breadcrumb without each page needing its own override.
   No padding-top here — the breadcrumb→panel gap is owned by
   #content-wrapper itself so .container, .container-fluid and .card roots
   all share the same top spacing. */
.ntelioApp #content-wrapper > .container,
.ntelioApp #content-wrapper > .container-fluid {
  padding-left: 0;
  padding-right: 0;
  max-width: none;
}

/* Bootstrap's .row has --bs-gutter-x: 1.5rem by default, which becomes a
   -12px margin on each side of the row plus 12px padding on each col. When the
   row is the layout root of a left-pane/right-pane page (Campaign, AddressBook,
   DataBundle, Agent, Pipeline, FormDefinition, UsersManagement, SiteEditor,
   WABA…) and we've zeroed the container's horizontal padding above, that -12px
   pushes the row 12px past each edge of #content-wrapper, which then crops it
   via overflow:hidden — visible as the left-pane / right-pane card being cut
   off on both ends. Cancel the gutter on the root row so its width matches the
   container's content box. (Cols already use .p-0 in every case, so removing
   the gutter padding has no effect on column layout.) */
.ntelioApp #content-wrapper > .container > .row,
.ntelioApp #content-wrapper > .container-fluid > .row {
  --bs-gutter-x: 0;
}

/* SiteHtml/SiteCss editor pane — maximize state pins the card to the
   viewport so the user gets the full screen for editing. The pane uses
   h-100 + flex-column in its normal layout so the ace surface tracks the
   right-pane height; .is-maximized just escapes the right-pane. */
.site-code-pane.is-maximized {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  margin: 0;
}

/* The card-header uses --color1 (dark teal) as background — the default
   Bootstrap outline-primary/outline-secondary use dark teal text + border
   which has near-zero contrast against it. Force white outline + white text
   for any buttons living in this header. */
.site-code-pane > .card-header .btn,
.site-code-pane > .card-header .btn:focus {
  color: var(--cartaja-white);
  border-color: var(--cartaja-white);
  background-color: transparent;
}
.site-code-pane > .card-header .btn:hover {
  color: var(--cartaja-bg-deep);
  background-color: var(--cartaja-white);
  border-color: var(--cartaja-white);
}

/* ---------- Floating Settings shortcut (top-right of viewport) ----------
   Mounted to <body> by Main.js so it survives every page change. Opens
   Settings → Cartaja → Business directly. */
#cg-setup-shortcut {
    /* Pinned to the right edge of the breadcrumb row.
       breadcrumb container: padding-top 16px, .arrow-item height 25px →
       visual center at y ≈ 28.5px. The 24px icon centers on that with
       translateY(-50%). Right offset matches the breadcrumb container's
       24px right padding so the icon lines up with the content edge. */
    position: fixed;
    top: 28px;
    right: 24px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cartaja-text-secondary, #5f5249);
    background: transparent;
    text-decoration: none;
    padding: 0;
    transition: color 140ms ease;
    z-index: 1030;
}

#cg-setup-shortcut:hover,
#cg-setup-shortcut:focus {
    color: var(--cartaja-whatsapp, #25d366);
    outline: none;
}

#cg-setup-shortcut svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: block;
}

/* ---------- Current store (top-right of the breadcrumb row) ----------
   Mounted to <body> by Main._renderStoreBadge so it survives every page
   change. Names the store the session is acting on, so a session that has
   landed in a different store is obvious at a glance (issue #139). Sits one
   slot left of the emulator launcher (right: 60px, 33px wide). */
#cg-store-badge {
    position: fixed;
    top: 28px;
    right: 104px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    max-width: min(320px, 40vw);
    padding: 3px 10px;
    border: 1px solid var(--cartaja-border-light);
    border-radius: 999px;
    background: var(--cartaja-white);
    color: var(--cartaja-bg-deep);
    font-size: 0.8125rem;
    line-height: 1.3;
    white-space: nowrap;
    z-index: 1030;
}

/* Several businesses: the badge switches between them (#178). */
#cg-store-badge.is-switchable { cursor: pointer; }
#cg-store-badge.is-switchable:hover { text-decoration: underline; }

#cg-store-badge[hidden] {
    display: none;
}

/* The screenshot launcher (opt-in, ?screenshot=on) takes the slot at 96px. */
body:has(#cg-page-screenshot-launch) #cg-store-badge {
    right: 140px;
}

#cg-store-badge .cg-store-badge__label {
    color: var(--cartaja-text-secondary);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#cg-store-badge .cg-store-badge__name {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

/* Signed in, but no store resolves — every store page will refuse to load. */
#cg-store-badge.is-missing {
    border-color: var(--cartaja-terracotta);
    color: var(--cartaja-terracotta);
}

/* Context on the login dialog when a session ended or a saved one was
   refused (issue #139): why the user is being asked to sign in again. */
#loginFrm .cg-session-notice {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-left: 3px solid var(--cartaja-terracotta);
    background: var(--cartaja-ivory);
    color: var(--cartaja-text-primary);
    font-size: 0.875rem;
    text-align: left;
}

/* A control the member's role does not include (#179) — see Main._gateControls. */
.cj-lacks-permission { display: none !important; }
