/* =====================================================
   TABLET LAYOUT — Panel de Estudio Contextual
   Fase 2: Nueva Arquitectura Responsive
   ===================================================== */

/* ─────────────────────────────────────────────────────
   Panel base: oculto por defecto
   ───────────────────────────────────────────────────── */
.tablet-study-panel {
  display: none;
  position: fixed;
  top: 80px;
  right: 18px;
  width: min(360px, 40vw);
  max-height: calc(100vh - 100px);
  z-index: 500;
  border-radius: var(--studio-radius-lg);
  background: var(--studio-panel);
  border: 1px solid rgba(255, 255, 255, 0.46);
  box-shadow: var(--studio-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-direction: column;
  overflow: hidden;
  animation: tablet-panel-in 0.28s cubic-bezier(0.34, 1.28, 0.64, 1) both;
}

@keyframes tablet-panel-in {
  from {
    opacity: 0;
    transform: translateX(28px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Solo mostrar en tablet landscape (≥820px) cuando hay selección */
@media (min-width: 820px) and (max-width: 1179px) {
  body.has-verse-selection .tablet-study-panel {
    display: flex;
  }
}

/* Nunca en desktop (tiene su propio sistema de ventanas) */
@media (min-width: 1180px) {
  .tablet-study-panel {
    display: none !important;
  }
}

/* ─────────────────────────────────────────────────────
   Header del panel
   ───────────────────────────────────────────────────── */
.tablet-study-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--studio-panel-muted);
  border-bottom: 1px solid var(--studio-line);
  flex-shrink: 0;
}

.tablet-study-meta {
  flex: 1;
  min-width: 0;
}

.tablet-study-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--studio-accent) 70%, var(--studio-muted));
  margin-bottom: 1px;
}

.tablet-study-ref {
  display: block;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  color: var(--studio-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.tablet-study-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--studio-muted) 14%, transparent);
  border: 1px solid var(--studio-line);
  color: var(--studio-muted);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  flex-shrink: 0;
  cursor: pointer;
}

.tablet-study-close:hover {
  background: var(--studio-hover);
  color: var(--studio-ink);
  transform: rotate(90deg);
}

/* ─────────────────────────────────────────────────────
   Previsualización del versículo seleccionado
   ───────────────────────────────────────────────────── */
.tablet-study-verse-preview {
  padding: 14px 16px;
  border-bottom: 1px solid var(--studio-line);
  flex-shrink: 0;
  max-height: 130px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--studio-panel-solid) 70%, transparent);
  scrollbar-width: thin;
  scrollbar-color: var(--studio-line) transparent;
}

.tablet-study-verse-preview::-webkit-scrollbar {
  width: 4px;
}
.tablet-study-verse-preview::-webkit-scrollbar-thumb {
  background: var(--studio-line);
  border-radius: 2px;
}

.tablet-study-verse-text {
  font-family: var(--font-title);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--studio-ink);
}

.tablet-study-verse-num {
  color: var(--studio-accent);
  font-weight: 800;
  font-family: var(--font-ui);
  margin-right: 4px;
  font-size: 0.8rem;
}

.tablet-study-verse-empty {
  color: var(--studio-muted);
  font-style: italic;
  font-size: 0.84rem;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────────
   Herramientas rápidas (IA / Comentarios / Strong)
   ───────────────────────────────────────────────────── */
.tablet-study-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--studio-line);
  flex-shrink: 0;
}

.tablet-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: var(--studio-radius-md);
  background: color-mix(in srgb, var(--studio-panel-solid) 82%, white 18%);
  border: 1px solid var(--studio-line);
  color: var(--studio-ink);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  letter-spacing: 0.02em;
}

.tablet-tool-btn:hover {
  background: var(--studio-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(20, 24, 32, 0.1);
  border-color: color-mix(in srgb, var(--studio-accent) 38%, var(--studio-line));
}

.tablet-tool-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* ─────────────────────────────────────────────────────
   Área de contenido de herramienta activa
   ───────────────────────────────────────────────────── */
.tablet-tool-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--studio-line) transparent;
}

.tablet-tool-content::-webkit-scrollbar {
  width: 4px;
}
.tablet-tool-content::-webkit-scrollbar-thumb {
  background: var(--studio-line);
  border-radius: 2px;
}

/* ─────────────────────────────────────────────────────
   Botón principal de acciones (abre el modal completo)
   ───────────────────────────────────────────────────── */
.tablet-study-open-actions {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 16px;
  background: linear-gradient(
    135deg,
    var(--studio-accent),
    color-mix(in srgb, var(--studio-accent) 72%, var(--studio-accent-2))
  );
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  border-top: 1px solid color-mix(in srgb, var(--studio-accent) 40%, transparent);
  transition: filter 0.18s;
  flex-shrink: 0;
}

.tablet-study-open-actions:hover {
  filter: brightness(1.08);
}

.tablet-study-open-actions svg {
  opacity: 0.88;
}

/* ─────────────────────────────────────────────────────
   Badge contador de versículos seleccionados
   ───────────────────────────────────────────────────── */
.tablet-selection-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--studio-accent);
  color: #111827;
  font-size: 0.72rem;
  font-weight: 900;
  font-family: var(--font-ui);
  margin-left: 6px;
}

/* ─────────────────────────────────────────────────────
   Tablet portrait (≤819px): panel NO se muestra, 
   el sistema de bottom-sheets sigue activo.
   ───────────────────────────────────────────────────── */
@media (max-width: 819px) {
  .tablet-study-panel {
    display: none !important;
  }
}

/* ─────────────────────────────────────────────────────
   Scroll suave en la zona de lectura cuando el panel
   está abierto (tablet landscape) — dar margen derecho
   ───────────────────────────────────────────────────── */
@media (min-width: 820px) and (max-width: 1179px) {
  body.has-verse-selection .content,
  body.has-verse-selection #content {
    padding-right: min(390px, 42vw);
    transition: padding-right 0.28s ease;
  }
}
