:root {
  --bg: #0f0f14;
  --surface: #16161d;
  --surface-soft: #27272a;
  --text: #ededed;
  --muted: #9ca3af;
  --accent: #7c5cff;
  --accent-soft: #a78bfa;
  --border: #2f2f37;
  --ok: #81c784;
}

* {
  box-sizing: border-box;
}

/* Marcar cualquier elemento con el atributo hidden como display: none !important; */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, #1d1d2a 0%, var(--bg) 40%);
  color: var(--text);
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: Manrope, Inter, sans-serif;
  letter-spacing: 0.01em;
  margin: 0;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 15, 20, 0.96);
  backdrop-filter: blur(3px);
}

.brand {
  font-family: Manrope, Inter, sans-serif;
  font-weight: 700;
}

.main-nav {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-tab,
.nav-link,
.nav-info {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  text-decoration: none;
}

.nav-tab {
  cursor: pointer;
}

.nav-tab.is-active {
  border-color: var(--accent);
}

.counter {
  color: var(--accent-soft);
  margin-left: 0.35rem;
}

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

.intro p,
.results-info,
.template-category,
.template-description,
.template-tags,
.detail-category {
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control span {
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 0.65rem;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.section-title {
  margin: 1.25rem 0 0.8rem;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-link {
  display: block;
  aspect-ratio: 16 / 10;
  background: #0b0b10;
  position: relative;
}

.preview-image,
.preview-video,
.preview-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(15, 15, 20, 0.75);
  backdrop-filter: blur(4px);
  color: var(--accent-soft);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
  z-index: 2;
  transition: all 0.2s ease;
}

.template-card:hover .preview-badge {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.preview-fallback {
  display: grid;
  place-items: center;
  color: #5f6380;
  font-weight: 600;
}

.preview-fallback::before {
  content: "Sin preview";
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.85rem;
  flex: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
}

.favorite-btn {
  min-width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #101018;
  color: var(--text);
  cursor: pointer;
}

.favorite-btn.is-favorite {
  border-color: var(--accent-soft);
  color: var(--accent-soft);
}

.viewed-badge {
  display: inline-block;
  border: 1px solid #34503b;
  color: var(--ok);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.open-btn,
.button-primary,
.button-secondary {
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  padding: 0.45rem 0.7rem;
  text-decoration: none;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #f5f5f5;
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
}

.detail-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--surface);
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 210px;
}

.preview-panel {
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  overflow: hidden;
  background: #0b0b10;
  min-height: 60vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.preview-panel:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.preview-panel:fullscreen iframe {
  min-height: 0;
  flex: 1;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.preview-modes {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  overflow: hidden;
}

.preview-mode-button {
  border-radius: 0;
  border: 0;
  border-right: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.preview-mode-button:last-child {
  border-right: 0;
}

.preview-mode-button.is-active {
  background: var(--accent);
  color: #f5f5f5;
}

.preview-status {
  color: var(--muted);
  font-size: 0.85rem;
}

.preview-status.is-ready {
  color: var(--ok);
}

.preview-viewport {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 60vh;
  flex: 1;
}

.preview-panel iframe {
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: 0;
  display: block;
}

.preview-panel[data-view-mode="tablet"] .preview-viewport {
  max-width: 820px;
}

.preview-panel[data-view-mode="mobile"] .preview-viewport {
  max-width: 390px;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
}

.feedback {
  min-height: 1.2rem;
  color: var(--accent-soft);
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 0.9rem;
  padding: 1.2rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .templates-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .templates-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 1rem;
  }
}
