/* Vista previa + modal de recorte (registro, perfil, etc.) */
.profile-photo-upload {
  text-align: center;
  margin-bottom: 28px;
}

.profile-photo-upload > label {
  display: block;
  margin-bottom: 14px;
}

.profile-photo-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ── Contenedor único consolidado ── */
.profile-photo-preview {
  --photo-ring: #e2e8f0;
  --photo-ring-width: 3px;
  --photo-fill: #f8fafc;
  position: relative;
  flex-shrink: 0;
  width: 128px;
  height: 128px;
  box-sizing: border-box;
  border: 0;
  outline: 0;
  overflow: visible;
  box-shadow: none;
  filter: none;
  border-radius: 50%;
  padding: var(--photo-ring-width);
  background: var(--photo-ring);
}

.profile-photo-preview--dark {
  --photo-ring: rgba(255, 255, 255, 0.35);
  --photo-fill: rgba(255, 255, 255, 0.08);
}

.profile-photo-preview--light {
  --photo-ring: #e2e8f0;
  --photo-fill: #f8fafc;
}

/* ── Placeholder e imagen ocupan el círculo interior (el padding es el anillo) ──
   Las medidas van explícitas y no con `width: auto`: en un elemento reemplazado
   posicionado, `auto` resuelve al tamaño intrínseco —los 400px que deja el
   recorte— y la foto se sale del anillo. El porcentaje se mide contra la caja
   de relleno del contenedor, así que hay que descontar el anillo dos veces. */
.profile-photo-placeholder,
.profile-photo-preview img {
  position: absolute;
  inset: var(--photo-ring-width);
  width: calc(100% - var(--photo-ring-width) * 2);
  height: calc(100% - var(--photo-ring-width) * 2);
  border-radius: 50%;
  background: var(--photo-fill);
}

.profile-photo-preview img {
  object-fit: cover;
  display: block;
}

/* `display: block` de la regla anterior gana al `display: none` del atributo
   `hidden`, así que sin esto la imagen vacía tapa el placeholder. */
.profile-photo-preview img[hidden] {
  display: none;
}

/* ── Oculta el placeholder cuando hay foto ── */
.profile-photo-preview img:not([hidden]) ~ .profile-photo-placeholder {
  display: none;
}

.profile-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-photo-placeholder svg {
  width: 52px;
  height: 52px;
  opacity: 0.65;
}

.profile-photo-preview--dark .profile-photo-placeholder svg {
  color: #cbd5e0;
}

.profile-photo-preview--light .profile-photo-placeholder svg {
  color: #94a3b8;
}

.profile-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.profile-photo-hint {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
}

.profile-photo-hint--dark {
  color: #cbd5e0;
}

.profile-photo-hint--light {
  color: #64748b;
}

.btn-photo-select,
.btn-photo-change {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn-photo-select:hover,
.btn-photo-change:hover {
  transform: translateY(-1px);
}

.btn-photo-select--dark,
.btn-photo-change--dark {
  background: #ffffff;
  color: #0f4c81;
}

.btn-photo-select--dark:hover,
.btn-photo-change--dark:hover {
  background: #f1f5f9;
}

.btn-photo-select--light,
.btn-photo-change--light {
  background: linear-gradient(135deg, #0f4c81 0%, #0069c2 100%);
  color: #fff;
}

/* Recorte de imagen. Tiene su propio JS (profile-photo-cropper.js) y se usa
   también en el login, que no carga modal.css; por eso repite aquí el cromo
   del modal estándar (cabecera, pie y botones del modal "Abrir ticket"). */
.foto-crop-overlay {
  --crop-modal-bg: var(--color-surface, #ffffff);
  --crop-modal-muted-bg: var(--color-surface-muted, #eef2f6);
  --crop-modal-text: var(--color-text, #0d1f33);
  --crop-modal-heading: var(--color-heading, #0b3a63);
  --crop-modal-muted: var(--color-text-muted, #51637a);
  --crop-modal-border: var(--color-border, #e3e9f0);
  --crop-modal-border-strong: var(--color-border-strong, #d3dce6);
  --crop-modal-ink: var(--ink, #0d1f33);
  --crop-modal-brand: var(--brand, #0f4c81);
  --crop-stage-h: 320px;

  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 31, 51, 0.62);
  z-index: 10000;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.foto-crop-overlay.is-open {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.foto-crop-modal {
  background: var(--crop-modal-bg);
  color: var(--crop-modal-text);
  border-radius: var(--modal-radius, 12px);
  width: min(520px, 100%);
  max-width: 100%;
  max-height: min(90vh, 720px);
  margin: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  box-shadow: 0 20px 48px rgba(0, 20, 40, 0.28);
  border: 1px solid var(--crop-modal-border);
}

.foto-crop-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px 14px 24px;
  border-bottom: 1px solid var(--crop-modal-border);
}

.foto-crop-header h3 {
  margin: 0;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--crop-modal-heading);
}

.foto-crop-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--crop-modal-muted);
  font-family: inherit;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.foto-crop-close:hover {
  color: var(--crop-modal-brand);
  background: var(--crop-modal-muted-bg);
}

.foto-crop-body {
  flex: 0 0 auto;
  padding: 12px 16px;
  background: #111827;
  min-height: 0;
}

/* Escenario de recorte: tamaño fijo; la imagen nunca estira el modal */
.foto-crop-stage,
.foto-crop-canvas {
  width: 100%;
  height: var(--crop-stage-h);
  max-height: var(--crop-stage-h);
  background: #0b1220;
  overflow: hidden;
  position: relative;
  border-radius: 8px;
}

.foto-crop-stage img,
.foto-crop-canvas img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.foto-crop-stage .cropper-container,
.foto-crop-canvas .cropper-container {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.foto-crop-modal > .foto-crop-hint {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 24px 0;
  text-align: left;
}

.foto-crop-hint {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--crop-modal-muted);
}

.foto-crop-footer,
.foto-crop-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 24px 16px;
  border-top: 1px solid var(--crop-modal-border);
  flex-wrap: wrap;
  gap: 8px;
  background: var(--crop-modal-muted-bg);
}

.foto-crop-overlay .btn-crop-cancel,
.foto-crop-overlay .btn-crop-save {
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.84rem;
  font-family: inherit;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: transform 0.15s, opacity 0.18s, border-color 0.18s, color 0.18s;
}

.foto-crop-overlay .btn-crop-cancel:hover:not(:disabled),
.foto-crop-overlay .btn-crop-save:hover:not(:disabled) {
  transform: translateY(-1px);
}

.foto-crop-overlay .btn-crop-cancel {
  background: var(--crop-modal-bg);
  color: var(--crop-modal-muted);
  border-color: var(--crop-modal-border-strong);
}

.foto-crop-overlay .btn-crop-cancel:hover {
  border-color: var(--crop-modal-brand);
  color: var(--crop-modal-brand);
}

.foto-crop-overlay .btn-crop-save {
  background: var(--crop-modal-ink);
  color: #ffffff;
}

.foto-crop-overlay .btn-crop-save:hover:not(:disabled) {
  opacity: 0.92;
  color: #ffffff;
}

.foto-crop-overlay .btn-crop-save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.foto-crop-error {
  display: none;
  flex: 0 0 auto;
  margin: 0 20px 12px;
  padding: 10px 14px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.foto-crop-error.is-visible {
  display: block;
}
@media (max-width: 768px) {
  .foto-crop-modal {
    display: flex;
    flex-direction: column;
    max-height: 100dvh;
  }

  .foto-crop-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .foto-crop-stage,
  .foto-crop-canvas {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
  }

  .foto-crop-footer,
  .foto-crop-actions {
    justify-content: stretch;
  }

  .foto-crop-overlay .btn-crop-cancel,
  .foto-crop-overlay .btn-crop-save {
    flex: 1;
  }
}