/* Piezas que se usan en todas partes: tarjetas, etiquetas, ventanas, avisos, tutorial, buscador */

/* ================================================================ piezas */
.avatar {
  --av: #6366f1;
  position: relative; flex-shrink: 0;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--av); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.avatar.on-light { color: #0b0b10; }
/* Con texto blanco, el fondo un poco más oscuro para que las iniciales se lean bien (contraste AA) */
.avatar[data-uid]:not(.on-light):not(.has-photo) { background: color-mix(in srgb, var(--av) 88%, #000); }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar .online-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #22c55e; border: 2px solid var(--surface);
}
.avatar.sm .online-dot { width: 9px; height: 9px; }
.avatar-group { background: var(--accent-soft); color: var(--accent); }
.avatar-term { background: var(--surface-3); color: var(--text-2); }
.avatar-group .icon, .avatar-term .icon { width: 17px; }

.badge {
  --c: #64748b;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 99px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 85%, var(--text));
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.badge-ceo { background: linear-gradient(135deg, #f8d66d, #d4a017); color: #3d2b00; }
.badge-ceo .icon { width: 13px; height: 13px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; margin-left: 4px; border-radius: 6px;
  background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 80%, var(--text));
  font-size: 11px; font-weight: 650; vertical-align: 1px;
}
.tag .icon { width: 12px; height: 12px; }
.tag-admin { background: color-mix(in srgb, #d4a017 18%, transparent); color: #7a5d00; }

.chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2); font-size: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.card-head h3 .icon { color: var(--accent); }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 99px; background: #dcfce7; color: #15803d; font-size: 12px; font-weight: 700;
}

.empty {
  display: grid; justify-items: center; gap: 6px;
  padding: 28px 16px; text-align: center; color: var(--muted);
}
.empty .icon { width: 28px; height: 28px; opacity: .6; margin-bottom: 4px; }
.empty strong { color: var(--text-2); font-weight: 600; }
.empty span { font-size: 13px; }

.skeleton-list { display: grid; gap: 10px; }
.skeleton-list i {
  height: 46px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.due {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.due .icon { width: 13px; height: 13px; }
.due-late { background: var(--danger-soft); color: var(--danger-text); }
.due-soon { background: color-mix(in srgb, #f97316 15%, transparent); color: #c2410c; }
.due-near { background: color-mix(in srgb, #eab308 18%, transparent); color: #a16207; }
.due-far { background: color-mix(in srgb, #22c55e 15%, transparent); color: #15803d; }
.due-none { background: var(--surface-3); color: var(--muted); }
a.due-none:hover { color: var(--accent); }

/* ================================================================ modales y toasts */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 24, .5); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh / var(--zoom, 1) - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.98); transition: transform .18s;
}
.modal-backdrop.open .modal { transform: none; }
.modal.sm { max-width: 420px; }
.modal.lg { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.modal-head h2 { font-size: 18px; overflow-wrap: anywhere; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--border); }
.confirm-text { color: var(--text-2); }

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: #1c1e2b; color: #fff; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: toast-in .2s ease;
}
.toast .icon { width: 16px; flex-shrink: 0; }
.toast-success .icon { color: #4ade80; }
.toast-error .icon { color: #f87171; }
.toast-info .icon { color: #a5a5ff; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ================================================================ popups */
#popups { position: fixed; top: 76px; right: 20px; z-index: 310; display: grid; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.popup {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 10px 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lg); animation: popup-in .25s ease;
}
.popup-icon { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.popup-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.popup-text strong { font-size: 13.5px; }
.popup-text span { font-size: 12.5px; line-height: 1.4; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.popup.leaving { opacity: 0; transform: translateX(16px); transition: .25s; }
@keyframes popup-in { from { opacity: 0; transform: translateX(24px); } }

/* ================================================================ resumen al volver */
.recap { display: grid; gap: 18px; }
.recap-intro { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.recap-intro .icon { color: var(--accent); }
.recap-section { display: grid; gap: 10px; }
.recap-section h3 { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.recap-section h3 .icon { color: var(--accent); }
.recap-source { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.recap-source .icon { width: 13px; height: 13px; }
.recap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.recap-chips .chip:hover { background: var(--accent-soft); color: var(--accent); }
.recap-summary { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 8px; }
.recap-summary ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.recap-summary li::marker { color: var(--accent); }
.recap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recap-list li { display: flex; align-items: stretch; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.recap-list li div { display: grid; min-width: 0; }

/* ================================================================ fotos de perfil */
.avatar.has-photo { background: var(--surface-3); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.xl { width: 84px; height: 84px; font-size: 28px; }
.member-bio { font-size: 12.5px; color: var(--text-2); font-style: italic; margin-top: 2px; overflow-wrap: anywhere; }
.profile-row { display: flex; align-items: center; gap: 18px; }
.profile-photo-actions { display: grid; gap: 6px; justify-items: start; }
.counter { justify-self: end; font-size: 11.5px; }
.zoom-select { width: auto !important; min-width: 190px; }

/* ================================================================ piezas comunes (v4) */
.avatar.xs { width: 18px; height: 18px; font-size: 8px; }
.avatar.xs .online-dot { display: none; }
.modal.xl { max-width: min(1100px, 94vw); }
.tag-danger { background: var(--danger-soft); color: var(--danger-text); }
.progress { display: inline-block; width: 90px; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width .3s; }
.task-ref { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 550; }
.back-link:hover { color: var(--accent); }
.back-link .icon { width: 15px; height: 15px; }
.hint code, .board-hint code, .task-commits code, .setting-note code { padding: 1px 5px; border-radius: 5px; background: var(--surface-3); font-family: var(--mono); font-size: 12px; }
.status-seg button { display: inline-flex; align-items: center; gap: 6px; }
.status-seg .icon { width: 14px; height: 14px; }
.status-seg .status-todo.active .icon { color: var(--muted); }
.status-seg .status-doing.active .icon { color: #0b84f3; }
.status-seg .status-done.active .icon { color: var(--success); }
.status-text.status-doing { color: #0b84f3; font-weight: 600; }

/* ================================================================ comentarios, avisos y alertas */
.task-comments { display: grid; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.task-comments h4 { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.task-comments h4 .icon { width: 15px; height: 15px; color: var(--accent); }
.comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 280px; overflow-y: auto; }
.comment-list > li { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 4px 12px 12px 12px; background: var(--surface-3); }
.comment-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.comment-meta .icon-btn { margin-left: auto; width: 24px; height: 24px; }
.comment-body p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; resize: vertical; min-height: 40px; }
.late-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; background: var(--danger-soft); color: var(--danger-text); font-size: 11.5px; font-weight: 650; }
.late-badge .icon { width: 12px; height: 12px; }
.my-task.is-late .my-task-main strong { color: var(--danger-text); }
.server-alerts { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.server-alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 9px; background: var(--danger-soft); color: var(--danger-text); }
.server-alerts .icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.server-alerts div { display: grid; }
.server-alerts span { font-size: 12px; color: var(--text-2); }
#popups .popup { cursor: default; }

/* ================================================================ tutorial */
.tour { position: fixed; inset: 0; z-index: 200; display: grid; place-items: end center; padding: 24px 16px; background: rgba(10, 12, 20, .28); opacity: 0; transition: opacity .25s; }
.tour.open { opacity: 1; }
.tour-card { width: min(420px, 100%); padding: 24px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); display: grid; gap: 10px; justify-items: start; animation: rise .35s cubic-bezier(.2, .9, .3, 1) both; }
.tour-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.tour-icon .icon { width: 24px; height: 24px; }
.tour-card h3 { font-size: 19px; }
.tour-card p { color: var(--text-2); line-height: 1.55; }
.tour-dots { display: flex; gap: 5px; margin-top: 4px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 99px; background: var(--border-strong); transition: width .25s, background .25s; }
.tour-dots i.on { width: 20px; background: var(--accent); }
.tour-actions { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 6px; }
.tour-actions .btn .icon { width: 15px; height: 15px; }
.tour-highlight { position: relative; z-index: 201; box-shadow: 0 0 0 3px var(--accent), 0 0 0 8px color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; animation: halo 1.6s ease-in-out infinite; }
@keyframes halo { 50% { box-shadow: 0 0 0 3px var(--accent), 0 0 0 12px color-mix(in srgb, var(--accent) 12%, transparent); } }

.tag-ok { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }

/* --- buscador (Ctrl+K) */
.search-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; justify-items: center; align-items: start; padding: 10vh 16px 16px;
  background: rgba(10, 12, 24, .45); opacity: 0; transition: opacity .15s;
}
.search-backdrop.open { opacity: 1; }
.search-box {
  width: min(640px, 100%); max-height: min(70vh, 640px); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg);
  transform: translateY(-8px) scale(.98); transition: transform .15s;
}
.search-backdrop.open .search-box { transform: none; }
.search-input { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-input > .icon { width: 19px; height: 19px; color: var(--muted); flex: none; }
.search-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 16px; }
.search-input input::-webkit-search-cancel-button { display: none; }
.search-results { overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.sr-group { padding: 10px 10px 4px; color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.sr-item {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 9px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.sr-item.active { background: var(--accent-soft); }
.sr-icon { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.sr-icon .icon { width: 16px; height: 16px; }
.sr-icon:has(.avatar) { background: none; }
.sr-dot { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.sr-folder { background: none; color: var(--fc); }
.sr-folder .icon { width: 22px; height: 22px; }
.sr-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sr-main strong { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-main small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-main small.sr-body { color: var(--text-2); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-item mark { background: color-mix(in srgb, #facc15 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.sr-go { flex: none; opacity: 0; }
.sr-item.active .sr-go { opacity: 1; }
.search-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px 12px; }
.search-empty .icon { width: 16px; height: 16px; }
.search-foot { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.search-foot kbd { margin-right: 3px; }

.tag .icon { width: 12px; height: 12px; vertical-align: -2px; margin-right: 3px; }

.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 88px; height: 88px; font-size: 30px; }
.avatar.xl .online-dot { width: 18px; height: 18px; border-width: 3px; right: 2px; bottom: 2px; }
.avatar[data-uid] { cursor: pointer; }
:is(button, a, label, .assignee-chip, .chat-item) .avatar[data-uid] { cursor: inherit; }

/* Número de versión (barra de arriba e inicio de sesión); en la copia de pruebas, bien visible en naranja */
.version-tag {
  display: inline-flex; align-items: center; flex: none; height: 20px; padding: 0 7px; border: 1px solid var(--border);
  border-radius: 99px; color: var(--muted); font: 650 11px var(--mono); letter-spacing: .02em; white-space: nowrap; vertical-align: middle;
}
.version-tag.is-dev { border-color: color-mix(in srgb, var(--warning) 55%, transparent); background: color-mix(in srgb, var(--warning) 14%, transparent); color: #8a4600; }
:root[data-theme="dark"] .version-tag.is-dev { color: #fbbf24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .version-tag.is-dev { color: #fbbf24; } }
