/* =============================================================
   ADMIN — Panel de edición. UI propia, deliberadamente distinta
   del sitio público para no confundir una vista con la otra.
   ============================================================= */

:root {
  --a-bg: #0e0f12;
  --a-panel: #16181d;
  --a-panel-2: #1d2027;
  --a-line: #2a2e37;
  --a-text: #e8e9ec;
  --a-muted: #8b909c;
  --a-accent: #c9a227;
  --a-ok: #3fb27f;
  --a-danger: #e0574a;
  --a-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--a-bg);
  color: var(--a-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ------------------------------ LOGIN ------------------------------ */
.login {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login__card {
  width: min(400px, 100%);
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 14px;
  padding: 2.5rem;
  text-align: center;
}

.login__card h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 1.9rem;
  margin: 0 0 0.35rem;
}

.login__card p {
  color: var(--a-muted);
  margin: 0 0 2rem;
  font-size: 0.85rem;
}

.login__hint {
  margin-top: 1.25rem !important;
  font-size: 0.75rem !important;
  opacity: 0.65;
}

.login__err {
  color: var(--a-danger);
  font-size: 0.8rem;
  min-height: 1.2em;
  margin: 0.75rem 0;
}

/* ------------------------ AUXILIARES COMUNES ------------------------ */
.subhead {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--a-muted);
  margin: 0 0 1rem;
}

.sep {
  border: 0;
  border-top: 1px solid var(--a-line);
  margin: 2rem 0;
}

.empty {
  color: var(--a-muted);
  font-size: 0.85rem;
}

.listhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.newsec {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.newsec select {
  width: auto;
  min-width: 190px;
  max-width: 340px;
}

.side__user {
  font-size: 0.72rem;
  color: var(--a-muted);
  margin: 0 0 0.5rem;
  padding-left: 0.25rem;
}

.side__user strong {
  color: var(--a-text);
}

.editor--slim {
  padding: 0.85rem;
}

.row--tight {
  align-items: end;
}

/* Alinea los botones con la línea base de los inputs de la misma fila */
.field--btn {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 1.35rem;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ------------------------------ LAYOUT ------------------------------ */
.admin {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100svh;
}

.side {
  background: var(--a-panel);
  border-right: 1px solid var(--a-line);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100svh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.side__brand {
  padding: 0.5rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--a-line);
}

.side__brand strong {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 1.3rem;
  display: block;
}

.side__brand span {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--a-muted);
}

.side__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: 0;
  color: var(--a-muted);
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  text-align: left;
  transition: all 0.2s var(--a-ease);
}

.tab:hover {
  background: var(--a-panel-2);
  color: var(--a-text);
}

.tab.is-active {
  background: var(--a-panel-2);
  color: var(--a-text);
  box-shadow: inset 2px 0 0 var(--a-accent);
}

.tab__icon {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
}

.side__foot {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--a-line);
  padding-top: 1rem;
}

/* ------------------------------ MAIN ------------------------------ */
.main {
  padding: 2rem clamp(1rem, 3vw, 2.5rem) 6rem;
  max-width: 980px;
  width: 100%;
}

.main__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--a-line);
}

.main__head h2 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 1.9rem;
  margin: 0;
}

.main__head p {
  color: var(--a-muted);
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
  animation: fade 0.35s var(--a-ease);
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ----------------------------- CAMPOS ----------------------------- */
.field {
  margin-bottom: 1.35rem;
}

.field > label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--a-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.field__hint {
  font-size: 0.75rem;
  color: var(--a-muted);
  margin: 0.4rem 0 0;
  opacity: 0.8;
}

input[type='text'],
input[type='url'],
input[type='email'],
input[type='password'],
input[type='number'],
textarea,
select {
  width: 100%;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  color: var(--a-text);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--a-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a-accent) 18%, transparent);
}

textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.6;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

/* ---------------------------- COLORES ---------------------------- */
.colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.9rem;
}

.color {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.color input[type='color'] {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--a-line);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.color__meta {
  min-width: 0;
  flex: 1;
}

.color__name {
  font-size: 0.75rem;
  display: block;
  margin-bottom: 0.15rem;
}

.color__hex {
  width: 100%;
  background: none;
  border: 0;
  color: var(--a-muted);
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  padding: 0;
}

.color__hex:focus {
  outline: 0;
  color: var(--a-text);
  box-shadow: none;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.preset {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 100px;
  padding: 0.45rem 0.9rem 0.45rem 0.5rem;
  color: var(--a-text);
  font-size: 0.78rem;
  transition: border-color 0.2s;
}

.preset:hover {
  border-color: var(--a-accent);
}

.preset__dots {
  display: flex;
}

.preset__dots i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--a-panel);
  margin-right: -5px;
}

/* ---------------------------- IMÁGENES ---------------------------- */
.img-field {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 1rem;
  align-items: start;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 10px;
  padding: 0.85rem;
}

.img-field__thumb {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--a-panel-2);
  border: 1px solid var(--a-line);
}

.img-field__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-field__ctrls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.img-field__row {
  display: flex;
  gap: 0.5rem;
}

.img-field__row input {
  flex: 1;
  min-width: 0;
}

/* ---------------------------- BOTONES ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--a-panel-2);
  border: 1px solid var(--a-line);
  color: var(--a-text);
  border-radius: 8px;
  padding: 0.62rem 1rem;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: all 0.2s var(--a-ease);
}

.btn:hover {
  border-color: var(--a-muted);
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--a-accent);
  border-color: var(--a-accent);
  color: #1a1400;
  font-weight: 600;
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--ghost {
  background: none;
}

.btn--danger {
  color: var(--a-danger);
  border-color: color-mix(in srgb, var(--a-danger) 40%, transparent);
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--a-danger) 12%, transparent);
}

.btn--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.75rem;
}

.btn--block {
  width: 100%;
}

/* --------------------------- PROYECTOS --------------------------- */
.plist {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.pitem {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 10px;
  padding: 0.75rem;
  transition: border-color 0.2s;
}

.pitem:hover {
  border-color: var(--a-muted);
}

.pitem__thumb {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--a-panel-2);
}

.pitem__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pitem__title {
  font-size: 0.95rem;
  margin: 0 0 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pitem__meta {
  font-size: 0.75rem;
  color: var(--a-muted);
  margin: 0;
}

.pitem__acts {
  display: flex;
  gap: 0.35rem;
}

.pill {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--a-accent) 20%, transparent);
  color: var(--a-accent);
  padding: 0.15rem 0.45rem;
  border-radius: 100px;
}

/* Editor de proyecto / lista repetible */
.editor {
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.editor__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--a-line);
}

.editor__head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.gthumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--a-line);
}

.gthumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gthumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
}

.gadd {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--a-line);
  border-radius: 8px;
  background: none;
  color: var(--a-muted);
  font-size: 0.75rem;
  text-align: center;
  gap: 0.25rem;
}

.gadd:hover {
  border-color: var(--a-accent);
  color: var(--a-accent);
}

/* ------------------------- BARRA GUARDAR ------------------------- */
.savebar {
  position: fixed;
  left: 260px;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--a-panel) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--a-line);
  padding: 0.85rem clamp(1rem, 3vw, 2.5rem);
}

.savebar__status {
  font-size: 0.78rem;
  color: var(--a-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--a-muted);
}

.dot.is-dirty {
  background: var(--a-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--a-accent) 20%, transparent);
}

.dot.is-saved {
  background: var(--a-ok);
}

.savebar__acts {
  display: flex;
  gap: 0.5rem;
}

/* ------------------------------ TOAST ------------------------------ */
.toast {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 200;
  background: var(--a-panel-2);
  border: 1px solid var(--a-line);
  border-left: 3px solid var(--a-ok);
  border-radius: 8px;
  padding: 0.85rem 1.15rem;
  font-size: 0.85rem;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s var(--a-ease);
}

.toast.is-show {
  transform: none;
  opacity: 1;
}

.toast.is-error {
  border-left-color: var(--a-danger);
}

/* --------------------------- RESPONSIVE --------------------------- */
@media (max-width: 860px) {
  .admin {
    grid-template-columns: 1fr;
  }
  .side {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--a-line);
  }
  .side__nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  .tab {
    white-space: nowrap;
  }
  .savebar {
    left: 0;
  }
  .main {
    padding-bottom: 7rem;
  }
  .img-field {
    grid-template-columns: 1fr;
  }
  .pitem {
    grid-template-columns: 56px 1fr;
  }
  .pitem__acts {
    grid-column: 2;
  }
}
