/* -----------------------------------------------------------
   historia-personaje.css  –  Historia del Personaje
   Tarjeta resumen + Modal de edición en mis-datos.html
----------------------------------------------------------- */

:root {
    --hp-accent:  #8b5cf6;
    --hp-accent-h:#7c3aed;
    --hp-ok:      #22c55e;
    --hp-warn:    #f59e0b;
    --hp-danger:  #ef4444;
    --hp-bg:      #0f172a;
    --hp-surface: #1e293b;
    --hp-surface2:#263148;
    --hp-border:  #334155;
    --hp-border-l:#3d4f6b;
    --hp-text:    #e2e8f0;
    --hp-muted:   #94a3b8;
    --hp-radius:  12px;
}

/* ---- TARJETA RESUMEN ------------------------------------ */
.exp-card--historia {
    background: var(--hp-surface);
    border: 1px solid var(--hp-border);
    border-radius: var(--hp-radius);
    padding: 1.4rem 1.5rem 1.5rem;
    margin-top: 1.25rem;
    transition: border-color .2s;
}
.exp-card--historia:hover { border-color: var(--hp-accent); }

.hist-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.hist-header-left { flex: 1; min-width: 0; }
.hist-header-left h3 {
    font-size: .98rem;
    font-weight: 700;
    color: var(--hp-text);
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .2rem;
}
.hist-header-left h3 i { color: var(--hp-accent); font-size: 1.15rem; }
.hist-subtitle {
    font-size: .73rem;
    color: var(--hp-muted);
    margin: 0;
    line-height: 1.4;
}

.hist-btn-edit {
    flex-shrink: 0;
    background: rgba(139,92,246,.1);
    border: 1px solid rgba(139,92,246,.4);
    color: var(--hp-accent);
    padding: .38rem .95rem;
    border-radius: 7px;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    transition: background .18s, color .18s, border-color .18s;
    white-space: nowrap;
}
.hist-btn-edit:hover { background: var(--hp-accent); border-color: var(--hp-accent); color: #fff; }

/* Barra de progreso */
.hist-progress-wrap { margin-bottom: 1.1rem; }
.hist-progress-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .35rem;
}
.hist-progress-text { font-size: .73rem; color: var(--hp-muted); }
.hist-progress-badge {
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: .12rem .5rem;
    border-radius: 20px;
    white-space: nowrap;
}
.hist-progress-badge.is-ok  { background:rgba(34,197,94,.1);  border:1px solid rgba(34,197,94,.35);  color:var(--hp-ok); }
.hist-progress-badge.is-warn{ background:rgba(245,158,11,.1); border:1px solid rgba(245,158,11,.35); color:var(--hp-warn); }
.hist-progress-bar  { height:5px; background:var(--hp-surface2); border-radius:99px; overflow:hidden; }
.hist-progress-fill { height:100%; border-radius:99px; transition:width .55s ease, background .35s; }

/* Grid preview */
.hist-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: .5rem;
}
.hist-preview-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    background: var(--hp-surface2);
    border: 1px solid var(--hp-border);
    border-radius: 8px;
}
.hist-preview-item i { font-size:1.1rem; color:var(--hp-accent); opacity:.7; flex-shrink:0; }
.hist-preview-item > div { min-width:0; }
.hist-prev-label {
    display: block;
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--hp-muted);
    margin-bottom: 1px;
}
.hist-prev-val {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--hp-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hist-prev-val.is-empty { color:var(--hp-muted); font-weight:400; font-style:italic; }


/* ---- MODAL OVERLAY ------------------------------------- */
.hist-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.hist-modal-card {
    background: var(--hp-bg);
    border: 1px solid var(--hp-border-l);
    border-radius: 14px;
    width: 100%;
    max-width: 540px;
    max-height: min(88vh, 640px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,.7);
    /* overflow:hidden se quita – interfiere con el scroll interno */
    animation: hp-in .22s ease-out both;
}
@keyframes hp-in {
    from { opacity:0; transform:translateY(16px) scale(.97); }
    to   { opacity:1; transform:none; }
}

/* Encabezado */
.hist-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem 1.1rem .65rem;
    border-bottom: 1px solid var(--hp-border);
    border-radius: 14px 14px 0 0;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(139,92,246,.07) 0%, transparent 60%);
}
.hist-modal-header > div { flex:1; min-width:0; }
.hist-modal-header h3 {
    font-size: .88rem;
    font-weight: 700;
    color: var(--hp-text);
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .18rem;
}
.hist-modal-header h3 i { color:var(--hp-accent); font-size:1.2rem; }
.hist-modal-header p { font-size:.73rem; color:var(--hp-muted); margin:0; line-height:1.5; }

.hist-modal-close {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--hp-border);
    color: var(--hp-muted);
    width: 30px; height: 30px;
    border-radius: 7px;
    cursor: pointer;
    display: flex; align-items:center; justify-content:center;
    font-size: 1.15rem;
    transition: background .15s, color .15s, border-color .15s;
    margin-top: 2px;
}
.hist-modal-close:hover { background:var(--hp-surface2); border-color:var(--hp-border-l); color:var(--hp-text); }

/* Body scrolleable – header y footer quedan fijos */
.hist-modal-body {
    flex: 1;
    min-height: 0;          /* CRÍTICO: sin esto flex no comprime el body */
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--hp-border) transparent;
}
.hist-modal-body::-webkit-scrollbar { width: 4px; }
.hist-modal-body::-webkit-scrollbar-thumb { background: var(--hp-border); border-radius: 99px; }

/* Sección interna */
.hist-section {
    padding: .6rem 1.1rem;
    border-bottom: 1px solid var(--hp-border);
}
.hist-section:last-of-type { border-bottom: none; }
.hist-section--civil {
    background: linear-gradient(135deg, rgba(139,92,246,.04) 0%, transparent 70%);
}
.hist-section--required {
    background: linear-gradient(135deg, rgba(239,68,68,.03) 0%, transparent 70%);
}

.hist-section-title {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--hp-muted);
    margin-bottom: .5rem;
    padding-bottom: .3rem;
    border-bottom: 1px dashed var(--hp-border);
}
.hist-section-title i { font-size:.9rem; color:var(--hp-accent); opacity:.8; }

/* Pills estado civil */
.hist-civil-pills { display:flex; flex-wrap:wrap; gap:.45rem; }
.hist-pill {
    background: var(--hp-surface2);
    border: 1.5px solid var(--hp-border);
    color: var(--hp-muted);
    padding: .38rem .9rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 500;
    line-height: 1;
    transition: border-color .15s, color .15s, background .15s;
}
.hist-pill:hover { border-color:var(--hp-accent); color:var(--hp-accent); background:rgba(139,92,246,.07); }
.hist-pill.is-active {
    background: var(--hp-accent);
    border-color: var(--hp-accent);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(139,92,246,.35);
}

/* Grid del formulario */
.hist-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}
.hist-field-group { display:flex; flex-direction:column; gap:.3rem; }
.hist-field-group--full { grid-column: 1 / -1; }

.hist-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .35rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--hp-text);
}
.hist-req { color:var(--hp-danger); font-size:.9rem; line-height:1; }
.hist-label-hint {
    font-size: .66rem;
    font-weight: 400;
    color: var(--hp-muted);
    font-style: italic;
    text-align: right;
}

.hist-input {
    width: 100%;
    background: var(--hp-surface2);
    border: 1.5px solid var(--hp-border);
    color: var(--hp-text);
    padding: .38rem .7rem;
    border-radius: 7px;
    font-size: .8rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}
.hist-input:focus { border-color:var(--hp-accent); box-shadow:0 0 0 3px rgba(139,92,246,.12); }
.hist-input::placeholder { color:var(--hp-muted); opacity:.65; }
.hist-select {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2.2rem;
}
.hist-input[type="time"]::-webkit-calendar-picker-indicator { filter:invert(.5); cursor:pointer; }

/* Alerta de error dentro del modal */
.hist-modal-alert {
    margin: 0 1.1rem .7rem;
    padding: .5rem .8rem;
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.3);
    border-radius: 8px;
    color: #fca5a5;
    font-size: .79rem;
    line-height: 1.55;
}

/* Footer */
.hist-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    padding: .6rem 1.1rem .7rem;
    border-top: 1px solid var(--hp-border);
    border-radius: 0 0 14px 14px;
    flex-shrink: 0;
    background: var(--hp-bg);
}
.hist-btn-cancel {
    background: transparent;
    border: 1.5px solid var(--hp-border);
    color: var(--hp-muted);
    padding: .48rem 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: .83rem;
    font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
}
.hist-btn-cancel:hover { background:var(--hp-surface2); border-color:var(--hp-border-l); color:var(--hp-text); }
.hist-btn-save {
    background: var(--hp-accent);
    border: none;
    color: #fff;
    padding: .5rem 1.45rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    transition: background .15s, box-shadow .15s, opacity .15s;
    box-shadow: 0 2px 12px rgba(139,92,246,.3);
}
.hist-btn-save:hover   { background:var(--hp-accent-h); box-shadow:0 4px 20px rgba(139,92,246,.45); }
.hist-btn-save:disabled{ opacity:.55; cursor:default; box-shadow:none; }

/* Badge tipo sangre en certificado */
.cn-tipo-sangre {
    display: inline-flex;
    align-items: center;
    padding: .12rem .55rem;
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.3);
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 700;
    color: #fca5a5;
    letter-spacing: .04em;
}

/* ---- RESPONSIVE ---------------------------------------- */
@media (max-width: 560px) {
    .hist-modal-overlay { padding: 0; align-items: flex-end; }
    .hist-modal-card  { border-radius:14px 14px 0 0; max-width:100%; max-height: 92dvh; }  
    .hist-form-grid   { grid-template-columns:1fr; }
    .hist-preview-grid{ grid-template-columns:1fr 1fr; }
    .hist-modal-header,
    .hist-section,
    .hist-modal-footer{ padding-left:1rem; padding-right:1rem; }
    .hist-modal-alert { margin-left:1rem; margin-right:1rem; }
}

