:root {
    --bg: #191227;
    --card: #221734;
    --line: rgba(255, 255, 255, 0.13);
    --txt: #f1eef8;
    --muted: #b7afca;
    --accent: #f8690e;
    --primary: #7723D8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Poppins", sans-serif;
    color: var(--txt);
    background:
        radial-gradient(90% 110% at 80% 0%, rgba(248, 105, 14, 0.16), transparent 45%),
        linear-gradient(165deg, #140f22 0%, #1a1230 100%);
}

.perfil-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 28px 18px 50px;
}

.perfil-top h1 {
    margin: 8px 0 4px;
    font-size: clamp(1.8rem, 3.2vw, 2.4rem);
}

.perfil-top p {
    margin: 0;
    color: var(--muted);
}

.back-link {
    color: #e4dcf7;
    text-decoration: none;
    font-weight: 600;
}

.perfil-card {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(34, 23, 52, 0.9);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    padding: 18px;
}

.avatar-block {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    margin-bottom: 14px;
}

.avatar-preview {
    width: 92px;
    height: 92px;
    border-radius: 16px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
}

.avatar-actions {
    display: grid;
    gap: 8px;
}

.avatar-cropper {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(7, 8, 12, 0.35);
    padding: 10px;
    max-width: 320px;
}

.avatar-cropper.is-hidden {
    display: none;
}

.cropper-title {
    margin: 0 0 8px;
    color: #e8e1f7;
    font-weight: 600;
    font-size: 0.92rem;
}

.avatar-crop-stage {
    width: min(280px, 72vw);
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    background: #120d1f;
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
    touch-action: none;
    cursor: grab;
}

.avatar-crop-stage.dragging {
    cursor: grabbing;
}

.avatar-crop-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid rgba(248, 105, 14, 0.5);
    border-radius: 14px;
    pointer-events: none;
}

.avatar-crop-stage img {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    max-width: none;
    max-height: none;
    pointer-events: none;
}

.cropper-zoom {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    color: #d7d0e7;
}

.cropper-zoom input[type="range"] {
    padding: 0;
}

#subir-avatar-btn {
    border: 1px solid rgba(119, 35, 216, 0.5);
    border-radius: 10px;
    background: rgba(119, 35, 216, 0.2);
    color: #fff;
    padding: 9px 12px;
    width: fit-content;
    cursor: pointer;
    font-weight: 600;
}

.avatar-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ghost-danger {
    border: 1px solid rgba(248, 105, 14, 0.38);
    border-radius: 10px;
    background: rgba(248, 105, 14, 0.14);
    color: #ffd7b3;
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 600;
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

#avatar-msg {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.perfil-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--muted);
}

.section-help {
    color: var(--muted);
    font-size: 0.9rem;
}

.section-count {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.intereses-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: #d7d0e7;
    padding: 8px 14px;
    font-size: 0.95rem;
    cursor: pointer;
}

.tag-btn.selected {
    border-color: rgba(119, 35, 216, 0.7);
    background: rgba(119, 35, 216, 0.2);
    color: #c6b8ff;
    box-shadow: 0 0 0 2px rgba(119, 35, 216, 0.2);
}

.tag-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.links-section h3 {
    margin: 0 0 6px;
}

.link-row {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 10px;
    margin-top: 8px;
    align-items: center;
}

.link-index {
    color: var(--muted);
    font-size: 0.9rem;
}

.link-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

input, textarea, select {
    background: rgba(7, 8, 12, 0.5);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--txt);
    padding: 11px 12px;
    font-size: 0.96rem;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: rgba(119, 35, 216, 0.8);
    box-shadow: 0 0 0 3px rgba(119, 35, 216, 0.22);
}

.full {
    grid-column: 1 / -1;
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#guardar-btn {
    border: none;
    border-radius: 12px;
    padding: 11px 16px;
    color: white;
    font-weight: 700;
    background: linear-gradient(130deg, var(--primary), #5f1fc4);
    cursor: pointer;
}

#perfil-msg {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

#perfil-msg.ok {
    color: #8ef0b7;
}

#perfil-msg.error {
    color: #ffc5bd;
}

@media (max-width: 760px) {
    .avatar-block {
        grid-template-columns: 1fr;
    }

    .perfil-grid {
        grid-template-columns: 1fr;
    }
}

/* Mejora UX: ocultar el input nativo sin perder accesibilidad */
#avatar-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(248, 105, 14, 0.25), 0 0 0 6px rgba(119, 35, 216, 0.18);
}
