/* ============================================================================
   layout.css — Estructura del dashboard: sidebar, header y área de contenido
   ========================================================================== */

.layout {
  display: flex;
  min-height: 100vh;
  background: var(--color-cream);
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #f4ead9;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 var(--space-4);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar__logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 3px;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-sm);
}
.sidebar__brand-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition);
}
.sidebar__brand-name {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}
.sidebar__brand-sub {
  font-size: var(--font-size-xs);
  color: var(--color-gold-bright);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}
.nav-section {
  margin-bottom: var(--space-4);
}
.nav-section__title {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  margin-bottom: var(--space-1);
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  text-align: left;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.nav-item.is-active {
  background: linear-gradient(90deg, var(--color-gold), var(--color-gold-bright));
  color: var(--color-primary-dark);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav-item__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}
.nav-item__icon svg {
  width: 22px;
  height: 22px;
}
.nav-item__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar__footer {
  flex-shrink: 0;
  padding: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  white-space: nowrap;
}

/* ---- Estado colapsado (solo iconos) ---- */
.layout.is-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}
.layout.is-collapsed .sidebar__brand-text,
.layout.is-collapsed .nav-item__label,
.layout.is-collapsed .nav-section__title,
.layout.is-collapsed .sidebar__footer span {
  opacity: 0;
  width: 0;
}
.layout.is-collapsed .nav-item {
  justify-content: center;
  padding: var(--space-3);
}
.layout.is-collapsed .sidebar__brand {
  justify-content: center;
  padding: 0;
}

/* ---- Main ---- */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}
.layout.is-collapsed .main {
  margin-left: var(--sidebar-width-collapsed);
}

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--header-height);
  padding: 0 var(--space-5);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.header__toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: var(--color-primary);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: background var(--transition);
}
.header__toggle:hover {
  background: var(--color-cream-dark);
}
.header__toggle svg {
  width: 20px;
  height: 20px;
}
.header__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header__spacer {
  flex: 1;
}
.header__company {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 240px;
  padding: var(--space-1) var(--space-3);
  color: var(--color-primary);
  background: var(--color-cream);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}
.header__company:hover {
  background: var(--color-cream-dark);
  border-color: var(--color-gold);
}
.header__company__icon {
  display: grid;
  place-items: center;
  color: var(--color-gold);
  flex-shrink: 0;
}
.header__company__icon svg {
  width: 18px;
  height: 18px;
}
.header__company__name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Perfil de usuario ---- */
.profile {
  position: relative;
}
.profile__button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  transition: background var(--transition), border-color var(--transition);
}
.profile__button:hover {
  background: var(--color-cream-dark);
  border-color: var(--color-border);
}
.profile__avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: #fff;
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-bright));
  border-radius: var(--radius-pill);
}
.profile__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: left;
}
.profile__name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}
.profile__role {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.profile__chevron {
  color: var(--color-text-muted);
}
.profile__chevron svg {
  width: 16px;
  height: 16px;
}

/* ---- Menú desplegable del perfil ---- */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 240px;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown__head {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}
.dropdown__head .profile__name {
  color: var(--color-primary);
}
.dropdown__email {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  word-break: break-all;
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  color: var(--color-text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: var(--font-size-sm);
  transition: background var(--transition);
}
.dropdown__item:hover {
  background: var(--color-cream-dark);
}
.dropdown__item--danger {
  color: var(--color-danger);
}
.dropdown__item--danger:hover {
  background: var(--color-danger-soft);
}
.dropdown__item svg {
  width: 18px;
  height: 18px;
}

/* ---- Área de contenido ---- */
.content {
  flex: 1;
  padding: var(--space-6) var(--space-5);
}
.content__inner {
  max-width: 1280px;
  margin: 0 auto;
}

/* ---- Backdrop móvil ---- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(26, 26, 26, 0.5);
  opacity: 0;
  transition: opacity var(--transition);
}
