/*
 * Hoja de estilos estática de Links Adjuntos.
 *
 * El color de marca vive en una variable que se conmuta con el atributo
 * data-brand del <html>: Farmavalue por defecto, Farmacias del Ahorro en HN.
 */

:root {
  --brand: #b70000;
  --brand-soft: #fdeaea;
  --texto: #1e293b;
  --texto-suave: #64748b;
  --texto-tenue: #94a3b8;
  --linea: #e2e8f0;
  --linea-clara: #f1f5f9;
  --superficie: #f8fafc;
  --radio: 12px;
}

[data-brand="fa"] {
  --brand: #00b041;
  --brand-soft: #e6f8ee;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #e2e8f0;
  color: var(--texto);
  font-family: "Montserrat", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0 auto;
  max-width: 480px;
  background: #fff;
  box-shadow: 0 12px 40px rgb(15 23 42 / 0.16);
}

/* Encabezado y marca */

.site-header {
  padding: 14px 16px;
  background: var(--brand);
  text-align: center;
}

.site-header h1 {
  margin: 0;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand-strip {
  padding: 16px 24px;
  border-bottom: 1px solid var(--linea);
  background: #fff;
  text-align: center;
}

.brand-strip img {
  display: block;
  margin: 0 auto;
  height: 44px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.app-shell {
  flex: 1;
  padding: 20px 16px;
}

/* Paneles de estado */

.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 64px 8px;
  text-align: center;
}

.state-panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

.state-panel p {
  margin: 0;
  max-width: 20rem;
  font-size: 12px;
  color: var(--texto-suave);
}

.state-panel img {
  height: 64px;
  width: 64px;
  object-fit: contain;
}

.state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: 48px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 24px;
  font-weight: 700;
}

.state-icon--quiet {
  background: var(--linea-clara);
  color: var(--texto-tenue);
}

/* Estado del enlace */

.link-intro {
  margin-bottom: 20px;
  text-align: center;
}

.link-intro h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.link-id {
  display: block;
  margin-top: 2px;
  font-family: inherit;
  font-size: 12px;
  font-style: italic;
  font-weight: 600;
  color: var(--texto-suave);
  word-break: break-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
}

.badge::before {
  content: "";
  height: 6px;
  width: 6px;
  border-radius: 50%;
  background: var(--brand);
}

/* Barras de sección y filas de detalle */

.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--linea-clara);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}

.section-bar span {
  color: var(--texto-suave);
  font-weight: 500;
}

.detail-list {
  margin: 0 0 20px;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border-bottom: 1px solid var(--linea-clara);
  font-size: 14px;
}

.detail-row dt {
  font-weight: 600;
  color: #334155;
}

.detail-row dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

.detail-row dd.plain {
  font-weight: 400;
  color: var(--texto-suave);
}

/* Galería de adjuntos */

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 20px;
}

.tile {
  position: relative;
  display: block;
  padding: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 0;
  border-radius: var(--radio);
  background: var(--superficie);
  box-shadow: inset 0 0 0 1px var(--linea);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--brand), 0 6px 16px rgb(15 23 42 / 0.12);
  outline: none;
}

.tile:active {
  transform: scale(0.98);
}

.tile img {
  height: 100%;
  width: 100%;
  object-fit: cover;
}

.tile-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 8px 6px;
  background: linear-gradient(to top, rgb(15 23 42 / 0.78), transparent);
  color: #fff;
  text-align: left;
}

.tile-caption strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-caption span {
  display: block;
  font-size: 9px;
  opacity: 0.85;
}

/* Mosaico de PDF o archivo sin vista previa */

.tile-file {
  display: flex;
  height: 100%;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--brand-soft);
  color: var(--brand);
}

.tile-file svg {
  height: 26px;
  width: 26px;
}

.tile-file b {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 36px 16px;
  text-align: center;
}

.empty-state h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

.empty-state p {
  margin: 0;
  max-width: 20rem;
  font-size: 12px;
  color: var(--texto-suave);
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 44px;
  border-radius: 50%;
  background: var(--linea-clara);
  color: var(--texto-tenue);
}

.empty-icon svg {
  height: 20px;
  width: 20px;
}

/* Carga de archivos */

.upload-panel {
  padding: 16px 12px;
}

.file-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  border: 2px dashed var(--linea);
  border-radius: var(--radio);
  color: var(--texto-suave);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.file-picker:focus-within {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.file-picker:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.file-picker svg {
  height: 20px;
  width: 20px;
}

.file-picker input {
  position: absolute;
  height: 1px;
  width: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.file-hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--texto-tenue);
}

.selected-file {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radio);
  background: var(--superficie);
  box-shadow: inset 0 0 0 1px var(--linea);
}

.file-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  width: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--linea);
  color: var(--brand);
}

.file-type-icon svg {
  height: 20px;
  width: 20px;
}

.selected-file-info {
  min-width: 0;
  flex: 1;
}

.selected-file-info strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-info span {
  font-size: 11px;
  color: var(--texto-suave);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.button:hover:not(:disabled) {
  opacity: 0.9;
}

.button:active:not(:disabled) {
  transform: scale(0.99);
}

.button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.button--full {
  width: 100%;
  margin-top: 12px;
  padding: 13px 20px;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  width: 28px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--texto-tenue);
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  background: var(--linea);
  color: #334155;
}

.upload-status {
  margin: 8px 0 0;
  min-height: 1rem;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--texto-suave);
}

.upload-status.is-error {
  color: #dc2626;
}

/* Pie */

.site-footer {
  padding: 16px;
  border-top: 1px solid var(--linea);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 11px;
  color: var(--texto-tenue);
}

/* Vista previa */

.preview-dialog {
  width: 92vw;
  max-width: 32rem;
  padding: 0;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
}

.preview-dialog::backdrop {
  background: rgb(15 23 42 / 0.6);
}

.preview-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--brand);
}

.preview-dialog-bar h2 {
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-dialog-bar .icon-button {
  color: #fff;
  font-size: 20px;
}

.preview-dialog-bar .icon-button:hover {
  background: rgb(255 255 255 / 0.2);
  color: #fff;
}

.preview-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 75vh;
  padding: 12px;
  overflow: auto;
  background: var(--superficie);
}

.preview-content img {
  max-height: 70vh;
  max-width: 100%;
  width: auto;
  border-radius: 10px;
  object-fit: contain;
}

.preview-content iframe {
  height: 70vh;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: #fff;
}

@media (max-width: 360px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

/*
 * Preferencia de movimiento reducido.
 *
 * Además de neutralizar transiciones y animaciones, se anulan los
 * desplazamientos y escalados de mosaicos y botones: con la transición
 * desactivada seguirían aplicándose, sólo que de golpe, que es justamente
 * lo que esta preferencia busca evitar. El realce de hover y foco se
 * mantiene por color y sombra, así que no se pierde el indicador visual.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .tile,
  .tile:hover,
  .tile:focus-visible,
  .tile:active,
  .button:active:not(:disabled) {
    transform: none;
  }
}
