/* =========================================================
   ANDES · components.css
   Botones, tarjetas, formularios, carrusel, modal, tabla...
   ========================================================= */

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent; transition: background-color .2s, border-color .2s, color .2s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { border-color: var(--border-strong); background: transparent; color: var(--text); }
.btn-outline:hover { border-color: var(--text); }
.btn-light { background: #fff; color: #000; }
.btn-light:hover { background: #e9e9e9; }
.btn-ghost-light { border-color: rgba(255,255,255,.4); color: #fff; }
.btn-ghost-light:hover { border-color: #fff; }
.btn-sm { height: 38px; padding: 0 16px; font-size: .86rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  transition: border-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--text); }

.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .92rem; color: var(--accent-text); }
.link-arrow:hover { gap: 10px; }
.link-arrow { transition: gap .2s; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; transition: border-color .2s;
}
.card:hover { border-color: var(--border-strong); }
.card-icon {
  width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--accent-text);
}
.card-icon svg { width: 22px; height: 22px; }
.card h3 { font-size: 1.35rem; }
.card-num { font-family: var(--font-head); font-size: .9rem; color: var(--muted); letter-spacing: .1em; margin-bottom: 14px; display: block; }

/* Tarjeta con imagen */
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-card .media { aspect-ratio: 16 / 10; position: relative; background: var(--surface-2); overflow: hidden; }
.media-card .media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.media-card:hover .media img { transform: scale(1.03); }
.media-card .body { padding: 24px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.media-card .body .link-arrow { margin-top: auto; padding-top: 8px; }

.mini-card {
  display: flex; align-items: center; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-weight: 500; font-size: .94rem;
}
.mini-card svg { color: var(--accent-text); width: 20px; height: 20px; }

/* ---------- Chips y etiquetas ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: .88rem; color: var(--text-soft);
}
.chip svg { color: var(--muted); }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: .74rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  background: color-mix(in srgb, var(--c, var(--accent-text)) 14%, transparent); color: var(--c, var(--accent-text));
}

.note { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--muted); margin-top: 20px; }
.note svg { margin-top: 3px; }

.check-list { display: grid; gap: 10px; margin: 16px 0; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-soft); font-size: .95rem; }
.check-list li::before {
  content: ""; flex-shrink: 0; width: 16px; height: 16px; margin-top: 4px; border-radius: 3px;
  background: var(--accent-soft);
  -webkit-mask: none;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* ---------- Medios pendientes (imagen / video no encontrados) ---------- */
.media-empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px;
  text-align: center; padding: 16px; color: var(--muted);
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(127,127,127,.06) 12px 13px),
    var(--surface-2);
}
.media-empty svg { width: 28px; height: 28px; }
.media-empty b { font-size: .86rem; color: var(--text-soft); font-weight: 600; }
.media-empty code { font-size: .74rem; background: var(--bg); border: 1px solid var(--border); padding: 3px 8px; border-radius: 4px; word-break: break-all; }
.media-empty.is-logo { position: static; width: 100%; height: 100%; padding: 0; background: none; }
.media-empty.is-logo svg { width: 22px; height: 22px; }

.video-box { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.video-box video, .video-box iframe { width: 100%; height: 100%; object-fit: cover; border: 0; }

/* ---------- Carrusel ---------- */
.carousel { position: relative; overflow: hidden; background: #000; }
.carousel:focus-visible { outline-offset: -2px; }
.carousel-track { display: flex; height: 100%; transition: transform .7s cubic-bezier(.65, 0, .35, 1); will-change: transform; }
.slide { position: relative; flex: 0 0 100%; min-width: 100%; height: 100%; overflow: hidden; }
.slide-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slide .media-empty { background-color: #111; color: #9a9a9a; }
.slide .media-empty b { color: #d0d0d0; }
.slide .media-empty code { background: #000; border-color: #2a2a2a; color: #bbb; }

.carousel-controls {
  position: absolute; z-index: 3; display: flex; align-items: center; gap: 16px;
}
.carousel-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-sm);
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.25); color: #fff;
  transition: background-color .2s, border-color .2s;
}
.carousel-btn:hover { background: rgba(0,0,0,.8); border-color: #fff; }
.carousel-dots { display: flex; gap: 6px; }
.carousel-dot {
  position: relative; width: 36px; height: 3px; background: rgba(255,255,255,.3); border-radius: 2px; overflow: hidden;
  padding: 0;
}
.carousel-dot::before { content: ""; position: absolute; inset: -10px 0; } /* área táctil */
.carousel-dot span { position: absolute; inset: 0; width: 0; background: #fff; }
.carousel-dot[aria-current="true"] span { width: 100%; }
.carousel.is-playing .carousel-dot[aria-current="true"] span { width: 0; animation: dotProgress var(--interval, 6000ms) linear forwards; }
@keyframes dotProgress { to { width: 100%; } }
.carousel-counter { font-family: var(--font-head); font-size: .95rem; letter-spacing: .1em; color: #fff; min-width: 64px; }
.carousel-counter b { color: #fff; }
.carousel-counter span { color: rgba(255,255,255,.55); }

.carousel-arrows { display: flex; gap: 8px; }

/* Variante: galería (controles abajo, fuera de la imagen) */
.gallery .carousel-dots { display: none; }
.gallery-top .carousel-controls { top: 16px; bottom: auto; }
.gallery { border-radius: var(--radius); }
.gallery .carousel-viewport { aspect-ratio: 16 / 9; }
.gallery .carousel-controls { right: 16px; bottom: 16px; }
.gallery .slide-caption-sm {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 48px 20px 18px;
  background: linear-gradient(to top, rgba(0,0,0,.75), transparent);
  color: #fff; font-size: .95rem; font-weight: 500; padding-right: 220px;
}
.carousel-viewport { position: relative; overflow: hidden; }

.carousel-thumbs { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(110px, 1fr); gap: 10px; margin-top: 12px; overflow-x: auto; padding-bottom: 4px; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden;
  border: 2px solid transparent; background: var(--surface-2); opacity: .55; transition: opacity .2s, border-color .2s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { opacity: .85; }
.thumb[aria-current="true"] { opacity: 1; border-color: var(--accent); }
.thumb .thumb-icon { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.thumb .thumb-label { position: absolute; left: 6px; bottom: 4px; font-size: .68rem; font-weight: 600; color: var(--text-soft); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 32px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 20px; white-space: nowrap;
  font-weight: 600; font-size: .95rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; font-size: .86rem; font-weight: 600; color: var(--text-soft); }
.input, .select {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  font: inherit; font-weight: 400; font-size: .95rem; transition: border-color .2s;
}
.input:focus, .select:focus { outline: none; border-color: var(--text); }
.input.invalid, .select.invalid { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 500; color: var(--text-soft); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-msg { font-size: .88rem; min-height: 1.3em; }
.form-msg.ok { color: var(--success); }
.form-msg.err { color: var(--danger); }

/* ---------- Progreso ---------- */
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .8s ease; }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; min-width: 660px; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--surface-2); }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]::after { content: " ↕"; opacity: .4; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .empty { text-align: center; padding: 40px; color: var(--muted); }

/* ---------- Segmented control / buscador ---------- */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.segmented button { padding: 9px 16px; font-size: .88rem; font-weight: 600; color: var(--muted); border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--text); color: var(--bg); }
.search-box { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.search-box input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; min-width: 200px; }

/* ---------- Acordeón ---------- */
.accordion { border-top: 1px solid var(--border); }
.acc-item { border-bottom: 1px solid var(--border); }
.acc-q { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 0; text-align: left; font-weight: 600; font-size: 1rem; }
.acc-q svg { transition: transform .3s; color: var(--muted); }
.acc-item.open .acc-q svg { transform: rotate(45deg); color: var(--accent-text); }
.acc-a { max-height: 0; overflow: hidden; transition: max-height .35s ease; }
.acc-a p { padding-bottom: 20px; }

/* ---------- Timeline ---------- */
.timeline { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); }
.tl-item { padding: 28px 24px 0 0; position: relative; }
.tl-item::before { content: ""; position: absolute; top: -5px; left: 0; width: 9px; height: 9px; background: var(--accent); border-radius: 50%; }
.tl-item .card-num { margin-bottom: 8px; }

/* ---------- Logos ---------- */
.logos { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.logo-cell {
  height: 120px; display: grid; place-items: center; padding: 24px; position: relative;
  border-right: 1px solid var(--border); background: var(--surface);
}
.logo-cell:last-child { border-right: 0; }
.logo-cell img { max-height: 64px; max-width: 100%; object-fit: contain; filter: grayscale(1); opacity: .8; transition: filter .2s, opacity .2s; }
.logo-cell:hover img { filter: none; opacity: 1; }
.logo-cell .media-empty { font-size: .78rem; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; visibility: hidden; opacity: 0; transition: opacity .2s, visibility .2s; }
.modal.open { visibility: visible; opacity: 1; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.modal-box {
  position: relative; width: min(520px, 100%); max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 32px;
}
.modal-close { position: absolute; top: 16px; right: 16px; }
.steps { display: flex; gap: 6px; margin-bottom: 24px; }
.steps span { flex: 1; height: 3px; border-radius: 2px; background: var(--border-strong); transition: background-color .3s; }
.steps span.on { background: var(--accent); }
.step-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; display: block; }
.step { display: none; gap: 16px; }
.step.active { display: grid; }
.modal-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.reg-success { display: grid; gap: 10px; justify-items: center; text-align: center; }
.reg-success .ok-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.reg-success .ok-icon svg { width: 28px; height: 28px; }
.mission-code { font-family: var(--font-head); font-size: 2rem; font-weight: 700; letter-spacing: .12em; padding: 8px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

/* ---------- Toast / volver arriba ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 120; transform: translate(-50%, 16px);
  padding: 12px 18px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg);
  font-size: .9rem; font-weight: 500; max-width: calc(100% - 32px);
  opacity: 0; visibility: hidden; transition: transform .3s, opacity .3s, visibility .3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.to-top { position: fixed; right: 20px; bottom: 20px; z-index: 40; opacity: 0; pointer-events: none; transition: opacity .3s; }
.to-top.show { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .timeline { grid-template-columns: 1fr 1fr; row-gap: 32px; }
  .logos { grid-template-columns: repeat(3, 1fr); }
  .logo-cell { border-bottom: 1px solid var(--border); }
  .gallery .slide-caption-sm { padding-right: 20px; padding-bottom: 72px; }
}
@media (max-width: 540px) {
  .timeline { grid-template-columns: 1fr; }
  .logos { grid-template-columns: 1fr 1fr; }
  .carousel-btn { width: 38px; height: 38px; }
  .carousel-dot { width: 22px; }
  .search-box input { min-width: 0; width: 100%; }
  .modal-box { padding: 24px; }
}

/* Controles segmentados con enlaces */
.segmented a { padding: 9px 16px; font-size: .88rem; font-weight: 600; color: var(--muted); border-right: 1px solid var(--border); }
.segmented a:last-child { border-right: 0; }
.segmented a.active { background: var(--text); color: var(--bg); }
