/* ============================================================
   Extras versión PHP — flash, enlaces-botón, toggles
============================================================ */

a.nav-item, a.btn, a.icon-btn { text-decoration: none; }
a.btn { display: inline-flex; align-items: center; gap: 6px; }
a.icon-btn { display: inline-flex; align-items: center; justify-content: center; }

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 14px;
  font-size: 13.5px; font-weight: 500; border: 1px solid;
}
.flash-ok    { color: var(--ok);     background: color-mix(in oklab, var(--ok) 10%, var(--bg-elev));     border-color: color-mix(in oklab, var(--ok) 35%, var(--border)); }
.flash-error { color: var(--danger); background: color-mix(in oklab, var(--danger) 10%, var(--bg-elev)); border-color: color-mix(in oklab, var(--danger) 35%, var(--border)); }
.flash-close {
  margin-left: auto; background: transparent; border: none; cursor: pointer;
  color: inherit; opacity: .6; display: inline-flex; padding: 2px;
}
.flash-close:hover { opacity: 1; }

/* Toggle de tema: mostrar el icono correcto según data-theme */
.theme-dark  { display: none; }
.theme-light { display: inline-flex; }
[data-theme="dark"] .theme-dark  { display: inline-flex; }
[data-theme="dark"] .theme-light { display: none; }
.theme-light, .theme-dark { align-items: center; }

/* Resultados del buscador de clientes (Nueva incidencia) */
.client-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-top: 4px; z-index: 5;
  box-shadow: 0 8px 24px rgba(15,25,50,0.12);
  max-height: 280px; overflow-y: auto;
}
.client-results button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; background: transparent; border: none;
  border-bottom: 1px solid var(--border-soft); cursor: pointer; color: var(--text);
}
.client-results button:hover { background: var(--bg-sunk); }

/* Acciones en tablas admin */
.adm-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.adm-table .row-actions form { margin: 0; }

/* Errores de validación bajo los campos */
.field .err { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ============================================================
   Página móvil independiente (movil.php)
============================================================ */
.movil-body {
  margin: 0; background: var(--bg);
  font-family: var(--font-sans); color: var(--text);
}
.movil-shell {
  max-width: 520px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  background: var(--surface);
  display: flex; flex-direction: column;
}
.movil-shell .fo {
  flex: 1; height: auto; min-height: 100vh; min-height: 100dvh;
  padding-top: max(14px, env(safe-area-inset-top));
}
.movil-shell .fo-footer { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
@media (min-width: 560px) {
  .movil-body { padding: 24px 0; }
  .movil-shell, .movil-shell .fo { min-height: calc(100vh - 48px); }
  .movil-shell { border: 1px solid var(--border); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow-lg); }
}

/* ============================================================
   Desplegables de estado / prioridad en el detalle
============================================================ */
.dd { position: relative; display: inline-flex; }
.dd-toggle {
  background: none; border: none; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-muted); font: inherit;
}
.dd-toggle .caret { display: inline-flex; opacity: .55; transition: transform .15s; }
.dd.open .dd-toggle .caret { transform: rotate(180deg); }
.dd-toggle:hover .caret { opacity: 1; }
.dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 200px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 60; padding: 6px;
  display: none;
}
.dd.open .dd-menu { display: block; }
.dd-menu form { margin: 0; }
.dd-head {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 6px 10px 8px;
}
.dd-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: none; background: transparent; border-radius: 8px;
  cursor: pointer; font-size: 13px; color: var(--text); text-align: left;
  font-family: var(--font-sans);
}
.dd-item:hover { background: var(--bg-sunk); }
.dd-item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dd-item.current { font-weight: 600; }
.dd-item.current::after { content: "✓"; margin-left: auto; color: var(--brand); }

/* ============================================================
   Notificaciones clicables
============================================================ */
.notif-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px; border-radius: 8px; font-size: 13px;
  border-top: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.notif-item:hover { background: var(--bg-sunk); }
.notif-item .notif-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: transparent; margin-top: 6px; flex-shrink: 0;
}
.notif-item.unread .notif-dot { background: var(--brand); }
.notif-item.unread { font-weight: 500; }
.notif-item .notif-go { color: var(--text-faint); margin-top: 3px; }
.notif-item:hover .notif-go { color: var(--brand); }

/* ============================================================
   Menciones @usuario
============================================================ */
.mention {
  color: var(--brand-700); background: var(--brand-50);
  border-radius: 4px; padding: 0 3px; font-weight: 600;
}
[data-theme="dark"] .mention { color: #86B6F5; background: rgba(28,100,208,0.22); }

.composer { position: relative; }

/* Textarea con resaltado en vivo: backdrop espejo detrás del texto */
.ta-wrap { position: relative; }
.composer .ta-wrap textarea,
.ta-backdrop {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  padding: 4px 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.ta-backdrop {
  position: absolute; inset: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
}
.composer .ta-wrap textarea { position: relative; background: transparent; z-index: 1; }
.ta-backdrop .hl {
  background: var(--brand-100);
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--brand-200);
}
[data-theme="dark"] .ta-backdrop .hl {
  background: rgba(28,100,208,0.35);
  box-shadow: 0 0 0 1px rgba(28,100,208,0.5);
}

/* Panel de sugerencias: SIEMPRE debajo del texto (top lo fija el JS) */
.mention-box {
  position: absolute; left: 12px; right: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 70;
  padding: 5px; max-height: 230px; overflow-y: auto;
}
.mention-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 10px;
  border: none; background: transparent; border-radius: 8px;
  cursor: pointer; font-size: 13px; color: var(--text); text-align: left;
  font-family: var(--font-sans);
}
.mention-item:hover, .mention-item.active { background: var(--bg-sunk); }
.mention-item.active { outline: 1px solid var(--brand-200); }
.mention-item .mu { color: var(--text-muted); font-size: 11.5px; font-family: var(--font-mono); margin-left: 4px; }
.mention-hint {
  padding: 5px 10px 4px; font-size: 10.5px; color: var(--text-faint);
  border-top: 1px solid var(--border); margin-top: 4px;
}

/* ============================================================
   Adjuntos en los mensajes del hilo
============================================================ */
.msg-atts {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 8px;
}
.att-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-elev);
  font-size: 12.5px; color: var(--text); text-decoration: none;
  max-width: 100%;
}
.att-chip[href]:hover { border-color: var(--brand-200); background: var(--brand-50); color: var(--brand-700); }
.att-chip .att-name {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 220px;
}
.att-chip .att-size { color: var(--text-faint); font-size: 11px; }
.att-img-link { display: inline-block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); line-height: 0; }
.att-img {
  max-height: 150px; max-width: 220px;
  display: block; object-fit: cover;
}
.att-img-link:hover { border-color: var(--brand-200); box-shadow: var(--shadow); }
