/* =========================================================
   ABIX — Estilos del panel de administración
   ========================================================= */

.admin-body { background: var(--arena); }

.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--carbon);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
}
.admin-sidebar__brand { margin-bottom: 30px; padding: 0 8px; }
.admin-sidebar__brand img { height: 38px; }

.admin-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.admin-nav a {
  color: rgba(255,255,255,0.75);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out);
}
.admin-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-nav a.is-active { background: var(--terracota); color: #fff; }

.admin-logout {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 12px;
}
.admin-logout:hover { color: #fff; }

.admin-main { padding: 32px 40px; max-width: 1100px; }

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-topbar h1 { margin: 0; font-size: 1.6rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 34px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--terracota);
}
.stat-card strong { display: block; font-family: var(--font-heading); font-size: 1.8rem; }
.stat-card span { color: var(--gris-medio); font-size: 0.85rem; }

.admin-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--arena);
  font-size: 0.9rem;
  vertical-align: middle;
}
.admin-table th { color: var(--gris-medio); font-family: var(--font-heading); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table tr:hover td { background: var(--blanco-calido); }
.admin-table img.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }

.admin-table td.row-actions { white-space: nowrap; }
.admin-table td.row-actions a, .admin-table td.row-actions button {
  font-size: 0.82rem;
  margin-right: 10px;
  color: var(--terracota);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
  transition: opacity 0.15s var(--ease-out), transform 0.1s var(--ease-out);
}
.admin-table td.row-actions a:hover, .admin-table td.row-actions button:hover { opacity: 0.7; }
.admin-table td.row-actions a:active, .admin-table td.row-actions button:active { transform: scale(0.95); }
.admin-table td.row-actions .danger { color: #B23B2E; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.tag--en_pozo { background: rgba(217,164,65,0.18); color: #8a6417; }
.tag--terminada { background: rgba(122,139,111,0.18); color: #4c5c43; }
.tag--no { background: rgba(107,107,107,0.12); color: var(--gris-medio); }
.tag--si { background: rgba(122,139,111,0.18); color: #4c5c43; }

/* -------- Formularios de admin -------- */

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.admin-form-grid .full { grid-column: 1 / -1; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.photo-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1/1;
  background: var(--arena);
  border: 2px solid transparent;
}
.photo-item.is-principal { border-color: var(--dorado); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item__badge {
  position: absolute; top: 6px; left: 6px;
  background: var(--dorado); color: var(--carbon);
  font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.photo-item__actions {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55);
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 3px 10px;
  padding: 5px 8px;
}
.photo-item__actions button, .photo-item__actions a {
  background: none; border: none; color: #fff; font-size: 0.7rem; cursor: pointer; padding: 0; white-space: nowrap;
}

.photo-grid--tour { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.field-hint { font-size: 0.78rem; color: var(--gris-medio); margin-top: 4px; }

/* -------- Fotos de avance de obra -------- */

.avance-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.avance-admin-item { background: var(--blanco-calido); border-radius: var(--radius-sm); overflow: hidden; }
.avance-admin-item__img { position: relative; aspect-ratio: 4/3; background: var(--arena); }
.avance-admin-item__img img { width: 100%; height: 100%; object-fit: cover; }
.avance-admin-item__delete {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.avance-admin-item__caption { display: flex; gap: 6px; padding: 8px; }
.avance-admin-item__caption input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(55,57,56,0.15);
  font-size: 0.78rem;
  font-family: var(--font-body);
}
.avance-admin-item__caption button { flex-shrink: 0; }

/* -------- Modal de confirmación (reemplaza confirm() nativo) -------- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(55,57,56,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.confirm-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 26px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-hover);
  text-align: center;
}
.confirm-box p { margin: 0 0 20px; color: var(--carbon); }
.confirm-box__actions { display: flex; gap: 10px; justify-content: center; }

/* -------- Editor de tour interactivo -------- */

.hotspot-editor {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--arena);
  line-height: 0;
}
.hotspot-editor img { max-width: 100%; max-height: 520px; display: block; cursor: crosshair; }

.hotspot-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--terracota);
  color: #fff;
  padding: 5px 8px 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.hotspot-marker[data-hotspot-id] { cursor: grab; touch-action: none; }
.hotspot-marker.is-dragging { cursor: grabbing; opacity: 0.85; z-index: 5; box-shadow: var(--shadow-hover); }
.hotspot-marker--preview { background: var(--carbon); opacity: 0.85; padding: 8px; }
.hotspot-marker__etiqueta {
  cursor: text;
  border-radius: 4px;
  padding: 1px 3px;
  margin: -1px -3px;
  outline: none;
}
.hotspot-marker__etiqueta:hover { background: rgba(255,255,255,0.18); }
.hotspot-marker__etiqueta:focus { background: rgba(255,255,255,0.32); box-shadow: 0 0 0 1px rgba(255,255,255,0.6); }
.hotspot-marker__destino { opacity: 0.9; }
.hotspot-marker form { display: contents; }
.hotspot-marker button {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  font-size: 0.85rem;
}
.hotspot-marker button:hover { background: rgba(255,255,255,0.45); }

.hotspot-form {
  display: none;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--arena);
}

/* -------- Login -------- */

.admin-body--login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--carbon), #4a4d4c);
}
.login-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 42px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-hover);
  text-align: center;
}
.login-box__logo { height: 50px; margin: 0 auto 18px; }
.login-box h1 { font-size: 1.3rem; }
.login-box__subtitle { color: var(--gris-medio); font-size: 0.88rem; margin-bottom: 26px; }
.login-box form { text-align: left; }
.login-box__back { display: inline-block; margin-top: 18px; font-size: 0.85rem; color: var(--gris-medio); }
.login-box__back:hover { color: var(--terracota); }

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .admin-sidebar__brand { margin-bottom: 0; }
  .admin-nav { flex-direction: row; }
  .admin-logout { border-top: none; margin-top: 0; }
  .admin-main { padding: 24px 18px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-form-grid { grid-template-columns: 1fr; }
}
