*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--cd-dark);
  background: var(--cd-light);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ══════════════════════════════════════════
   LOGIN
══════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cd-gradient);
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  top: -200px; right: -200px;
}
.login-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  bottom: -100px; left: -100px;
}

.login-card {
  background: var(--cd-white);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 440px;
  max-width: 95vw;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-logo { margin-bottom: 24px; }
.login-logo img { width: 200px; }

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--cd-dark);
  margin-bottom: 8px;
}
.login-card > p {
  font-size: 14px;
  color: var(--cd-gray-500);
  margin-bottom: 28px;
}
.login-note {
  font-size: 12px;
  color: var(--cd-gray-400);
  margin-top: 16px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: var(--cd-white);
  border: 2px solid var(--cd-gray-200);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: 15px;
  font-weight: 500;
  color: var(--cd-dark);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-google:hover {
  border-color: var(--cd-crimson);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--cd-dark);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed { width: 72px; }

/* Header with logo */
.sidebar-header {
  padding: 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
}

.sidebar-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
}

/* Full logo (expanded) */
.sidebar-logo-full {
  height: 28px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
  transition: opacity 0.2s;
}

/* Isotipo (collapsed) */
.sidebar-logo-icon-img {
  height: 32px;
  width: 32px;
  object-fit: contain;
  display: none;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-logo-full     { display: none; }
.sidebar.collapsed .sidebar-logo-icon-img { display: block; }

/* User profile area */
.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}
.sidebar-user:hover { background: rgba(255,255,255,0.05); }

.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--cd-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { color: var(--cd-gray-400); font-size: 11px; white-space: nowrap; }

.sidebar.collapsed .user-info { display: none; }

/* Nav */
.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section-label {
  color: var(--cd-gray-500);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 8px 2px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
  display: block;
}
.sidebar.collapsed .nav-section-label { opacity: 0; pointer-events: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--cd-gray-400);
  cursor: pointer;
  transition: all 0.2s;
  margin: 1px 0;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-link.active { background: rgba(240,159,0,0.16); color: #fecb66; }

.nav-icon  { font-size: 18px; flex-shrink: 0; }
.nav-label { font-size: 13px; font-weight: 500; }
.sidebar.collapsed .nav-label { display: none; }

.nav-badge {
  margin-left: auto;
  background: var(--cd-crimson);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
  all: unset;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--cd-gray-400);
  cursor: pointer;
  width: 100%;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); color: var(--cd-crimson-l); }
.sidebar.collapsed .btn-logout .nav-label { display: none; }

.sidebar-version {
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  padding: 6px 12px 2px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.2s;
}
.sidebar-version:hover { color: rgba(255,255,255,0.45); }
.sidebar.collapsed .sidebar-version { display: none; }

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 260px;
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-wrapper,
.sidebar.collapsed + .main-wrapper,
.main-wrapper.sidebar-collapsed {
  margin-left: 72px;
}

/* ── Topbar ── */
.topbar {
  background: var(--cd-white);
  border-bottom: 2px solid var(--cd-gray-200);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle sidebar — vive en la topbar */
.topbar-toggle {
  background: none;
  border: none;
  color: var(--cd-gray-500);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s;
  flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--cd-gray-100); color: var(--cd-dark); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--cd-dark);
}

.topbar-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--cd-dark);
}

.topbar-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--cd-gray-100);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--cd-gray-500);
  transition: all 0.2s;
  position: relative;
}
.topbar-btn:hover { background: var(--cd-gray-200); color: var(--cd-dark); }

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.profile-trigger:hover { background: var(--cd-gray-100); }
.profile-trigger .user-avatar { width: 32px; height: 32px; font-size: 12px; }

/* ── Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--cd-cream);
}

/* ══════════════════════════════════════════
   NOTIFICACIONES
══════════════════════════════════════════ */
.notif-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--cd-white);
  z-index: 200;
  box-shadow: var(--shadow-xl);
  transform: translateX(0);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}
.notif-drawer.hidden {
  display: flex !important;
  transform: translateX(100%);
}

.notif-drawer-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--cd-gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-drawer-header h3 { flex: 1; font-size: 17px; font-weight: 700; }

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  list-style: none;
}

.notif-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--cd-gray-100);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  gap: 12px;
}
.notif-item:hover { background: var(--cd-gray-50); }
.notif-item.unread { background: rgba(240,159,0,0.05); }

.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cd-amber);
  flex-shrink: 0;
  margin-top: 4px;
}
.notif-item.read .notif-dot { background: transparent; }

.notif-item-body { flex: 1; }
.notif-title { font-weight: 600; font-size: 13px; color: var(--cd-dark); }
.notif-text  { font-size: 12px; color: var(--cd-gray-500); margin-top: 2px; line-height: 1.4; }
.notif-time  { font-size: 11px; color: var(--cd-gray-400); margin-top: 4px; }

.notif-badge {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--cd-crimson);
  border-radius: 50%;
}

.btn-notifications { position: relative; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .sidebar { width: 72px; }
  .sidebar .nav-label,
  .sidebar .sidebar-logo-text-wrap,
  .sidebar .user-info,
  .sidebar .nav-section-label,
  .sidebar .nav-badge { display: none; }
  .main-wrapper { margin-left: 72px; }
}
