/* BRICO MG v1.4.7.3 — UX profesional estable
   Objetivo: ordenar cabecera, navegación, administración y móvil sin ocultar el root principal.
*/

:root {
  --brico-green: #6b9900;
  --brico-green-2: #4f7800;
  --brico-ink: #171b14;
  --brico-muted: #5f685d;
  --brico-line: rgba(92, 121, 48, .18);
  --brico-soft: #f6f9ef;
  --brico-card: #ffffff;
  --brico-shadow: 0 18px 45px rgba(42, 59, 24, .10);
  --brico-radius: 18px;
}

html {
  background: #f6f8f1;
}

body.bricomg-ux-1473 {
  background:
    radial-gradient(circle at top left, rgba(116, 163, 19, .08), transparent 320px),
    linear-gradient(180deg, #fbfcf7 0%, #f5f8ee 100%);
  color: var(--brico-ink);
}

/* Crédito discreto */
#bricomg-footer-credit {
  width: 100%;
  max-width: 1320px;
  margin: 28px auto 18px;
  padding: 12px 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: rgba(62, 76, 50, .42);
  user-select: none;
}

/* Ocultar copias de versión detectadas dentro de cabecera/cards sin tocar la app principal */
.bricomg-hide-version-inline {
  display: none !important;
}

/* Botones etiquetados por JS */
.bricomg-nav-action {
  border-radius: 13px !important;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

.bricomg-nav-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(48, 73, 18, .10);
}

.bricomg-admin-trigger-active {
  background: var(--brico-green) !important;
  color: #fff !important;
  border-color: var(--brico-green) !important;
}

/* Dropdown profesional de administración */
#bricomg-admin-dropdown {
  position: fixed;
  z-index: 99999;
  width: min(360px, calc(100vw - 32px));
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(92, 121, 48, .18);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(34, 49, 17, .22);
  backdrop-filter: blur(14px);
  overflow: hidden;
  display: none;
}

#bricomg-admin-dropdown.is-open {
  display: block;
}

.bricomg-admin-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(92, 121, 48, .12);
  background: linear-gradient(180deg, rgba(244, 249, 235, .95), rgba(255,255,255,.95));
}

.bricomg-admin-title {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 900;
  color: #203010;
  margin: 0 0 4px;
}

.bricomg-admin-subtitle {
  font-size: 12px;
  line-height: 1.35;
  color: var(--brico-muted);
  margin: 0;
}

.bricomg-admin-list {
  padding: 10px;
  display: grid;
  gap: 6px;
}

.bricomg-admin-item {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 12px 12px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  color: var(--brico-ink);
}

.bricomg-admin-item:hover,
.bricomg-admin-item:focus-visible {
  outline: none;
  background: #f2f7e8;
}

.bricomg-admin-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--brico-green-2);
  background: rgba(107,153,0,.10);
  font-size: 16px;
  font-weight: 900;
}

.bricomg-admin-label {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
}

.bricomg-admin-desc {
  font-size: 12px;
  color: var(--brico-muted);
  line-height: 1.25;
  margin-top: 3px;
  font-weight: 600;
}

.bricomg-admin-badge {
  font-size: 11px;
  font-weight: 900;
  color: #5a7c00;
  background: #edf5da;
  border: 1px solid rgba(107,153,0,.18);
  padding: 4px 8px;
  border-radius: 999px;
}

.bricomg-admin-separator {
  height: 1px;
  background: rgba(92, 121, 48, .12);
  margin: 4px 8px;
}

/* Eliminar paneles fantasma generados por parches anteriores */
.bricomg-ghost-admin-panel,
.bricomg-ghost-admin-card {
  display: none !important;
}

/* Tooltips y ayuda contextual */
.bricomg-ux-1473 [role="tooltip"],
.bricomg-ux-1473 .tooltip,
.bricomg-ux-1473 .help-tooltip,
.bricomg-ux-1473 [data-tooltip]::after {
  max-width: min(360px, calc(100vw - 32px)) !important;
  line-height: 1.45 !important;
  letter-spacing: normal !important;
  word-spacing: normal !important;
  padding: 12px 14px !important;
  border-radius: 14px !important;
  box-shadow: 0 18px 45px rgba(0,0,0,.18) !important;
}

/* Ayuda inyectada */
#bricomg-help-panel {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  background: rgba(18, 26, 12, .42);
  backdrop-filter: blur(8px);
  padding: 28px;
}

#bricomg-help-panel.is-open {
  display: grid;
  place-items: center;
}

.bricomg-help-card {
  width: min(820px, calc(100vw - 28px));
  max-height: min(78vh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 24px;
  border: 1px solid rgba(92, 121, 48, .16);
  box-shadow: 0 28px 90px rgba(18, 26, 12, .28);
}

.bricomg-help-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(92, 121, 48, .14);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  background: linear-gradient(180deg, #f7faef, #fff);
}

.bricomg-help-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.bricomg-help-header p {
  margin: 6px 0 0;
  color: var(--brico-muted);
  line-height: 1.45;
}

.bricomg-help-close {
  border: 1px solid rgba(92, 121, 48, .18);
  background: #fff;
  border-radius: 12px;
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 900;
}

.bricomg-help-body {
  padding: 22px 24px 26px;
  display: grid;
  gap: 18px;
}

.bricomg-help-section {
  border: 1px solid rgba(92, 121, 48, .14);
  background: #fbfcf7;
  border-radius: 18px;
  padding: 16px;
}

.bricomg-help-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.bricomg-help-section p,
.bricomg-help-section li {
  color: #495247;
  line-height: 1.55;
  font-size: 14px;
}

/* Móvil: navegación sólida y compacta */
#bricomg-mobile-bar,
#bricomg-mobile-drawer {
  display: none;
}

@media (max-width: 820px) {
  body.bricomg-ux-1473 {
    padding-top: 58px;
    background: #f7f9f1;
  }

  #bricomg-mobile-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    z-index: 99998;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid rgba(92, 121, 48, .14);
    box-shadow: 0 8px 28px rgba(34, 49, 17, .10);
    backdrop-filter: blur(14px);
  }

  .bricomg-mobile-button {
    border: 1px solid rgba(92, 121, 48, .18);
    background: #fff;
    border-radius: 14px;
    min-height: 40px;
    padding: 0 12px;
    font-weight: 900;
    color: #1d2516;
  }

  .bricomg-mobile-brand {
    text-align: center;
    font-weight: 950;
    color: var(--brico-green-2);
    letter-spacing: .03em;
    white-space: nowrap;
  }

  #bricomg-mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 99997;
    background: rgba(17, 24, 10, .40);
    backdrop-filter: blur(7px);
  }

  #bricomg-mobile-drawer.is-open {
    display: block;
  }

  .bricomg-mobile-sheet {
    width: min(360px, calc(100vw - 24px));
    margin: 70px 12px 12px;
    background: #fff;
    border-radius: 22px;
    border: 1px solid rgba(92, 121, 48, .16);
    box-shadow: 0 28px 85px rgba(18, 26, 12, .30);
    overflow: hidden;
  }

  .bricomg-mobile-sheet-head {
    padding: 16px 18px;
    background: linear-gradient(180deg, #f3f8e8, #fff);
    border-bottom: 1px solid rgba(92, 121, 48, .12);
  }

  .bricomg-mobile-sheet-head strong {
    display: block;
    font-size: 16px;
  }

  .bricomg-mobile-sheet-head span {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--brico-muted);
    font-weight: 700;
  }

  .bricomg-mobile-list {
    padding: 10px;
    display: grid;
    gap: 6px;
  }

  .bricomg-mobile-item {
    border: 0;
    background: transparent;
    border-radius: 14px;
    padding: 13px 12px;
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 10px;
    align-items: center;
    text-align: left;
    font-weight: 900;
    color: var(--brico-ink);
  }

  .bricomg-mobile-item:hover,
  .bricomg-mobile-item:active {
    background: #f2f7e8;
  }

  .bricomg-mobile-section-title {
    margin: 8px 12px 2px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #77816d;
    font-weight: 950;
  }

  /* Evitar que el crédito tape contenido en móvil */
  #bricomg-footer-credit {
    margin: 22px auto 82px;
    font-size: 11px;
    opacity: .72;
  }

  /* Compactación de hero sin ocultarlo */
  body.bricomg-ux-1473 h1 {
    font-size: clamp(26px, 8vw, 38px) !important;
    line-height: 1.08 !important;
  }

  body.bricomg-ux-1473 main,
  body.bricomg-ux-1473 #root {
    max-width: 100vw;
    overflow-x: hidden;
  }
}