/* ====== RESET BÁSICO ====== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f5f5f7;
  color: #222;
}

/* ====== LAYOUT GENERAL ====== */

.header {
  padding: 1.2rem 1.5rem;
  background: #1f2937;
  color: #f9fafb;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
}

.header p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

.container {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
  align-items: flex-start;
}

.panel {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.panel-form {
  flex: 1 1 380px;
  max-width: 450px;
}

.panel-list {
  flex: 2 1 0;
  min-width: 0;
}

.footer {
  padding: 0.75rem 1.5rem;
  background: #111827;
  color: #9ca3af;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ====== FORMULARIO ====== */

.panel-form h2,
.panel-list h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.form-row {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
}

.form-row label {
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
  font-weight: 600;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="search"],
.form-row input[type="file"],
.form-row select,
.form-row textarea {
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: #f9fafb;
}

.form-row textarea {
  resize: vertical;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
  background: #ffffff;
}

.form-row small {
  font-size: 0.75rem;
  color: #6b7280;
}

.form-row-inline {
  display: flex;
  gap: 0.75rem;
}

.form-row-inline > div {
  flex: 1;
}

/* ====== PREVIEW FOTO ====== */

.foto-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.foto-preview-wrapper span {
  font-size: 0.8rem;
  color: #4b5563;
}

#fotoPreview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 0.75rem;
  object-fit: contain;
  border: 1px dashed #cbd5f5;
  background: #f9fafb;
}

/* ====== BOTONES ====== */

.btn {
  border-radius: 999px;
  border: none;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease,
    transform 0.05s ease;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.5);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #6b7280;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-outline {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
}

.btn-outline:hover {
  background: #f3f4f6;
}

.btn-danger {
  background: #b91c1c;
  color: #ffffff;
}

.btn-danger:hover {
  background: #991b1b;
}

.btn:active {
  transform: scale(0.97);
}

.btn-file {
  position: relative;
  overflow: hidden;
}

.btn-file input[type="file"] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ====== LISTA / TARJETAS ====== */

.list-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.list-header h2 {
  flex: 1;
  margin: 0;
}

#buscador {
  flex: 1.1;
}

.summary-bar {
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 0.5rem;
}

.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.card {
  background: #f9fafb;
  border-radius: 0.75rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.card-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  white-space: nowrap;
}

.card-body-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-label {
  font-weight: 600;
}

.card-foto {
  margin-top: 0.4rem;
}

.card-foto img {
  width: 100%;
  border-radius: 0.5rem;
  max-height: 150px;
  object-fit: cover;
}

/* ====== OTROS ====== */

.divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1rem 0;
}

/* ====== RESPONSIVE ====== */

@media (max-width: 900px) {
  .container {
    flex-direction: column;
    padding: 0.75rem;
  }

  .panel-form,
  .panel-list {
    max-width: 100%;
  }

  .header,
  .footer {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

@media (max-width: 600px) {
  .list-header {
    flex-direction: column;
    align-items: stretch;
  }

  .cards-container {
    grid-template-columns: 1fr;
  }
}
