/* Ajustes y perfil.
   Prefijo aj- para no chocar con styles.css ni con el panel (pa-). */

.aj-overlay {
    position: fixed;
    inset: 0;
    /* Por encima de la barra inferior de la tienda (6000) y del selector de
       restaurante: Ajustes ocupa la pantalla entera y navegar por debajo
       mientras está abierto no lleva a ninguna parte. Solo el panel de
       compras (6100) y su detalle (6200) quedan por encima. */
    z-index: 6300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px 60px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(15, 17, 21, .55);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.aj-caja {
    position: relative;
    width: 100%;
    max-width: 820px;
    padding: 28px 30px 34px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .26);
}

/* Mientras se recarga, el contenido se apaga en vez de saltar a "Cargando":
   la pantalla no se mueve y no se pierde el sitio donde estabas. */
.aj-caja.aj-ocupado { opacity: .55; pointer-events: none; }

.aj-cargando { padding: 50px 0; text-align: center; color: #868e96; font-size: 15px; }
.aj-error { color: #e03131; }

.aj-cabecera {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}
.aj-cabecera h2 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.02em; color: #16181d; }
.aj-sub { margin: 3px 0 0; font-size: 13.5px; color: #6c757d; }

.aj-cerrar {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border: 0; border-radius: 50%;
    background: #f1f3f5; color: #495057;
    font-size: 22px; line-height: 1; cursor: pointer;
}
.aj-cerrar:hover { background: #e9ecef; }

/* ── Secciones ───────────────────────────────────────────────────────── */
.aj-seccion { padding: 20px 0; border-top: 1px solid #f1f3f5; }
.aj-seccion:first-of-type { border-top: 0; padding-top: 0; }
.aj-seccion h3 { margin: 0 0 4px; font-size: 16px; font-weight: 650; color: #16181d; }
.aj-ayuda { margin: 0 0 14px; font-size: 13px; color: #868e96; line-height: 1.45; }

/* ── Rejilla de restaurantes ─────────────────────────────────────────── */
.aj-rejilla {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
    gap: 12px;
}

.aj-tarjeta {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    background: #fff;
    text-align: left;
    font: inherit;
}
.aj-tarjeta.es-archivado { opacity: .62; background: #f8f9fa; }

.aj-avatar {
    flex-shrink: 0;
    display: grid; place-items: center;
    width: 46px; height: 46px;
    border-radius: 13px;
    color: #fff;
    font-size: 16px; font-weight: 700; letter-spacing: .02em;
}
.aj-avatar-mini { width: 38px; height: 38px; border-radius: 11px; font-size: 13px; background: #adb5bd; }
.aj-avatar-nuevo { background: #dee2e6 !important; color: #495057; font-size: 24px; font-weight: 400; }

.aj-tarjeta-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.aj-tarjeta-txt strong { font-size: 14.5px; font-weight: 650; color: #16181d; }
.aj-tarjeta-txt small  { font-size: 12px; color: #868e96; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.aj-etiqueta {
    align-self: flex-start;
    margin-top: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f1f3f5;
    color: #868e96;
    font-size: 10.5px; font-weight: 700;
}
.aj-etiqueta.es-activo { background: #eef4ff; color: #2563eb; }
.aj-etiqueta.es-aviso  { background: #fff4e6; color: #d9480f; }

.aj-nuevo { border: 2px dashed #ced4da; cursor: pointer; }
.aj-nuevo:hover { background: #f8f9fa; }

.aj-lapiz {
    position: absolute;
    top: 8px; right: 8px;
    width: 30px; height: 30px;
    border: 0; border-radius: 9px;
    background: transparent;
    color: #adb5bd;
    font-size: 14px; cursor: pointer;
}
.aj-lapiz:hover { background: #f1f3f5; color: #2563eb; }

/* ── Personas ────────────────────────────────────────────────────────── */
.aj-personas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.aj-persona {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 46px 12px 14px;
    border: 1px solid #e9ecef;
    border-radius: 13px;
}
.aj-persona.es-pendiente { background: #fffdf7; border-color: #ffe8cc; }

.aj-persona-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.aj-persona-txt strong { font-size: 14px; font-weight: 650; color: #16181d; }
.aj-persona-txt small  { font-size: 12px; color: #868e96; }
.aj-persona-negocios   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.aj-persona-estado { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }

.aj-rol {
    padding: 2px 9px;
    border-radius: 999px;
    background: #e7f5ff; color: #1971c2;
    font-size: 11px; font-weight: 650;
}

/* ── Formularios ─────────────────────────────────────────────────────── */
.aj-form { display: flex; flex-direction: column; gap: 12px; }

.aj-form label {
    display: block;
    font-size: 12.5px; font-weight: 650; color: #495057;
}
.aj-form label small { font-weight: 400; color: #adb5bd; }

.aj-form input:not([type="checkbox"]),
.aj-form select {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    background: #fff;
    color: #16181d;
    font: inherit;
    font-size: 15px; font-weight: 400;
}
.aj-form input:focus, .aj-form select:focus {
    outline: 2px solid #2563eb; outline-offset: -1px; border-color: transparent;
}
.aj-form input:disabled { background: #f8f9fa; color: #868e96; }

.aj-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.aj-checks, .aj-colores {
    margin: 0; padding: 12px 14px;
    border: 1px solid #e9ecef; border-radius: 12px;
}
.aj-checks legend, .aj-colores legend {
    padding: 0 6px; font-size: 12.5px; font-weight: 650; color: #495057;
}
.aj-checks legend small { font-weight: 400; color: #adb5bd; }

.aj-check { display: flex !important; align-items: center; gap: 9px; padding: 5px 0; font-weight: 400 !important; cursor: pointer; }
.aj-check input { width: auto !important; margin: 0 !important; }
.aj-check span { font-size: 14px; color: #16181d; }

.aj-colores { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.aj-color {
    width: 30px; height: 30px;
    border: 2px solid transparent; border-radius: 9px;
    cursor: pointer;
}
.aj-color.es-activo { border-color: #16181d; box-shadow: 0 0 0 2px #fff inset; }

.aj-error-form { min-height: 18px; margin: 0; color: #e03131; font-size: 13px; }

.aj-acciones { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.aj-btn, .aj-btn-sec, .aj-btn-peligro {
    padding: 10px 18px;
    border: 0; border-radius: 10px;
    cursor: pointer;
    font: inherit; font-size: 14px; font-weight: 650;
}
.aj-btn { background: #2563eb; color: #fff; }
.aj-btn:hover:not(:disabled) { background: #1d4ed8; }
.aj-btn:disabled { opacity: .55; cursor: default; }
.aj-btn-sec { background: #f1f3f5; color: #495057; }
.aj-btn-sec:hover:not(:disabled) { background: #e9ecef; }
.aj-btn-peligro { background: #fff5f5; color: #e03131; }
.aj-btn-peligro:hover:not(:disabled) { background: #ffe3e3; }

.aj-desplegable { margin-top: 16px; }
.aj-desplegable summary {
    padding: 10px 0; cursor: pointer;
    font-size: 14px; font-weight: 650; color: #2563eb;
}
.aj-desplegable[open] summary { margin-bottom: 8px; }

/* ── Interruptor ─────────────────────────────────────────────────────── */
.aj-interruptor {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px; border: 1px solid #e9ecef; border-radius: 13px;
}
.aj-interruptor span { display: flex; flex-direction: column; gap: 2px; }
.aj-interruptor strong { font-size: 14px; font-weight: 650; color: #16181d; }
.aj-interruptor small  { font-size: 12.5px; color: #868e96; }
.aj-interruptor input { width: 20px; height: 20px; flex-shrink: 0; accent-color: #2563eb; }

/* ── Móvil ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .aj-overlay { padding: 0; }
    .aj-caja { max-width: none; min-height: 100vh; border-radius: 0; padding: 20px 16px 40px; }
    .aj-rejilla { grid-template-columns: 1fr; }
    .aj-fila { grid-template-columns: 1fr; }
    .aj-persona { padding-right: 14px; flex-wrap: wrap; }
    .aj-persona-estado { align-items: flex-start; flex-direction: row; flex-wrap: wrap; width: 100%; }
    .aj-lapiz { position: static; align-self: flex-start; }
    .aj-acciones { flex-direction: column-reverse; align-items: stretch; }
    .aj-acciones span { display: none; }
    .aj-acciones button { width: 100%; }
}

/* ── Movimiento ──────────────────────────────────────────────────────── */
/* Mismo criterio que el resto: curvas cortas de salida, escalonado suave y
   todo apagado con prefers-reduced-motion. */
.aj-caja { animation: aj-entra .3s cubic-bezier(.22,.61,.36,1); }
@keyframes aj-entra { from { opacity: 0; transform: translateY(14px) scale(.99) } to { opacity: 1; transform: none } }

.aj-overlay { animation: aj-aparece .18s ease-out; }
@keyframes aj-aparece { from { opacity: 0 } to { opacity: 1 } }

.aj-tarjeta, .aj-persona {
    transition: background-color .16s ease, border-color .16s ease, transform .16s cubic-bezier(.22,.61,.36,1);
}
.aj-tarjeta:not(.aj-nuevo):hover, .aj-persona:hover { border-color: #dee2e6; }
.aj-nuevo:hover { transform: translateY(-2px); }

.aj-caja { transition: opacity .18s ease; }

.aj-btn, .aj-btn-sec, .aj-btn-peligro, .aj-lapiz, .aj-cerrar, .aj-color {
    transition: background-color .14s ease, color .14s ease, border-color .14s ease,
                transform .14s cubic-bezier(.22,.61,.36,1);
}
.aj-btn:hover:not(:disabled), .aj-btn-sec:hover:not(:disabled) { transform: translateY(-1px); }
.aj-btn:active:not(:disabled) { transform: translateY(0); transition-duration: .06s; }
.aj-color:hover { transform: scale(1.08); }

@media (prefers-reduced-motion: reduce) {
    .aj-caja, .aj-overlay { animation-duration: .01ms !important; }
    .aj-nuevo:hover, .aj-color:hover,
    .aj-btn:hover:not(:disabled), .aj-btn-sec:hover:not(:disabled) { transform: none; }
}

/* ── Foto de perfil ──────────────────────────────────────────────────── */
/* Fuera del formulario a propósito: se guarda al elegir el fichero, no con el
   botón "Guardar" de los datos de al lado. */
.aj-foto {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin: 0 0 20px;
    padding: 16px;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    background: #fbfbfc;
}

.aj-foto-marco {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    width: 72px; height: 72px;
    border-radius: 50%;
    background: #e9ecef;
    color: #495057;
    font-size: 24px; font-weight: 700;
    overflow: hidden;
}
.aj-foto-marco img { width: 100%; height: 100%; object-fit: cover; }
/* Mientras sube, la vista previa se atenúa: se ve que aún no está confirmada. */
.aj-foto-marco.es-subiendo { opacity: .5; }

.aj-foto-texto { flex: 1; min-width: 0; }
.aj-foto-texto strong { display: block; font-size: 14.5px; font-weight: 650; color: #16181d; }
.aj-foto-texto small { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: #868e96; }

.aj-foto-botones { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
/* El <label> hace de botón porque el <input type=file> de verdad va oculto:
   su aspecto nativo no se puede estilar y cambia en cada navegador. */
.aj-foto-botones label { cursor: pointer; }

@media (max-width: 560px) {
    .aj-foto { flex-direction: column; align-items: center; text-align: center; }
    .aj-foto-botones { justify-content: center; }
}

/* Acción secundaria escrita como enlace. Se usa para lo que se puede deshacer
   fácil (quitar la foto), que no merece el peso visual de un botón. */
.aj-btn-link {
    padding: 9px 6px;
    border: 0;
    background: none;
    color: #868e96;
    font: inherit; font-size: 13.5px; font-weight: 600;
    cursor: pointer;
}
.aj-btn-link:hover { color: #e03131; }
