/* fastecom - Layout compartido: sidebar 72px, expand hover, hamburger móvil */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
}

/* Contenedor principal: sidebar + contenido */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar desktop ----- */
.sidebar {
  width: 72px;
  min-width: 72px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, min-width 0.25s ease;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar:hover {
  width: 240px;
  min-width: 240px;
}

.sidebar-header {
  padding: 1rem;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-bottom: 1px solid #f1f5f9;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.sidebar:hover .sidebar-logo,
.sidebar.open .sidebar-logo {
  width: 160px;
  min-width: 160px;
  height: 48px;
}

.sidebar:hover .sidebar-logo img,
.sidebar.open .sidebar-logo img {
  width: 160px;
  height: 48px;
  object-fit: contain;
  object-position: center;
}


.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem 1rem;
  margin: 0 0.5rem;
  border-radius: 12px;
  color: #64748b;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.sidebar-nav a.active {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.sidebar-nav a .nav-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-nav a span.text {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar:hover .sidebar-nav a span.text {
  opacity: 1;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar:hover .sidebar-user-info {
  opacity: 1;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: #3b82f6;
  color: white;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: #ef4444;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  width: 100%;
  text-align: left;
  transition: background 0.2s;
}

.sidebar-logout:hover {
  background: #fef2f2;
}

.sidebar-logout .nav-icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex-shrink: 0;
}

.sidebar-logout span.text {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar:hover .sidebar-logout span.text {
  opacity: 1;
}

/* Área principal */
.main-content {
  flex: 1;
  margin-left: 72px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

/* ----- Header móvil (hamburger + logo) ----- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 99;
}

.mobile-header .sidebar-logo {
  width: 120px;
  height: 36px;
  min-width: 120px;
  min-height: 36px;
}

.mobile-header .sidebar-logo img {
  width: 120px;
  height: 36px;
  object-fit: contain;
  object-position: left center;
}

.mobile-header .sidebar-brand {
  opacity: 1;
  font-size: 1rem;
}

.mobile-header a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #1e293b;
  font-weight: 700;
}

.hamburger {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border-radius: 8px;
  transition: background 0.2s;
}

.hamburger:hover {
  background: #f1f5f9;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #475569;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.sidebar.open .hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.sidebar.open .hamburger span:nth-child(2) {
  opacity: 0;
}

.sidebar.open .hamburger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Overlay móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* ----- Responsive: móvil ----- */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding-top: 72px; /* espacio para header móvil */
  }

  .sidebar {
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar:hover {
    width: 280px;
    min-width: 280px;
  }

  .sidebar .sidebar-nav a span.text,
  .sidebar .sidebar-user-info,
  .sidebar .sidebar-logout span.text {
    opacity: 1;
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.visible {
    pointer-events: auto;
  }

}

/* Utilidad: ocultar enlace en sidebar si no admin */
.sidebar-nav a[data-admin-only] {
  display: none;
}

body.user-is-admin .sidebar-nav a[data-admin-only] {
  display: flex;
}

/* Reseñas: oculto por defecto, visible solo si el usuario tiene permiso */
.sidebar-nav a[data-requires-reviews],
[data-requires-reviews] {
  display: none !important;
}

body.user-has-reviews .sidebar-nav a[data-requires-reviews],
body.user-has-reviews [data-requires-reviews] {
  display: flex !important;
}

body.user-has-reviews .stat-card[data-requires-reviews],
body.user-has-reviews .action-card[data-requires-reviews] {
  display: block !important;
}

body.user-has-reviews .app-tab[data-requires-reviews] {
  display: inline-flex !important;
}
