/* ================================
   Design Tokens (variables base) — CHIQUIANDINOS
   Paleta oficial: área misional COMUNIDAD (#A5CF48 verde) + amarillo institucional (#FFF100).
   Fuente: Manual de marca Uniandinos (05 - Recursos/Utils/Manualdemarca.pdf, pág. 9 y 11).
   Nota: el manual imprime "HEX:FF7C30" junto a Comunidad por error (copiado de Red Global);
   el color REAL del swatch (relleno vectorial) es #A5CF48.
=================================== */
:root{
  /* Marca y énfasis */
  --color-brand:#A5CF48;        /* verde — área COMUNIDAD */
  --color-accent:#FFF100;       /* amarillo institucional */
  --color-accent-hover:#E6D800; /* amarillo oscuro (hover) */

  /* Superficies */
  --bg-page:#e6e6e6;
  --bg-form:#f1f1f1;
  --bg-input:#cfd4da;
  --bg-input-focus:#dbe0e6;
  --bg-input-readonly:#bfc5cc;

  /* Texto */
  --text-900:#000;
  --text-800:#111;
  --text-700:#333;
  --text-danger:#c62828;
  --text-success:#1b5e20;

  /* Dimensiones y radios */
  --container-max:980px;
  --radius-form:8px;
  --radius-pill:30px;

  /* Control unify (altura de controles y botones) */
  --control-height:48px;
  --control-padding-x:18px;

  /* Tipografía y espacios */
  --font-ui:'Segoe UI','Roboto',Arial,Helvetica,sans-serif;
  --font-size-sm:13px;
  --font-size-md:14px;
  --font-size-lg:18px;

  --space-xxs:4px;
  --space-xs:6px;
  --space-sm:10px;
  --space-md:16px;
  --space-lg:24px;
  --space-xl:32px;
}

/* ================================
   Base
=================================== */
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg-page);
  font-family:var(--font-ui);
  padding:40px 24px;
  color:var(--text-800);
}

/* ================================
   Contenedores de formulario
=================================== */
.form{
  background:var(--bg-form);
  max-width:var(--container-max);
  margin:0 auto 30px auto;
  padding:40px;
  border-radius:var(--radius-form);
}

/* Fieldset + Legend */
fieldset{border:none;margin:0 0 20px 0;padding:0}
legend{
  font-size:var(--font-size-lg);
  font-weight:600;
  margin-bottom:var(--space-md);
  color:var(--text-900);
}

/* ================================
   Grillas
=================================== */
.grid-2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:var(--space-lg);
}
.grid-full{grid-column:1 / -1}

@media (max-width:768px){
  .grid-2{grid-template-columns:1fr}
}

/* ================================
   Grupos y etiquetas
=================================== */
.form-group{display:flex;flex-direction:column}
.form-group label{
  font-size:var(--font-size-md);
  margin-bottom:var(--space-xs);
  color:var(--text-800);
}

/* ================================
   Controles (inputs/selects/textarea)
=================================== */
.input,
.select{
  width:100%;
  height:var(--control-height);
  padding:0 var(--control-padding-x);
  border:none;
  border-radius:var(--radius-pill);
  background:var(--bg-input);
  font-size:var(--font-size-md);
  line-height:1;
  outline:none;
  transition:background .2s ease, box-shadow .2s ease;
  display:flex;
  align-items:center;
}

.input:focus,
.select:focus{
  background:var(--bg-input-focus);
  box-shadow:0 0 0 3px rgba(165,207,72,.30);
}

.input[readonly]{
  background:var(--bg-input-readonly);
}

/* Textarea: no usa altura fija */
.textarea{
  width:100%;
  min-height:110px;
  padding:14px var(--control-padding-x);
  border:none;
  border-radius:18px;
  background:var(--bg-input);
  font-size:var(--font-size-md);
  outline:none;
  resize:vertical;
  transition:background .2s ease, box-shadow .2s ease;
}
.textarea:focus{
  background:var(--bg-input-focus);
  box-shadow:0 0 0 3px rgba(165,207,72,.30);
}

/* Estados de validación */
.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid{
  box-shadow:0 0 0 3px rgba(198,40,40,.18);
}
.input.is-valid,
.select.is-valid,
.textarea.is-valid{
  box-shadow:0 0 0 3px rgba(27,94,32,.18);
}

/* ================================
   Botones
=================================== */
.btn{
  height:var(--control-height);
  padding:0 32px;
  border:none;
  border-radius:var(--radius-pill);
  font-weight:600;
  font-size:var(--font-size-md);
  color:var(--text-900);
  cursor:pointer;
  transition:background .2s ease, opacity .2s ease, box-shadow .2s ease;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  white-space:nowrap;
}

.btn--primary{
  background:var(--color-accent);
}
.btn--primary:hover{
  background:var(--color-accent-hover);
}

/* Tamaños alternos (opcional) */
.btn--sm{
  height:calc(var(--control-height) - 8px);
  padding:0 24px;
}
.btn--lg{
  height:calc(var(--control-height) + 6px);
  padding:0 36px;
}

/* Estados */
.btn:disabled{
  opacity:.6;
  cursor:not-allowed;
}

/* ================================
   Utilidades
=================================== */
.flex{display:flex}
.flex-gap-sm{gap:var(--space-sm)}
.items-end{align-items:end}
.actions{display:flex;margin-top:var(--space-md)}
.actions--end{justify-content:flex-end}

.mt-xs{margin-top:var(--space-xs)}
.mt-sm{margin-top:var(--space-sm)}
.mt-md{margin-top:var(--space-md)}
.mt-lg{margin-top:var(--space-lg)}

.text-sm{font-size:var(--font-size-sm)}
.text-link{color:var(--color-brand);text-decoration:underline}

.message{
  margin-top:var(--space-xs);
  font-size:var(--font-size-md);
}
.message--error{color:var(--text-danger)}
.message--ok{color:var(--text-success)}

/* ================================
   Modal simple
=================================== */
.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.4);
  z-index:9999;
}
.modal-content{
  background:#fff;
  padding:30px;
  border-radius:12px;
  width:90%;
  max-width:400px;
  text-align:center;
}

/* ================================
   Ajustes para móviles
=================================== */
@media (max-width:768px){
  .actions--end{justify-content:center}
}

/* ================================
   Tablas (mínimo necesario)
=================================== */
.table-responsive{
  width:100%;
  overflow:auto;
  border-radius:12px;
  background:#fff;
}

table{
  width:100%;
  border-collapse:collapse;
  background:#fff;
}

thead th{
  position:sticky; top:0;
  background:#f7f7f7;
  color:var(--text-800);
  font-weight:600;
  text-align:left;
  padding:12px 10px;
  border-bottom:1px solid #e9e9e9;
  font-size:var(--font-size-md);
  white-space:nowrap;
}

tbody td{
  padding:10px;
  border-bottom:1px solid #f0f0f0;
  vertical-align:middle;
  font-size:var(--font-size-md);
  color:var(--text-800);
  white-space:nowrap;
}

/* Inputs/selects dentro de celdas */
table .input,
table .select{
  height:36px;
  padding:0 12px;
  border-radius:18px;
  min-width:140px;
  width:100%;
}

/* Botones dentro de celdas */
table .btn{
  height:36px;
  padding:0 16px;
  font-size:var(--font-size-sm);
  white-space:nowrap;
}

/* Ajuste visual de la fila al pasar el mouse */
tbody tr:hover{
  background:#fafafa;
}

/* ================================
   Tabla — Modo vista / edición
=================================== */

/* ── Botones de fila ── */
.btn-row {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background .18s, opacity .18s;
}
.btn-row:disabled { opacity: .55; cursor: not-allowed; }
.btn-edit   { background: var(--color-brand); color: var(--text-900); }
.btn-edit:hover { background: #8CB43A; }
.btn-save   { background: var(--color-accent); color: var(--text-900); }
.btn-save:hover { background: var(--color-accent-hover); }
.btn-cancel { background: #757575; color: #fff; }
.btn-cancel:hover { background: #555; }

/* ── Inputs/selects en modo edición ── */
table .t-input,
table .t-select {
  height: 30px;
  padding: 0 4px;
  border: none;
  border-bottom: 2px solid #9ca3af;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text-800);
  outline: none;
  width: 100%;
  transition: border-color .18s;
}
table .t-input:focus,
table .t-select:focus { border-bottom-color: var(--color-brand); }
table .t-input[readonly] {
  border-bottom-style: dashed;
  color: var(--text-700);
  cursor: not-allowed;
}

/* ── Fila en modo edición ── */
tr[data-mode="edit"] {
  background: #fffde7 !important;
}
tr[data-mode="edit"] td {
  vertical-align: bottom;
  padding-bottom: 6px;
}

/* ── Celda de texto en modo vista ── */
td .cell-text {
  display: inline-block;
  font-size: 13px;
  color: var(--text-800);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* ── Celda de acciones ── */
td.td-actions {
  white-space: nowrap;
  text-align: center;
}
td.td-actions .btn-row + .btn-row { margin-left: 4px; }
