/* components/crud/crud.css */
/* Todas las clases con prefijo crud- — aisladas de otros componentes.
   Modificar este archivo nunca afecta el login ni el shell. */

/* Zonas del motor CRUD tras la migración al datagrid: la tabla ocupa
   todo el alto disponible y el modal vive fuera de ese flujo. */
.crud-grid-zone { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.crud-grid-zone > .dg { flex: 1; min-height: 0; }
.crud-modal-zone { flex: 0 0 auto; }

.crud-component { padding: 1.5rem; max-width: 68.75rem; margin: 0 auto; }

.crud-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.crud-title { font-size: 1.25rem; font-weight: 500; color: var(--text); }

.crud-toolbar { margin-bottom: 1rem; }
.crud-search {
  width: 100%; max-width: 20rem;
  padding: 0.5rem 0.75rem; font-size: 0.875rem;
  border: 0.5px solid var(--border-md);
  border-radius: 0.5rem; background: var(--surface); color: var(--text);
}

.crud-btn { padding: 0.5rem 1rem; font-size: 0.8125rem; font-weight: 500; border-radius: 0.5rem; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.375rem; transition: opacity .15s, transform .05s; }
.crud-btn:hover { opacity: .85; }
.crud-btn:active { transform: scale(.97); }
.crud-btn:disabled { opacity: .5; cursor: not-allowed; }
.crud-btn-primary { background: var(--accent); color: #fff; }
.crud-btn-secondary { background: none; border: 0.5px solid var(--border-md); color: var(--text); }

.crud-alert {
  background: var(--danger-bg); color: var(--danger);
  border: 0.5px solid var(--danger);
  padding: 0.625rem 0.875rem; border-radius: 0.5rem; font-size: 0.8125rem; margin-bottom: 1rem;
}

.crud-form-alert {
  background: var(--danger-bg); color: var(--danger);
  border: 0.5px solid var(--danger); border-radius: 0.5rem;
  padding: 0.5625rem 0.875rem; font-size: 0.75rem; margin: 0 1.25rem 0 1.25rem;
  margin-top: 0.75rem;
}

.crud-table-wrap { border: 0.5px solid var(--border); border-radius: 0.625rem; overflow: hidden; }
.crud-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.crud-table th {
  background: var(--bg); padding: 0.625rem 0.875rem; text-align: left;
  font-weight: 500; font-size: 0.75rem; color: var(--muted);
  border-bottom: 0.5px solid var(--border);
}
.crud-table td { padding: 0.625rem 0.875rem; border-bottom: 0.5px solid var(--border); color: var(--text); transition: background-color .1s; }
.crud-table tr:last-child td { border-bottom: none; }
.crud-table tr:hover td { background: var(--bg); }
.crud-col-actions { width: 5.625rem; text-align: right; }

.crud-icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 0.375rem; border-radius: 0.375rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .1s, color .1s, transform .05s;
}
.crud-icon-btn:active { transform: scale(.9); }
.crud-icon-btn:hover { background: var(--bg); color: var(--text); }
.crud-icon-danger:hover { color: var(--danger); }

.crud-loading, .crud-empty {
  padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); font-size: 0.8125rem;
}

.crud-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1.25rem;
}
.crud-modal {
  background: var(--surface); border-radius: 0.75rem;
  width: 100%; max-width: 27.5rem;
  max-height: 90vh; overflow-y: auto;
}
.crud-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 0.5px solid var(--border);
}
.crud-modal-head h3 { font-size: 0.9375rem; font-weight: 500; color: var(--text); }
.crud-modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.875rem; }
.crud-modal-foot {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 0.875rem 1.25rem; border-top: 0.5px solid var(--border);
}

.crud-field { display: flex; flex-direction: column; gap: 0.3125rem; width: 100%; }
.crud-field label { font-size: 0.75rem; font-weight: 500; color: var(--text); }
.crud-input {
  width: 100%; box-sizing: border-box;
  padding: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--text);
  background: var(--surface); border: 0.5px solid var(--border-md);
  border-radius: 0.5rem; outline: none; font-family: inherit;
}
.crud-input:focus { border-color: var(--accent); }
.crud-input-error { border-color: var(--danger); }
.crud-field-error { font-size: 0.6875rem; color: var(--danger); }
