/* styles.css */
:root{
  --bg: #0f172a;           
  --panel: #111827;        
  --panel-2: #0b1220;      
  --text: #e5e7eb;         
  --muted: #9ca3af;        
  --accent: #6366f1;       
  --accent-2: #8b5cf6;     
  --ok: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial;
  color:var(--text);
  background: linear-gradient(135deg, #0b1020 0%, #111827 60%, #0f172a 100%);
  background-attachment: fixed;
}

.container{
  width:100%;
  max-width:none;
  margin:0;
  padding:24px 24px 24px 328px;
}

.header{
  position:fixed;
  left:22px;
  top:22px;
  bottom:22px;
  width:280px;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-content:flex-start;
  gap:22px;
  padding:20px;
  background:
    linear-gradient(180deg, rgba(99,102,241,.18), rgba(17,24,39,.82) 44%, rgba(15,23,42,.96)),
    rgba(17,24,39,.96);
  border:1px solid rgba(255,255,255,.1);
  border-radius:20px;
  box-shadow: 0 24px 70px rgba(0,0,0,.46);
  backdrop-filter: blur(10px);
  animation: fadeIn .6s ease-out both;
  z-index:20;
}
.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
  padding-bottom:18px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.brand-icon{
  width:46px;
  height:46px;
  flex:0 0 auto;
  display:grid;
  place-items:center;
  border-radius:14px;
  background:linear-gradient(180deg, var(--accent), var(--accent-2));
  color:#fff;
  font-weight:800;
  box-shadow:0 16px 32px rgba(99,102,241,.28);
}
.brand-icon svg,
.login-mark svg{
  width:26px;
  height:26px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.7;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.title{
  font-size:22px;
  line-height:1.1;
  font-weight:800;
  letter-spacing:0;
}
.subtitle{
  margin-top:4px;
  color:var(--muted);
  font-size:13px;
  font-weight:600;
}
.actions{
  display:flex;
  flex:1;
  flex-direction:column;
  gap:10px;
}
.header .actions form{
  display:block !important;
  width:100%;
}
.header .button,
.header .user-pill{
  width:100%;
  min-height:46px;
  justify-content:flex-start;
}
.header .button{
  border-radius:14px;
  padding:12px 14px;
}
.header .button:hover{
  transform:translateX(2px);
}
.header .button.danger{
  margin-top:auto;
  justify-content:center;
}
.user-pill{
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.05);
  color:#d1d5db;
  display:inline-flex;
  align-items:center;
  gap:10px;
  font-size:13px;
  font-weight:600;
}
.role-icon{
  width:28px;
  height:28px;
  flex:0 0 auto;
  display:grid;
  place-items:center;
  border-radius:10px;
  background:rgba(99,102,241,.18);
  color:#c4b5fd;
}
.role-icon svg{
  width:18px;
  height:18px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}

@media (max-width:980px){
  .container{
    padding:16px;
  }
  .header{
    position:static;
    width:100%;
    min-height:auto;
    margin-bottom:16px;
    flex-direction:row;
    align-items:center;
    gap:16px;
    border-radius:18px;
  }
  .brand{
    min-width:220px;
    padding-bottom:0;
    border-bottom:0;
  }
  .actions{
    flex:1;
    flex-direction:row;
    flex-wrap:wrap;
    justify-content:flex-end;
  }
  .header .actions form{
    width:auto;
  }
  .header .button,
  .header .user-pill{
    width:auto;
    min-height:42px;
  }
  .header .button.danger{
    margin-top:0;
  }
}

@media (max-width:680px){
  .header{
    flex-direction:column;
    align-items:stretch;
  }
  .brand{
    min-width:0;
    padding-bottom:14px;
    border-bottom:1px solid rgba(255,255,255,.08);
  }
  .actions,
  .header .actions form,
  .header .button,
  .header .user-pill{
    width:100%;
  }
  .actions{
    flex-direction:column;
  }
}
.button{
  padding:10px 14px; border-radius:12px; border:1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color:var(--text); cursor:pointer; transition:.2s transform, .2s box-shadow, .2s background;
  text-decoration:none; display:inline-flex; gap:8px; align-items:center; font-weight:600;
}
.button:hover{ transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.3)}
.button.primary{ background: linear-gradient(180deg, var(--accent), var(--accent-2)); border:0}
.button.danger{ background: linear-gradient(180deg, #ef4444, #b91c1c); border:0}
.button.success{ background: linear-gradient(180deg, #10b981, #059669); border:0}
.button:disabled{opacity:.6; pointer-events:none}

.login-body{
  min-height:100%;
  display:grid;
  place-items:center;
  padding:24px;
  background:
    linear-gradient(90deg, rgba(3,7,18,.55), rgba(15,23,42,.18), rgba(3,7,18,.5)),
    url("assets/login-bg.png") center center / cover no-repeat fixed;
}
.login-shell{
  width:min(440px, 100%);
}
.login-panel{
  padding:26px;
  border-radius:16px;
  background:linear-gradient(180deg, rgba(17,24,39,.86), rgba(15,23,42,.78));
  border:1px solid rgba(255,255,255,.1);
  box-shadow:0 24px 70px rgba(0,0,0,.45);
  backdrop-filter:blur(12px);
  animation:fadeIn .5s ease-out both;
}
.login-brand{
  display:flex;
  flex-direction:column;
  gap:14px;
  align-items:center;
  text-align:center;
  margin-bottom:18px;
}
.login-mark{
  width:48px;
  height:48px;
  border-radius:14px;
  display:grid;
  place-items:center;
  font-weight:800;
  background:linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow:0 14px 30px rgba(99,102,241,.25);
}
.login-brand h1{
  margin:0;
  font-size:24px;
  letter-spacing:0;
}
.login-brand p{
  margin:4px 0 0;
  color:var(--muted);
  font-size:14px;
}
.login-form{
  display:grid;
  gap:14px;
}
.password-field{
  position:relative;
  display:block;
}
.password-field .input{
  padding-right:48px;
}
.password-toggle{
  position:absolute;
  right:8px;
  top:50%;
  width:36px;
  height:36px;
  transform:translateY(-50%);
  border:0;
  background:transparent;
  color:#d1d5db;
  cursor:pointer;
  display:grid;
  place-items:center;
  padding:0;
}
.password-toggle svg{
  width:21px;
  height:21px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.password-toggle:hover,
.password-toggle:focus,
.password-toggle:active{
  background:transparent;
  box-shadow:none;
  outline:none;
  transform:translateY(-50%);
}
.login-submit{
  width:100%;
  justify-content:center;
  margin-top:4px;
}
.login-help{
  margin:16px 0 0;
  color:var(--muted);
  font-size:13px;
  line-height:1.45;
}

.card{
  margin-top:16px; padding:16px; border-radius:16px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border:1px solid rgba(255,255,255,.08);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  animation: fadeIn .6s ease-out both .08s;
}

.filters{display:grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap:10px}
@media (max-width:900px){ .filters{ grid-template-columns: 1fr 1fr } }
@media (max-width:520px){ .filters{ grid-template-columns: 1fr } }

.input, select{
  width:100%; padding:10px 12px; border-radius:12px; border:1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04); color: var(--text);
  line-height:1.45;
  outline:none; transition:border .2s, box-shadow .2s;
}
textarea.input{
  min-height:96px;
  resize:vertical;
  text-align:justify;
  white-space:pre-wrap;
}
input.input,
select{
  text-align:left;
}
.input:focus, select:focus{ border-color: rgba(99,102,241,.6); box-shadow: 0 0 0 4px rgba(99,102,241,.2)}
.input:read-only,
textarea.input:read-only,
select:disabled{
  opacity:1;
  color:#f9fafb;
  background:rgba(255,255,255,.03);
  border-color:rgba(255,255,255,.06);
}
select{
  color-scheme: dark;
  cursor:pointer;
}
select option,
select optgroup{
  background:#111827;
  color:#f9fafb;
}
select option:checked{
  background:#4f46e5;
  color:#ffffff;
}
.filters select{
  min-height:42px;
  background-color:#111827;
}

.table-wrap{ overflow:auto; border-radius:12px; border:1px solid rgba(255,255,255,.08)}
.card.table-wrap{ padding:0 }
table{
  width:100%;
  border-collapse:collapse;
  table-layout:fixed;
}
th, td{
  padding:10px 10px;
  border-bottom:1px solid rgba(255,255,255,.06);
  vertical-align:top;
  overflow-wrap:anywhere;
  word-break:normal;
}
th{
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(99,102,241,.25), rgba(139,92,246,.15));
  text-align:left; font-size:13px; letter-spacing:0;
}
td{ font-size:14px; color:#e8eaf0 }
tr:hover td{ background: rgba(255,255,255,.02) }
tbody tr{ height:108px }

.col-apellido{ width:11% }
.col-nombres{ width:13% }
.col-dni{ width:8% }
.col-prontuario{ width:8% }
.col-establecimiento{ width:16% }
.col-localidad{ width:13% }
.col-situacion{ width:12% }
.col-ingreso{ width:11% }
.col-acciones{ width:78px }
.actions-cell{
  padding:8px 6px;
  text-align:center;
  white-space:normal;
}
.actions-cell > .button + .button{ margin-top:4px }
.actions-cell form{ display:block !important; margin-top:4px }
.actions-cell .button{
  width:100%;
  height:28px;
  min-width:0;
  gap:0;
  justify-content:center;
  padding:0 6px;
  border-radius:8px;
  font-size:0;
  line-height:1;
  white-space:nowrap;
}
.actions-cell .button::before{
  font-size:12px;
  font-weight:700;
}
.actions-cell > .button:nth-of-type(1)::before{ content:"Ver" }
.actions-cell > .button:nth-of-type(2)::before{ content:"Editar" }
.actions-cell form .button::before{ content:"Borrar" }

@media (max-width:1100px){
  table{ min-width:980px }
}

.badge{ padding:4px 8px; border-radius:999px; font-size:12px; background:rgba(99,102,241,.2); border:1px solid rgba(99,102,241,.25) }
.badge.ok{ background:rgba(16,185,129,.2); border-color:rgba(16,185,129,.3)}
.badge.no{ background:rgba(239,68,68,.2); border-color:rgba(239,68,68,.3)}

/* Modal: ahora el fondo es sólido y cubre todo (no se ve la app detrás) */
.modal{
  position:fixed; inset:0;
  background:#0f172a; /* fondo sólido opaco */
  display:none; align-items:center; justify-content:center; padding:16px;
  z-index:9999;
}
.modal.open{ display:flex }
.modal .box{
  width:min(1100px, 98vw); max-height:95vh; overflow:auto;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border:1px solid rgba(255,255,255,.08); border-radius:16px; padding:16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

.image-viewer{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
  background:rgba(2,6,23,.82);
  z-index:10000;
}
.image-viewer.open{ display:flex }
.image-viewer-box{
  position:relative;
  width:min(1000px, 90vw);
  max-width:90vw;
  max-height:90vh;
  padding:14px;
  background:#111827;
  border:1px solid rgba(255,255,255,.14);
  border-radius:12px;
  box-shadow:0 24px 70px rgba(0,0,0,.62);
}
.image-viewer-box img{
  display:block;
  width:100%;
  max-width:calc(90vw - 28px);
  max-height:84vh;
  object-fit:contain;
  border-radius:8px;
  background:#0b1220;
}
.image-viewer-close{
  position:absolute;
  top:8px;
  right:8px;
  width:36px;
  height:36px;
  display:grid;
  place-items:center;
  border:1px solid rgba(255,255,255,.18);
  border-radius:8px;
  background:rgba(15,23,42,.92);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
}
.image-viewer-close:hover{
  background:var(--danger);
  color:#fff;
}

@media (max-width:600px){
  .image-viewer{
    padding:12px;
  }
  .image-viewer-box{
    width:92vw;
    max-width:92vw;
    max-height:86vh;
    padding:10px;
  }
  .image-viewer-box img{
    max-width:calc(92vw - 20px);
    max-height:80vh;
  }
}

.form-grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap:12px }
@media (max-width:900px){ .form-grid{ grid-template-columns: repeat(2, 1fr) } }
@media (max-width:520px){ .form-grid{ grid-template-columns: 1fr } }

.form-actions{ display:flex; gap:8px; justify-content:flex-end; margin-top:12px }
#printButton{ display:none }
.print-report-sheet{ display:none }

@keyframes fadeIn{ from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:none}}

@media print{
  @page{
    margin:0;
    size:auto;
  }
  body{
    background:#fff;
    color:#000;
    -webkit-print-color-adjust:exact;
    print-color-adjust:exact;
  }
  html,
  body{
    width:auto;
    min-height:auto;
  }
  body > .container,
  .modal:not(.open),
  .modal.open > *:not(.box),
  .image-viewer,
  #formPersona,
  .form-actions,
  .alert{
    display:none !important;
  }
  .modal,
  .modal.open{
    position:static;
    display:block;
    padding:0;
    background:#fff;
  }
  .modal .box{
    width:100%;
    max-height:none;
    overflow:visible;
    padding:0;
    border:0;
    border-radius:0;
    box-shadow:none;
    background:#fff;
    color:#000;
  }
  .modal .box > div:first-child,
  #modalTitle{
    display:none !important;
  }
  .print-report-sheet{
    display:block;
    width:100%;
    min-height:auto;
    padding:9mm 11mm;
    font-family:Arial, Helvetica, sans-serif;
    color:#000;
  }
  .report-header{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    padding:12px 14px;
    border:1px solid #d8dee9;
    border-radius:10px;
    background:#f4f7fb;
    break-inside:avoid;
    page-break-inside:avoid;
  }
  .report-kicker{
    margin-bottom:3px;
    color:#4f46e5;
    font-size:9px;
    font-weight:700;
    text-transform:uppercase;
  }
  .report-header h1{
    margin:0;
    color:#111827;
    font-size:20px;
    line-height:1.15;
  }
  .report-header p{
    margin:5px 0 0;
    color:#4b5563;
    font-size:10px;
  }
  .report-photo-wrap{
    flex:0 0 auto;
    padding:4px;
    border:1px solid #cbd5e1;
    border-radius:8px;
    background:#fff;
  }
  .report-photo{
    display:block;
    width:74px;
    height:74px;
    object-fit:cover;
    border-radius:6px;
  }
  .report-summary{
    display:grid;
    grid-template-columns:minmax(0, 2fr) minmax(32mm, 1fr) minmax(32mm, 1fr);
    gap:6px;
    margin:8px 0;
    break-inside:avoid;
    page-break-inside:avoid;
  }
  .report-summary div{
    min-height:18mm;
    padding:6px 8px;
    border:1px solid #e5e7eb;
    border-radius:8px;
    background:#fff;
    break-inside:avoid;
    page-break-inside:avoid;
  }
  .report-summary span,
  .report-label{
    display:block;
    margin-bottom:3px;
    color:#6b7280;
    font-size:8.5px;
    font-weight:700;
    text-transform:uppercase;
  }
  .report-summary strong{
    display:block;
    color:#111827;
    font-size:10.5px;
    line-height:1.22;
    text-align:justify;
    overflow-wrap:anywhere;
  }
  .report-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(42mm, 1fr));
    gap:5px;
    align-items:start;
  }
  .report-field{
    min-height:15mm;
    padding:5px 7px;
    border:1px solid #e5e7eb;
    border-radius:8px;
    background:#fff;
    break-inside:avoid;
    page-break-inside:avoid;
  }
  .report-field.wide{
    grid-column:1 / -1;
    min-height:18mm;
  }
  .report-value{
    color:#111827;
    font-size:9.8px;
    line-height:1.22;
    text-align:justify;
    text-align-last:left;
    white-space:normal;
    overflow:visible;
    overflow-wrap:anywhere;
    word-break:normal;
  }
}
