/* ══ APP SHELL ══ */
.app { display: flex; min-height: 100vh; }

/* ══ SIDEBAR ══ */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: visible;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sb-logo { padding: 22px 18px 18px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sb-logo-wrap { display: flex; align-items: center; gap: 12px; }
.sb-logo-img {
  height: 38px; width: auto; object-fit: contain; flex-shrink: 0;
  filter: brightness(0) invert(1);
}
.sb-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  border-radius: 12px; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 20px; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(13,37,85,0.4);
}
.sb-logo-name { color: #fff; font-size: 16px; font-weight: 800; line-height: 1.2; }
.sb-logo-sub  { color: rgba(255,255,255,0.35); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }

.sb-user {
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  transition: background .15s;
}
.sb-user:hover { background: rgba(255,255,255,0.04); }
.sb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(13,37,85,0.3);
}
.sb-user-name { color: #fff; font-size: 13px; font-weight: 600; }
.sb-user-role { color: rgba(255,255,255,0.4); font-size: 11px; font-weight: 500; }

.sb-nav { flex: 1; padding: 10px 10px; }
.sb-section {
  color: rgba(255,255,255,0.25); font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; padding: 14px 10px 5px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  color: rgba(255,255,255,0.55); font-size: 13px; font-weight: 600;
  transition: var(--transition); user-select: none; margin-bottom: 2px;
  position: relative;
}
.sb-item i { font-size: 18px; flex-shrink: 0; transition: transform .2s; }
.sb-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.sb-item:hover i { transform: translateX(2px); }
.sb-item.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  color: #fff; box-shadow: 0 4px 14px rgba(13,37,85,0.4);
}
.sb-item.active i { transform: none; }
.sb-item .sb-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; min-width: 18px; text-align: center; }

.sb-footer { padding: 10px 10px 20px; border-top: 1px solid rgba(255,255,255,0.06); }

/* ══ MAIN ══ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: rgba(255,255,255,0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 17px; font-weight: 800; color: var(--text); }
.topbar-right { display: flex; gap: 8px; align-items: center; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-100); border-radius: var(--radius-sm);
  padding: 8px 14px; border: 1.5px solid transparent; transition: var(--transition);
}
.topbar-search:focus-within { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px rgba(13,37,85,0.1); }
.topbar-search i { color: var(--gray-400); font-size: 16px; }
.topbar-search input { border: none; background: transparent; outline: none; font-size: 13px; font-family: inherit; color: var(--text); width: 160px; }

.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; color: var(--gray-600); transition: var(--transition);
  position: relative;
}
.topbar-icon-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.topbar-notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--surface); }

.content { flex: 1; padding: 22px 24px; }

/* ══ SECTIONS ══ */
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }

/* ═════════════════════════════════════
   LOGIN PAGE — Rediseño Community Go
   ═════════════════════════════════════ */

/* bg-login.png cubre TODA la pantalla */
#login-page {
  display: flex;
  min-height: 100vh;
  background-color: #0B2559;
  background-image: url('../assets/bg-login.png');
  background-size: cover;
  background-position: center;
}

/* ── Panel izquierdo ── */
.login-left {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px 56px;
  background: transparent;
}

.login-left > * { position: relative; z-index: 1; }

/* ── Fila superior: logo (izq) + headline/desc (der) ── */
.ll-top-row {
  display: flex;
  align-items: center;
  gap: 36px;
  margin-bottom: 36px;
}

.ll-logo { flex-shrink: 0; }
.ll-logo-img {
  height: 150px;
  width: auto;
  object-fit: contain;
  display: block;
}

.ll-top-text { flex: 1; }

/* Headline */
.ll-headline {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  line-height: 1.18;
  margin-bottom: 12px;
}
.ll-headline-accent { color: #00BBD4; }

/* Descripción */
.ll-desc {
  color: rgba(255,255,255,0.65);
  font-size: 14px;
  line-height: 1.65;
  margin: 0;
  max-width: 340px;
}

/* ── Stats bar — más alta, números más grandes ── */
.ll-stats {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 28px 32px;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 28px;
}

.ll-stat {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
}
.ll-stat i {
  font-size: 28px;
  color: #00BBD4;
}
.ll-stat-val {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}
.ll-stat-label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
  margin-top: 2px;
}
.ll-stat-sep {
  width: 1px;
  height: 44px;
  background: rgba(255,255,255,0.15);
  margin: 0 8px;
  flex-shrink: 0;
}

/* ── Features — horizontal ── */
.ll-features {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 16px;
}

.ll-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  gap: 12px;
}

/* Cuadrado redondeado — logo completo sin recorte */
.ll-feature-icon {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
}

.ll-feature-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  transform: translateZ(0);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: smooth;
  filter: blur(0.4px) contrast(1.05);
}

.ll-feature-icon-fallback {
  display: none;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(0,187,212,0.4);
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #00BBD4;
}

.ll-feature-text { width: 100%; }

.ll-feature-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.ll-feature-title.cyan-dark { color: #0096AA; }
.ll-feature-title.cyan      { color: #00BBD4; }
.ll-feature-title.green     { color: #4CCB2A; }

.ll-feature-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
  line-height: 1.4;
}

/* ── Área derecha: transparente, centra la tarjeta ── */
.login-right {
  width: 560px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 44px;
  background: transparent;
}

/* ── Tarjeta flotante blanca ── */
.login-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.15);
  padding: 48px 44px;
}

.login-title { font-size: 28px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.login-sub   { font-size: 14px; color: var(--text2); margin-bottom: 28px; }

/* Campos */
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--gray-600); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .07em;
}
.form-field .input-wrap { position: relative; }
.form-field .input-wrap i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 16px; color: var(--gray-400); }
.form-field input {
  width: 100%; padding: 12px 12px 12px 40px;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); outline: none;
  transition: var(--transition); font-size: 14px; font-family: inherit; font-weight: 500;
}
.form-field input:focus { border-color: #1E5BFA; box-shadow: 0 0 0 3px rgba(30,91,250,0.1); }

/* ¿Olvidaste? */
.login-forgot-row { display: flex; justify-content: flex-end; margin-top: -6px; margin-bottom: 20px; }
.login-forgot { font-size: 13px; color: #1E5BFA; cursor: pointer; font-weight: 600; }
.login-forgot:hover { text-decoration: underline; }

/* Roles */
.role-label { font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 10px; }
.login-roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.role-btn {
  border: 2px solid var(--border); border-radius: 12px;
  padding: 14px 6px; cursor: pointer; text-align: center;
  transition: var(--transition); background: #fff;
}
.role-btn:hover   { border-color: #1E5BFA; background: #EEF3FF; transform: translateY(-1px); }
.role-btn.selected { border-color: #1E5BFA; background: #EEF3FF; box-shadow: 0 0 0 3px rgba(30,91,250,0.1); }
.role-btn i   { font-size: 23px; color: #1E5BFA; display: block; margin-bottom: 5px; }
.role-btn span { font-size: 12px; font-weight: 700; color: var(--text); }

/* Botón ingresar */
.btn-login {
  width: 100%; padding: 15px;
  background: #0B2559;
  color: #fff; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 8px; transition: background 0.18s, transform 0.15s;
  margin-bottom: 22px;
}
.btn-login:hover { background: #0d2e6e; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login i { font-size: 18px; }

/* Error */
.login-error {
  background: var(--red-bg); color: var(--red-text);
  border: 1px solid #FECACA; border-radius: 10px;
  padding: 11px 14px; font-size: 13px;
  margin-bottom: 14px; display: none; font-weight: 500;
}
.login-error.show { display: flex; align-items: center; gap: 8px; animation: fadeIn 0.2s ease; }

/* Cuentas demo */
.demo-section { margin-bottom: 20px; }
.demo-label {
  font-size: 11px; font-weight: 700; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px;
}
.demo-select-wrap {
  position: relative;
  display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: #fff; padding: 0 12px;
  transition: var(--transition);
}
.demo-select-wrap:focus-within { border-color: #1E5BFA; box-shadow: 0 0 0 3px rgba(30,91,250,0.08); }
.demo-select-wrap > i:first-child { font-size: 16px; color: var(--gray-400); margin-right: 8px; flex-shrink: 0; }
.demo-select-wrap select {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--text);
  padding: 11px 0; cursor: pointer; appearance: none;
}
.demo-chevron { font-size: 14px; color: var(--gray-400); flex-shrink: 0; pointer-events: none; }

/* Badge seguridad */
.security-badge {
  display: flex; align-items: flex-start; gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.security-badge > i { font-size: 18px; color: var(--gray-400); margin-top: 1px; flex-shrink: 0; }
.security-badge-title { font-size: 12px; font-weight: 700; color: var(--text); }
.security-badge-sub   { font-size: 11px; color: var(--text2); margin-top: 1px; }

/* CTA de contratación (alta de comunidad nueva) */
.login-register-cta {
  text-align: center; font-size: 13px; color: var(--text2);
  margin-bottom: 20px; padding: 13px 14px;
  background: var(--brand-light); border-radius: 10px;
}
.login-register-cta a { color: #1E5BFA; font-weight: 700; text-decoration: none; }
.login-register-cta a:hover { text-decoration: underline; }


/* ══ SELECTOR DE COMUNIDAD ══ */
.com-switch { position: relative; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.com-switch-btn {
  width: 100%; display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 9px 11px; cursor: pointer;
  color: #fff; font-family: inherit; transition: background .15s;
}
.com-switch-btn:hover { background: rgba(255,255,255,0.1); }
.com-switch-btn > i:first-child { font-size: 18px; color: var(--accent); flex-shrink: 0; }
.com-switch-name { flex: 1; text-align: left; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.com-switch-chev { font-size: 15px; color: rgba(255,255,255,0.5); transition: transform .2s; flex-shrink: 0; }
.com-switch.open .com-switch-chev { transform: rotate(180deg); }

.com-switch-menu {
  display: none; position: absolute; left: 12px; right: 12px; top: calc(100% - 2px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden;
  animation: scaleIn .16s ease; transform-origin: top center;
}
.com-switch.open .com-switch-menu { display: block; }
.com-switch-head { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); padding: 11px 14px 7px; }
.com-switch-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: transparent; border: none; cursor: pointer;
  font-family: inherit; text-align: left; transition: background .12s; color: var(--text);
}
.com-switch-item:hover { background: var(--gray-100); }
.com-switch-item.active { background: var(--brand-light); }
.com-switch-item > i:first-child { font-size: 18px; color: var(--brand); flex-shrink: 0; }
.com-switch-item > span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.com-switch-item-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.com-switch-item-rol  { font-size: 11px; color: var(--text2); font-weight: 500; }
.com-switch-item-check { font-size: 16px; color: var(--brand); flex-shrink: 0; }

/* Colapsada: ocultar texto, dejar solo el ícono */
.sidebar.collapsed ~ * .com-switch,
.sidebar.collapsed .com-switch { padding: 10px 8px; }
.sidebar.collapsed .com-switch-name,
.sidebar.collapsed .com-switch-chev { display: none; }
.sidebar.collapsed .com-switch-btn { justify-content: center; padding: 9px 0; }

/* ══ SIDEBAR SCROLL + TOGGLE ══ */
.sidebar {
  transition: width 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto; overflow-x: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.35); }

.sidebar.collapsed { width: 68px; }
.sidebar.collapsed span:not(.sb-badge),
.sidebar.collapsed .sb-logo-name,
.sidebar.collapsed .sb-logo-sub,
.sidebar.collapsed .sb-user-name,
.sidebar.collapsed .sb-user-role,
.sidebar.collapsed .sb-section { display: none; }

.sidebar.collapsed .sb-logo      { padding: 16px 10px; }
.sidebar.collapsed .sb-logo-wrap { justify-content: center; }
.sidebar.collapsed .sb-logo-icon { margin: 0; }
.sidebar.collapsed .sb-logo-img  { height: 28px; }
.sidebar.collapsed .sb-user      { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sb-avatar    { margin: 0; }
.sidebar.collapsed .sb-nav       { padding: 10px 6px; }
.sidebar.collapsed .sb-footer    { padding: 8px 6px 16px; }
.sidebar.collapsed .sb-item      { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sb-item i    { margin: 0; font-size: 20px; transform: none !important; }

.sidebar.collapsed .sb-item[data-label]:hover::after {
  content: attr(data-label);
  position: fixed; left: 78px;
  background: #1F2937; color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 7px;
  white-space: nowrap; pointer-events: none;
  z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  animation: fadeIn 0.12s ease;
}

.sidebar-wrap { position: relative; flex-shrink: 0; display: flex; }

.sb-toggle {
  position: absolute; top: 24px; right: -13px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff;
  border: 2.5px solid #eef2f7;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; z-index: 50;
  box-shadow: 0 2px 10px rgba(13,37,85,0.45);
  transition: background 0.15s, box-shadow 0.15s; outline: none;
}
.sb-toggle:hover { background: var(--brand-dark); box-shadow: 0 4px 14px rgba(13,37,85,0.55); }
.sb-toggle i { transition: transform 0.25s ease; display: flex; align-items: center; justify-content: center; }
.sidebar.collapsed ~ .sb-toggle i { transform: rotate(180deg); }

/* ══ USER MENU ══ */
.user-menu-overlay { display: none; position: fixed; inset: 0; z-index: 150; }
.user-menu-overlay.open { display: block; }

.user-menu {
  position: fixed; left: 14px; bottom: 72px;
  width: 272px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 160; display: none;
  animation: scaleIn 0.2s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom left;
}
.user-menu.open { display: block; }

.user-menu-header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.user-menu-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.user-menu-name  { font-size: 14px; font-weight: 700; color: var(--text); }
.user-menu-email { font-size: 12px; color: var(--text2); margin-top: 1px; }
.user-menu-role  { font-size: 11px; font-weight: 600; margin-top: 5px; }

.user-menu-body { padding: 8px 8px; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text);
  transition: background 0.13s; user-select: none;
}
.user-menu-item:hover          { background: var(--gray-100); }
.user-menu-item i              { font-size: 17px; color: var(--text2); }
.user-menu-item.danger         { color: var(--red); }
.user-menu-item.danger i       { color: var(--red); }
.user-menu-item.danger:hover   { background: var(--red-bg); }
.user-menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }

.sb-badge { animation: bounceIn 0.4s cubic-bezier(0.34,1.56,0.64,1); }

.avatar-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.avatar-color  {
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: var(--transition);
}
.avatar-color:hover,
.avatar-color.selected { border-color: var(--gray-800); transform: scale(1.15); }
