:root {
  --primary: #16a34a;
  --primary-hover: #10893d;
  --secondary: #0f172a;
  --bg-color: #f1f5f9;
  --sidebar-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: "Outfit", sans-serif;
  background-color: var(--bg-color);
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 0.03) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 0.03) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 0.03) 0, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  padding: 1rem;
  gap: 1rem;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  position: relative;
  z-index: 10;
  transition: var(--transition);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), #10893d);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  padding: 5px;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.logo-container h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: -0.5px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: var(--transition);
  font-weight: 500;
}

.nav-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background: #f8fafc;
  color: var(--primary);
  transform: translateX(4px);
}

.nav-item.active {
  background: #eff6ff;
  color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: white;
  text-decoration: none;
  padding: 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--secondary);
  cursor: pointer;
  padding: 0.5rem;
  transition: var(--transition);
}

.hamburger-btn:hover {
  color: var(--primary);
}

.btn-download:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.top-header {
  background: var(--sidebar-bg);
  border-radius: var(--radius-lg);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-title h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--secondary);
}

.badge {
  background: #dbeafe;
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.icon-btn:hover {
  background: #f1f5f9;
  color: var(--secondary);
}

.user-profile img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  cursor: pointer;
  transition: var(--transition);
}

.user-profile img:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}

/* Viewer Container */
.viewer-container {
  flex: 1;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.viewer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-info {
  font-size: 0.95rem;
  color: var(--text-main);
  min-width: 120px;
  text-align: center;
}

.viewer-wrapper {
  flex: 1;
  border-radius: var(--radius-md);
  overflow: auto;
  background: #e2e8f0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

#pdf-render {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  background: #fff;
  max-width: 100%;
  height: auto !important;
  margin: 0 auto;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar,
.top-header,
.viewer-container {
  animation: fadeIn 0.5s ease-out forwards;
}

.sidebar {
  animation-delay: 0.1s;
}
.top-header {
  animation-delay: 0.2s;
}
.viewer-container {
  animation-delay: 0.3s;
  opacity: 0;
}

/* Skeleton Loader */
.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 800px;
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}
.skeleton-header {
  height: 40px;
  background: #e2e8f0;
  border-radius: 4px;
  margin-bottom: 20px;
  animation: pulse 1.5s infinite;
}
.skeleton-line {
  height: 15px;
  background: #e2e8f0;
  border-radius: 4px;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}
.loading-text {
  text-align: center;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 220px;
    padding: 1rem;
  }
  .header-title h1 {
    font-size: 1.2rem;
  }
}

@media (max-width: 768px) {
  body {
    overflow: hidden; /* Mantiene la sensación de App nativa */
  }
  
  .app-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Ajuste perfecto para navegadores móviles con barra de URL dinámica */
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .sidebar {
    width: 100%;
    padding: 0.75rem 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    margin-bottom: 0;
    flex-wrap: wrap; /* Permitir que el menú caiga debajo si está abierto */
  }

  .hamburger-btn {
    display: block; /* Mostramos el botón en móviles */
  }

  .logo-container {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    gap: 0.5rem;
  }
  
  .logo-container h2 {
    font-size: 1.1rem;
  }
  
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .nav-menu {
    display: none; /* Oculto por defecto */
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
    flex: unset;
    margin-top: 1rem;
    animation: fadeIn 0.3s ease-out forwards;
  }

  .nav-menu.show-menu {
    display: flex;
  }
  
  .nav-item {
    padding: 0.75rem;
    justify-content: center;
    background: #f8fafc;
  }
  
  .nav-item span {
    display: inline; /* Restaurar el texto del menú en móviles cuando esté abierto */
  }

  .sidebar-footer {
    display: none;
  }

  .top-header {
    display: none; /* Ocultamos el header superior redundante para maximizar el espacio de lectura */
  }

  .viewer-container {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .viewer-controls {
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }
  
  .control-group {
    gap: 0.5rem;
  }

  .page-info {
    font-size: 0.85rem;
    min-width: 80px;
  }

  .icon-btn {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .viewer-wrapper {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
  }

  #pdf-render {
    max-width: 100%;
    height: auto !important;
  }
}
