/* ========================================================
   MODAL DE AUTENTICACIÓN (COMPACTO, LIMPIO, CON MARGEN)
   ======================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 44, 34, 0.88);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}

.auth-wrapper {
  background: #ffffff;
  border-radius: 16px;
  max-width: 820px;
  width: 100%;
  min-height: 460px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: 0.9fr 1fr;
  overflow: hidden;
  margin: auto;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* PANEL IZQUIERDO: ESTILO BOSQUE / ESMERALDA DE PROGRAMACIÓN */
.auth-illustration-side {
  background: linear-gradient(155deg, #022c22 0%, #064e3b 60%, #0f172a 100%);
  color: #ffffff;
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-illustration-side::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 1000' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' d='M0,0 C65,260 75,410 30,660 C-5,860 55,960 100,1000 L100,0 Z'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  pointer-events: none;
  z-index: 10;
}

.auth-brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
}

.auth-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  object-fit: cover;
  background: #000000;
}

.auth-brand-text h3 {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.auth-brand-text span {
  font-size: 10px;
  color: #6ee7b7;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-code-container {
  margin: 16px 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.code-window-card {
  background: rgba(2, 44, 34, 0.85);
  border: 1px solid rgba(110, 231, 183, 0.2);
  border-radius: 9px;
  padding: 12px 14px;
  font-family: var(--font-code);
  font-size: 10.5px;
  line-height: 1.5;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.code-dots {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dot { width: 7.5px; height: 7.5px; border-radius: 50%; }
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.c-kw { color: #38bdf8; font-weight: 600; }
.c-fn { color: #c084fc; }
.c-str { color: #34d399; }

.code-meta-badges {
  display: flex;
  gap: 8px;
}

.code-badge {
  background: rgba(6, 78, 59, 0.7);
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  color: #a7f3d0;
}

.auth-illustration-footer {
  z-index: 5;
  font-size: 10px;
  color: #a7f3d0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* PANEL DERECHO: FORMULARIO SIMPLE Y FUNCIONAL */
.auth-form-side {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #ffffff;
}

.auth-nav-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.auth-tab-btn {
  flex: 1;
  padding: 7px;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.auth-tab-btn.active {
  background: #ffffff;
  color: var(--brand-emerald);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.auth-form-view { display: none; }
.auth-form-view.active { display: block; }

.auth-header-text h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--brand-black);
  letter-spacing: -0.01em;
}

.auth-header-text p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  margin-bottom: 16px;
}

.auth-input-group {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-input-group label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
}

.auth-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-dark);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 12.5px;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

.auth-input:focus {
  border-color: var(--brand-emerald);
  box-shadow: 0 0 0 2px rgba(6, 78, 59, 0.12);
}

.auth-btn-primary {
  width: 100%;
  padding: 9px 14px;
  background: var(--brand-emerald);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  margin-top: 14px;
}

.auth-btn-primary:hover {
  background: var(--brand-emerald-hover);
}

.auth-switch-link {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 14px;
}

.auth-switch-link a {
  color: var(--brand-emerald);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.auth-switch-link a:hover { text-decoration: underline; }

/* ========================================================
   BARRA LATERAL ADAPTADA AL COLOR ESMERALDA DEL LOGIN
   ======================================================== */
aside.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 50;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

aside.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  background: #ffffff;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}

.brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  font-family: var(--font-mono);
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-emerald);
  background: var(--brand-black);
}

.brand-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-meta h2 {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--brand-black);
  line-height: 1.2;
}

.brand-meta span {
  font-size: 10px;
  color: var(--brand-emerald);
  font-weight: 600;
}

.sidebar.collapsed .brand-meta { display: none; }

.btn-toggle-sidebar {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-toggle-sidebar:hover {
  background: var(--brand-light);
  color: var(--brand-emerald);
  border-color: var(--border-emerald);
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
}

.nav-group-title {
  padding: 16px 16px 6px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-group-title { display: none; }

nav.sidebar-nav {
  padding: 0 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: transparent;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-item:hover {
  background: var(--brand-light);
  color: var(--brand-emerald);
}

.nav-item.active {
  background: var(--brand-emerald);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(6, 78, 59, 0.2);
}

.nav-svg-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .nav-label { display: none; }

.nav-item .pill {
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.nav-item.active .pill {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.sidebar.collapsed .nav-item .pill { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 14px 0; }

.user-avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-light);
  border: 1px solid var(--border-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--brand-emerald);
  flex-shrink: 0;
}

.user-data { font-size: 11px; line-height: 1.3; }
.sidebar.collapsed .user-data { display: none; }
.user-data strong { display: block; color: var(--text-main); font-weight: 700; }
.user-data span { color: var(--text-muted); font-size: 10px; }

/* CONTENEDOR PRINCIPAL */
main.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

header.top-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb strong { color: var(--brand-black); }

/* USER PROFILE MENU EN CABECERA */
.user-menu-wrapper {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 6px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.user-profile-btn:hover {
  background: var(--brand-light);
  border-color: var(--border-emerald);
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.user-role-subtitle {
  font-size: 10.5px;
  color: var(--brand-emerald);
  font-weight: 600;
}

.chevron-icon {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.user-menu-wrapper.open .chevron-icon {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 270px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  z-index: 100;
  overflow: hidden;
  animation: fadeInDropdown 0.15s ease forwards;
}

.user-menu-wrapper.open .user-dropdown-menu {
  display: block;
}

@keyframes fadeInDropdown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  padding: 14px 16px;
  background: #fafafa;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-circle.large {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.user-dropdown-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.user-dropdown-details strong {
  font-size: 12.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-details span {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
}

.user-dropdown-body, .user-dropdown-footer {
  padding: 6px;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--brand-light);
  color: var(--brand-emerald);
}

.dropdown-item-danger {
  color: #dc2626;
}

.dropdown-item-danger:hover {
  background: #fee2e2;
  color: #991b1b;
}

.content-area {
  padding: 24px 30px 48px 30px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.view-panel {
  display: none;
  animation: fadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 960px) {
  aside.sidebar:not(.expanded-mobile) {
    width: var(--sidebar-collapsed-w);
  }
  aside.sidebar.expanded-mobile {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 120;
    box-shadow: 12px 0 36px rgba(2, 44, 34, 0.25);
  }
  aside.sidebar:not(.expanded-mobile) .brand-meta,
  aside.sidebar:not(.expanded-mobile) .nav-group-title,
  aside.sidebar:not(.expanded-mobile) .nav-label,
  aside.sidebar:not(.expanded-mobile) .nav-item .pill,
  aside.sidebar:not(.expanded-mobile) .user-data {
    display: none;
  }
  aside.sidebar:not(.expanded-mobile) .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
  }
  aside.sidebar:not(.expanded-mobile) .nav-item {
    justify-content: center;
    padding: 12px 0;
  }
  aside.sidebar:not(.expanded-mobile) .sidebar-footer {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
  }
  main.main-content {
    min-width: 0;
    overflow-x: hidden;
  }
  header.top-header {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .user-name-title,
  .user-role-subtitle {
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .content-area {
    padding: 16px;
  }
  .auth-wrapper {
    grid-template-columns: 1fr;
  }
  .auth-illustration-side::after {
    display: none;
  }
}
