/* ----------------------------------------------------------------------------
   ACE NUTRITIONS. — Hoja de Componente 08
   Extraida de `tokens.css` en la Iteracion 07.7 (Regla #011).
   El ORDEN de carga en `app-shell.html` reproduce el del archivo original:
   la cascada CSS depende de el y no debe alterarse.
   -------------------------------------------------------------------------- */
/* ============================================================================
   CREATIZEUS BRAND APP SHELL (SIDEBAR + NAVHEADER + CONTENT + CONTENT HEADER)
   ============================================================================ */
.ace-app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  transition: grid-template-columns 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.ace-app-shell.is-collapsed {
  grid-template-columns: 78px minmax(0, 1fr);
}

.ace-app-sidebar {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-height: calc(100vh - 116px);
  justify-content: space-between;
  transition: padding 0.22s ease;
}

.ace-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.ace-sidebar-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-studio);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ace-sidebar-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ace-sidebar-brand-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ace-sidebar-brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ace-sidebar-collapse-btn {
  padding: 6px 9px;
  font-size: 12px;
  flex-shrink: 0;
}

.ace-sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ace-sidebar-group-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 8px 4px;
}

.ace-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.ace-sidebar-link:hover {
  background: var(--bg-studio);
  color: var(--ink);
  border-color: var(--border-soft);
}

.ace-sidebar-link.is-active {
  background: var(--jade-soft);
  color: var(--ink);
  border-color: var(--jade);
  font-weight: 600;
}

.ace-sidebar-icon {
  font-size: 13px;
  color: var(--jade);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.ace-sidebar-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ace-sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ace-sidebar-session-card {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ace-sidebar-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ace-app-shell.is-collapsed .ace-sidebar-brand-copy,
.ace-app-shell.is-collapsed .ace-sidebar-group-title,
.ace-app-shell.is-collapsed .ace-sidebar-label,
.ace-app-shell.is-collapsed .ace-sidebar-link .ace-badge,
.ace-app-shell.is-collapsed .ace-sidebar-session-card {
  display: none;
}

.ace-app-shell.is-collapsed .ace-sidebar-link {
  justify-content: center;
  padding: 10px 6px;
}

.ace-app-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* WORKSPACE NAVHEADER (`data-cz-navheader="true"`) */
.ace-workspace-navheader {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.ace-navheader-left,
.ace-navheader-center,
.ace-navheader-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ace-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.ace-breadcrumb-root {
  color: var(--ink-muted);
  font-weight: 600;
}

.ace-breadcrumb-sep {
  color: var(--border-med);
}

.ace-breadcrumb-current {
  color: var(--ink);
  font-weight: 700;
}

.ace-command-search-wrap,
.ace-patient-switcher-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ace-command-search-input {
  min-width: 240px;
  padding: 7px 12px;
  font-size: 12.5px;
}

/* CONTENT & CONTENT HEADER (`data-cz-content="true"`, `data-cz-content-header="true"`) */
.ace-workspace-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.ace-content-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ace-content-header-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 760px;
}

.ace-content-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ace-content-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* STANDARDIZED CONTROLS & BUTTON VARIANTS (`data-cz-ui-controls="true"`) */
.ace-btn-secondary {
  background: var(--bg-studio);
  color: var(--ink);
  border: 1px solid var(--border-med);
}

.ace-btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--jade);
}

.ace-btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid transparent;
}

.ace-btn-ghost:hover {
  background: var(--bg-studio);
  color: var(--ink);
  border-color: var(--border-soft);
}

.ace-btn-danger {
  background: var(--danger-soft, rgba(220, 38, 38, 0.1));
  color: var(--danger);
  border: 1px solid var(--danger);
}

.ace-btn-danger:hover {
  background: var(--danger);
  color: var(--bg-surface);
}

.ace-badge-warn {
  background: rgba(217, 119, 6, 0.12);
  color: var(--warn);
  border-color: rgba(217, 119, 6, 0.28);
}

.ace-badge-danger {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.28);
}

.cz-segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-studio);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-pill);
}

.cz-segment-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.cz-segment-btn.is-active {
  background: var(--ink);
  color: var(--bg-surface);
}

.cz-switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cz-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-med);
  background: var(--bg-studio);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.cz-switch-track {
  width: 34px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: var(--border-med);
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background 0.18s ease;
}

.cz-switch-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  transition: transform 0.18s ease;
}

.cz-switch-btn.is-on {
  border-color: var(--jade);
  background: var(--jade-soft);
}

.cz-switch-btn.is-on .cz-switch-track {
  background: var(--jade);
}

.cz-switch-btn.is-on .cz-switch-thumb {
  transform: translateX(16px);
}

.cz-input-unit-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-studio);
}

.cz-input-unit-wrap .ace-input {
  border: none;
  flex: 1;
}

.cz-input-unit-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

/* DESIGN SYSTEM SHOWCASE (`data-cz-design-system="true"`) */
.cz-ds-root {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cz-ds-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.cz-ds-swatch-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-studio);
}

.cz-ds-swatch-preview {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-med);
  flex-shrink: 0;
}

.cz-swatch-brand { background: var(--brand); }
.cz-swatch-accent { background: var(--accent); }
.cz-swatch-jade { background: var(--jade); }
.cz-swatch-surface { background: var(--bg-surface); }
.cz-swatch-studio { background: var(--bg-studio); }
.cz-swatch-ink { background: var(--ink); }

.cz-ds-swatch-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cz-ds-token-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.cz-ds-token-label,
.cz-ds-token-desc {
  font-size: 11px;
  color: var(--ink-secondary);
}

.cz-ds-type-stack,
.cz-ds-controls-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.cz-ds-type-row {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-studio);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cz-ds-type-sample-display {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.cz-ds-type-sample-sans {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
}

.cz-ds-type-sample-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--jade);
}

.cz-ds-anatomy-diagram {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-med);
  background: var(--bg-studio);
}

.cz-ds-anatomy-sidebar,
.cz-ds-anatomy-navheader,
.cz-ds-anatomy-contentheader,
.cz-ds-anatomy-contentbody {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.cz-ds-anatomy-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
