/* Bisecreta Modern UI Glassmorphism Theme */

:root {
  --bg-color: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #8b5cf6;
  --primary-hover: #a78bfa;
  --secondary: #3b82f6;
  --glass-bg: rgba(30, 41, 59, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --font-family: 'Outfit', sans-serif;
  --book-cover-bg: #2a3143;
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.1);
  --search-glow: rgba(139, 92, 246, 0.3);

  --blob-1: #c084fc;
  --blob-2: #38bdf8;
}

body.light-theme {
  --bg-color: #f0f4ff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(139, 92, 246, 0.15);
  --glass-shadow: 0 4px 32px rgba(99, 51, 180, 0.08);
  --book-cover-bg: #ede9fe;
  --input-bg: rgba(255, 255, 255, 0.7);
  --input-border: rgba(139, 92, 246, 0.2);
  --search-glow: rgba(139, 92, 246, 0.25);
  --blob-1: #c4b5fd;
  --blob-2: #93c5fd;
}
body.light-theme {
  background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 50%, #f0f9ff 100%);
  color: var(--text-main);
}
/* Glassmorphism en modo claro: inputs, textareas, selects */
body.light-theme input,
body.light-theme textarea,
body.light-theme select {
  color: var(--text-main) !important;
  background: var(--input-bg) !important;
  border-color: var(--input-border) !important;
}
body.light-theme input::placeholder { color: #94a3b8; }
/* Texto muted no desaparece */
body.light-theme .text-muted,
body.light-theme [style*="color: #94a3b8"],
body.light-theme [style*="color:#94a3b8"] { color: #64748b !important; }
/* Nav links en modo claro */
body.light-theme .nav-link { color: #64748b !important; }
body.light-theme .nav-link:hover { color: #1e293b !important; }
body.light-theme .glass-footer { color: #64748b; border-color: var(--glass-border); }

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

html {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  height: 100%;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  /* Fix para PWA: usa dvh (dynamic viewport height) si está disponible,
     evita el doble scroll causado por 100vh en modo standalone */
  min-height: 100dvh;
  position: relative;
}

/* Background Animated Blobs */
.blob {
  position: fixed; /* fixed en vez de absolute para no participar en el flex layout */
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.5;
  animation: float 20s infinite alternate cubic-bezier(0.5, 0, 0.5, 1);
  pointer-events: none;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: var(--blob-1);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 600px;
  height: 600px;
  background: var(--blob-2);
  bottom: -200px;
  right: -150px;
  animation-duration: 25s;
}

@keyframes float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-50px) scale(1.1); }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Glassmorphism Navbar */
.glass-navbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 20px 40px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  flex-shrink: 0; /* No se comprima en layout flex */
}

.nav-brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.nav-links .nav-link, .nav-user .nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  margin-left: 15px;
  margin-right: 15px;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.nav-links .nav-link:hover {
  color: var(--text-main);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease;
  margin-left: 10px;
}
.theme-toggle:hover { border-color: var(--primary); }

/* Hero Section */
.hero-section {
  text-align: center;
  padding: 80px 0 60px;
}

.hero-title {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 20px;
}

.text-gradient {
  background: linear-gradient(135deg, var(--blob-1), var(--blob-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 40px;
  font-weight: 300;
}

/* Search Wrapper */
.search-wrap {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.glass-search {
  width: 100%;
  padding: 20px 30px;
  font-size: 1.5rem;
  font-family: var(--font-family);
  border-radius: 50px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  outline: none;
}

.glass-search:focus {
  border-color: var(--primary);
  background: var(--input-bg);
  box-shadow: 0 0 20px var(--search-glow);
}

.search-options {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  gap: 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Features grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-top: 60px;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--glass-shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
}

.feature-card h3 {
  font-size: 1.4rem;
  margin-bottom: 15px;
  font-weight: 600;
}

.feature-card p {
  color: var(--text-muted);
  line-height: 1.6;
}

/* Results section */
.results-layout {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-title {
  font-size: 2rem;
  margin-bottom: 20px;
  font-weight: 800;
  border-bottom: 2px solid var(--glass-border);
  display: inline-block;
  padding-bottom: 10px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 25px;
}

/* Interactive Book Cards */
.book-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text-main);
}

.book-card:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(139, 92, 246, 0.4);
}

.book-cover {
  width: 100%;
  aspect-ratio: 0.666666; /* 2:3 ratio typical for ebooks */
  background-color: var(--book-cover-bg);
  /* Background images are set via JS sprite logic */
}

.book-info {
  padding: 15px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.book-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 0.85rem;
  color: var(--primary-hover);
  font-weight: 400;
}

.book-read-count {
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #f8fafc;
  background: rgba(139, 92, 246, 0.35);
  border: 1px solid rgba(139, 92, 246, 0.5);
  border-radius: 999px;
  padding: 2px 8px;
  display: inline-block;
  letter-spacing: 0.02em;
}

/* Author Item */
.author-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}

.author-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.author-item:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--primary);
  transform: translateX(5px);
}

.badge {
  background: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mt-5 {
  margin-top: 50px;
}

.glass-footer {
  text-align: center;
  padding: 30px;
  margin-top: 80px;
  border-top: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Hamburger button — hidden on desktop */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: 1.3rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}

/* Mobile dropdown menu — hidden by default */
.nav-mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 20px;
  gap: 12px;
  position: sticky;
  top: 56px; /* altura del navbar móvil */
  z-index: 99;
}

.nav-mobile-menu.open { display: flex; }

.nav-mobile-menu .nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--glass-border);
}

.nav-mobile-menu .nav-link:last-child { border-bottom: none; }
.nav-mobile-menu .nav-link:hover { color: #fff; }

#user-menu-mobile {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.nav-mobile-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 2px 0;
}

/* Responsive */
@media (max-width: 900px) {
  .hero-title { font-size: 2.2rem; }
  .hero-subtitle { font-size: 1.1rem; }
  .glass-search { font-size: 1.2rem; padding: 15px 20px; }

  .glass-navbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 10px 16px;
    gap: 0;
  }
  .nav-links { display: none; }   /* ocultos — se muestran en el dropdown */
  /* nav-right: push al extremo derecho, ocultar user-links, mostrar toggle + hamburger */
  .nav-right { margin-left: auto; justify-content: flex-end; }
  .nav-right .nav-user { display: none; }
  .nav-hamburger { display: block; }

  .nav-brand { font-size: 1.1rem; }
  .container { padding: 0 15px; }
}

#hall-of-fame-section {
    text-align: center;
}

/* Podium Styles */
.podium-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 15px;
  margin-top: 60px;
  margin-bottom: 40px;
  min-height: 250px;
  perspective: 1000px;
}

.podium-place {
  width: 150px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 15px 15px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 20px 10px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: floatPodium 3s ease-in-out infinite alternate;
}

.podium-place:hover {
  transform: translateY(-15px) scale(1.05);
  z-index: 10;
}

.podium-first {
  height: 240px;
  border-top: 3px solid #ffd700;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.2) 0%, rgba(30, 41, 59, 0.8) 100%);
  z-index: 3;
  animation-delay: 0s;
  box-shadow: 0 -15px 40px rgba(255, 215, 0, 0.3);
}

.podium-second {
  height: 180px;
  border-top: 3px solid #c0c0c0;
  background: linear-gradient(180deg, rgba(192, 192, 192, 0.2) 0%, rgba(30, 41, 59, 0.8) 100%);
  z-index: 2;
  animation-delay: -1s;
  box-shadow: 0 -10px 30px rgba(192, 192, 192, 0.2);
}

.podium-third {
  height: 140px;
  border-top: 3px solid #cd7f32;
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.2) 0%, rgba(30, 41, 59, 0.8) 100%);
  z-index: 1;
  animation-delay: -2s;
  box-shadow: 0 -10px 30px rgba(205, 127, 50, 0.2);
}

.podium-medal {
  font-size: 3.5rem;
  margin-bottom: 5px;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5));
  position: absolute;
  top: -45px;
  animation: pulseMedal 2s infinite;
}

.podium-username {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  margin-top: 20px;
  margin-bottom: 10px;
  text-align: center;
  word-break: break-all;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.podium-stats {
  font-size: 1rem;
  color: var(--primary);
  font-weight: bold;
}

.podium-first .podium-stats {
  color: #ffd700;
}

.podium-details {
  display: flex;
  justify-content: space-around;
  width: 100%;
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-top: auto;
}

@keyframes floatPodium {
  0% { transform: translateY(0px); }
  100% { transform: translateY(6px); }
}

@keyframes pulseMedal {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); filter: drop-shadow(0 5px 15px rgba(255, 255, 255, 0.4)); }
  100% { transform: scale(1); }
}

@media (max-width: 600px) {
  .podium-place { width: 100px; padding: 15px 5px; }
  .podium-first { height: 200px; }
  .podium-second { height: 160px; }
  .podium-third { height: 130px; }
  .podium-medal { font-size: 2.5rem; top: -35px; }
  .podium-username { font-size: 0.9rem; margin-top: 15px; }
  .podium-stats { font-size: 0.85rem; }
  .podium-details { flex-direction: column; align-items: center; gap: 5px; }
}

/* AI Chatbot */
#ai-chat-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}

#ai-chat-btn {
    background: linear-gradient(135deg, #8b5cf6, #f472b6);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-chat-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

#ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.3s, transform 0.3s;
}

#ai-chat-window.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

#ai-chat-header {
    background: rgba(30, 41, 59, 0.8);
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#ai-chat-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

#ai-chat-close:hover {
    color: var(--text-main);
}

#ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
}

.ai-msg.bot {
    background: rgba(139, 92, 246, 0.2);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.ai-msg.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-msg p {
    margin-top: 0;
    margin-bottom: 8px;
}
.ai-msg p:last-child {
    margin-bottom: 0;
}
.ai-msg strong {
    color: #a78bfa;
}

#ai-chat-input-area {
    padding: 15px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
    background: rgba(15, 23, 42, 0.5);
}

#ai-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 20px;
    font-family: inherit;
    outline: none;
}

#ai-chat-send {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}

#ai-chat-send:hover {
    background: #a78bfa;
}

@media (max-width: 600px) {
    #ai-chat-container { bottom: 20px; right: 20px; }
    #ai-chat-window {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        z-index: 99999;
        box-sizing: border-box;
    }
}
