/* ==========================================================================
   Galería Interactiva de Obras Maestras del Arte - Estilos Canónicos
   Paleta: Pinacoteca Oscura Midnight Slate (#0b0f17) y Visualizador IIIF
   ========================================================================== */

:root {
  --bg-main: #0b0f17;
  --bg-card: #131b28;
  --bg-card-alt: #1a2436;
  --border-color: #243044;

  --accent-gold: #f59e0b;
  --accent-blue: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #cbd5e1;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-frame: 0 20px 35px -10px rgba(0, 0, 0, 0.7);
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema claro */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --border-color: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #334155;

  --shadow-card: 0 10px 20px -5px rgba(15, 23, 42, 0.08);
  --shadow-frame: 0 15px 30px -10px rgba(0, 0, 0, 0.15);
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
}

/* Panel de control de la galería */
.gallery-controls-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.gallery-controls-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.gallery-meta {
  flex: 1 1 300px;
}

.badge-iiif {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #f59e0b;
  background-color: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 0.4rem;
}

.gallery-heading {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.gallery-subtext {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.search-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
}

@media (max-width: 600px) {
  .search-box-wrapper {
    max-width: 100%;
  }
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.art-search-input {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-alt);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  padding: 0 0.85rem 0 36px;
  outline: none;
  transition: var(--transition-smooth);
}

.art-search-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Píldoras de colecciones */
.collections-pills-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

.collection-pill {
  min-height: 40px;
  padding: 0 1.1rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-alt);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.collection-pill:hover, .collection-pill.active {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #0b0f17;
}

/* Cuadrícula de lienzos */
.artworks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: stretch;
}

.artwork-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  outline: none;
}

.artwork-card:hover, .artwork-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent-gold);
  box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.6);
}

.artwork-thumb-wrap {
  position: relative;
  width: 100%;
  height: 250px;
  background-color: #05070c;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.artwork-thumb-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
  display: block;
}

.artwork-card:hover .artwork-thumb-img {
  transform: scale(1.05);
}

.artwork-hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.artwork-card:hover .artwork-hover-overlay {
  opacity: 1;
}

.btn-inspect-overlay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 1rem;
  background-color: var(--accent-gold);
  color: #0b0f17;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.artwork-card-info {
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  justify-content: space-between;
  background-color: var(--bg-card);
}

.artwork-card-artist {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.artwork-card-title {
  font-family: var(--font-heading);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 0.6rem;
  height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.artwork-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-date {
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.meta-separator {
  color: var(--text-dim);
}

.meta-medium {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cargador y estados vacíos */
.art-loading-state, .art-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.art-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-reset-search {
  margin-top: 1rem;
  padding: 0.6rem 1.25rem;
  min-height: 40px;
  background-color: var(--accent-gold);
  color: #0b0f17;
  border: none;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-reset-search:hover {
  background-color: #d97706;
}

/* Ficha didáctica IIIF */
.iiif-info-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.info-card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.info-card-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   Modal inmersivo con visor IIIF (Overlay Fixed Flotante)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-art-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 1080px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 92vh;
  position: relative;
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-art-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-card);
  flex-shrink: 0;
}

.modal-art-titles {
  min-width: 0;
  flex: 1;
  padding-right: 1rem;
}

.modal-art-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-art-artist {
  display: block;
  font-size: 0.85rem;
  color: var(--accent-gold);
  font-weight: 600;
  margin-top: 2px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-close-modal:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.modal-art-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  overflow: hidden;
  flex: 1 1 auto;
}

@media (max-width: 860px) {
  .modal-overlay {
    padding: 0.75rem;
  }

  .modal-art-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

/* Viewport con zoom */
.art-zoom-viewport {
  position: relative;
  background-color: #05070c;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
  height: 100%;
}

.art-zoom-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.12s ease-out;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.zoom-controls-floating {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 4px;
  background-color: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(4px);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  z-index: 5;
}

.btn-zoom-action {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-alt);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-zoom-action:hover {
  background-color: var(--accent-gold);
  color: #0b0f17;
}

/* Barra lateral de detalles en el modal */
.art-details-sidebar {
  background-color: var(--bg-card);
  border-left: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

@media (max-width: 860px) {
  .art-details-sidebar {
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding: 1.25rem;
  }

  .art-zoom-viewport {
    min-height: 320px;
    height: 360px;
  }
}

.detail-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-val {
  font-size: 0.88rem;
  color: var(--text-main);
  font-weight: 500;
  line-height: 1.4;
}

/* Extractor de paleta de colores */
.palette-extractor-block {
  padding: 1rem;
  background-color: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.palette-swatches-row {
  display: flex;
  gap: 6px;
  margin: 0.6rem 0;
  flex-wrap: wrap;
}

.palette-swatch-item {
  flex: 1 1 0%;
  min-width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.palette-swatch-item:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.swatch-hex-tag {
  display: none;
}

.palette-swatch-loading {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.palette-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-download-hd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  width: 100%;
  border-radius: 8px;
  background-color: var(--accent-gold);
  color: #0b0f17;
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  transition: var(--transition-smooth);
}

.btn-download-hd:hover {
  background-color: #d97706;
}

/* Toast flotante sin alerts */
.art-toast-notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background-color: rgba(17, 24, 39, 0.95);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.65rem 1.25rem;
  border-radius: 30px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.art-toast-notification.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
