/* ============ COMPONENTS — Search Modal, Toast, Resource Cards ============ */

/* SEARCH MODAL */
.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.search-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}
.search-input-wrapper svg { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.search-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  padding: 0;
}
.search-input-wrapper input:focus { box-shadow: none; }
.search-input-wrapper kbd {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-hover); }

.search-result-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 1rem;
  flex-shrink: 0;
}

.search-result-info { flex: 1; min-width: 0; }
.search-result-title { font-size: 0.875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-desc { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-result-badges { display: flex; gap: 0.3rem; flex-shrink: 0; }

.search-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* RESOURCE CARD — Grid Mode */
.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.resource-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.resource-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.resource-card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.resource-card-icon.cat-prompts { background: var(--accent-bg); }
.resource-card-icon.cat-agentes { background: var(--green-bg); }
.resource-card-icon.cat-n8n { background: var(--orange-bg); }
.resource-card-icon.cat-ventas { background: var(--yellow-bg); }
.resource-card-icon.cat-mcp { background: var(--blue-bg); }
.resource-card-icon.cat-dev { background: var(--blue-bg); }
.resource-card-icon.cat-directorios { background: var(--green-bg); }
.resource-card-icon.cat-newsletters { background: var(--red-bg); }

.resource-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
}

.resource-card-fav {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  transition: all var(--transition);
  z-index: 2;
}
.resource-card-fav:hover { background: var(--yellow-bg); color: var(--yellow); }
.resource-card-fav.is-fav { color: var(--yellow); }
.resource-card-fav svg { width: 16px; height: 16px; }

.resource-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.resource-card-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.resource-card-tag {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-muted);
}

/* RESOURCE CARD — List Mode */
.resources-grid.list-mode {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.resources-grid.list-mode .resource-card {
  flex-direction: row;
  align-items: center;
  padding: 0.7rem 1rem;
  gap: 1rem;
}

.resources-grid.list-mode .resource-card-header { flex: 0 0 auto; }
.resources-grid.list-mode .resource-card-desc { flex: 1; -webkit-line-clamp: 1; }
.resources-grid.list-mode .resource-card-footer { flex: 0 0 auto; margin-top: 0; }
.resources-grid.list-mode .resource-card-fav { position: static; }

/* DETAIL VIEW */
.detail-back { margin-bottom: 1rem; }

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.detail-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 1.6rem;
  flex-shrink: 0;
}

.detail-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.3rem; }
.detail-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

.detail-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.detail-tag {
  padding: 0.3rem 0.7rem;
  background: var(--bg-hover);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ============ FICHA DE PRODUCTO — S3 ============ */

.ficha-header {
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.ficha-header-info { flex: 1; min-width: 0; }
.ficha-fav-btn { flex-shrink: 0; }

.ficha-gerardino-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.6rem;
  font-size: 0.72rem;
  padding: 0.22rem 0.6rem;
  background: var(--yellow-bg);
  color: var(--yellow);
  border-radius: 999px;
  font-weight: 600;
}

/* Metrics strip */
.ficha-metrics {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1rem 1.2rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.ficha-metric { display: flex; flex-direction: column; gap: 0.3rem; }
.ficha-metric-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.ficha-metric-val { font-size: 0.72rem; color: var(--text-muted); }
.ficha-metric-time { font-size: 0.88rem; font-weight: 600; color: var(--text-secondary); }

.ficha-metric-stars { display: flex; gap: 2px; }
.ficha-star { font-size: 0.9rem; line-height: 1; }
.ficha-star-red { color: var(--red); }
.ficha-star-yellow { color: var(--yellow); }
.ficha-star-green { color: var(--green); }
.ficha-star-empty { color: var(--border); }

.ficha-metric-bars { display: flex; gap: 3px; align-items: flex-end; }
.ficha-bar { width: 14px; height: 12px; border-radius: 3px; }
.ficha-bar-green { background: var(--green); }
.ficha-bar-empty { background: var(--border); }

/* Sections */
.ficha-section { margin-bottom: 1.5rem; }
.ficha-section-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
}
.ficha-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.ficha-description {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.ficha-url-link {
  font-size: 0.8rem;
  color: var(--accent);
  word-break: break-all;
  text-underline-offset: 3px;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color var(--transition);
}
.ficha-url-link:hover { text-decoration-color: var(--accent); }

/* Invocation grid */
.ficha-invoke-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.6rem;
}
.ficha-invoke-card {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color var(--transition);
}
.ficha-invoke-card:hover { border-color: var(--accent); }
.ficha-invoke-method {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ficha-invoke-cmd {
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.78rem;
  background: var(--bg-input);
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  color: var(--text-primary);
  border: 1px solid var(--border);
  word-break: break-all;
}
.ficha-invoke-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Use cases */
.ficha-usecases { display: flex; flex-direction: column; gap: 0.7rem; }
.ficha-usecase-area {
  background: var(--bg-hover);
  border-radius: var(--radius-xs);
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--accent);
}
.ficha-usecase-area-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.ficha-usecase-list { list-style: none; display: flex; flex-direction: column; gap: 0.22rem; }
.ficha-usecase-list li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding-left: 1.1rem;
  position: relative;
  line-height: 1.4;
}
.ficha-usecase-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Where not to use */
.ficha-no-use { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.ficha-no-use li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
  background: var(--red-bg);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(248,113,113,0.15);
  line-height: 1.4;
}
.ficha-no-use-icon { color: var(--red); flex-shrink: 0; }

/* Related resources */
.ficha-related {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 0.6rem;
}
.ficha-related-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
}
.ficha-related-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.ficha-related-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  font-size: 1rem;
  flex-shrink: 0;
}
.ficha-related-title { font-size: 0.8rem; font-weight: 600; line-height: 1.3; }
.ficha-related-cat { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.1rem; }

/* Contenido descargado (markdown embebido) */
.ficha-contenido-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-hover);
  padding: 1.2rem 1.4rem;
}
.ficha-contenido-wrap.collapsed { max-height: 320px; }
.ficha-contenido-fade {
  display: none;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 90px;
  background: linear-gradient(to bottom, transparent, var(--bg-hover));
  pointer-events: none;
}
.ficha-contenido-wrap.collapsed .ficha-contenido-fade { display: block; }
.ficha-contenido-toggle {
  margin-top: 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ficha-contenido-toggle:hover { opacity: 0.85; }

/* Markdown body styling */
.markdown-body { font-size: 0.9rem; line-height: 1.65; color: var(--text); }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4 { margin: 1.2rem 0 0.6rem; line-height: 1.3; font-weight: 700; }
.markdown-body h1 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.markdown-body h2 { font-size: 1.18rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
.markdown-body h3 { font-size: 1.02rem; }
.markdown-body h4 { font-size: 0.92rem; color: var(--text-muted); }
.markdown-body p { margin: 0.6rem 0; }
.markdown-body ul, .markdown-body ol { margin: 0.6rem 0; padding-left: 1.5rem; }
.markdown-body li { margin: 0.25rem 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body code {
  background: var(--bg);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.85em;
}
.markdown-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 0.8rem 0;
}
.markdown-body pre code { background: none; padding: 0; font-size: 0.82rem; }
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.8rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  color: var(--text-muted);
}
.markdown-body table { border-collapse: collapse; width: 100%; margin: 0.8rem 0; font-size: 0.85rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 0.4rem 0.7rem; text-align: left; }
.markdown-body th { background: var(--bg); font-weight: 600; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 6px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* Actions */
.ficha-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 1.5rem;
}

.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.page-btn:hover { background: var(--bg-hover); }
.page-btn.active { background: var(--accent); color: white; }
.page-btn.disabled { opacity: 0.3; pointer-events: none; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-icon { width: 48px; height: 48px; margin: 0 auto 1rem; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.3rem; color: var(--text-secondary); }
.empty-state p { font-size: 0.85rem; }

/* FORM */
.form-card { max-width: 700px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0.8rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.form-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* FILE INPUT */
.file-input {
  font-size: 0.8rem;
  max-width: 200px;
}