/* ==========================================
   CONFIGURACIÓN GENERAL
========================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Arial, sans-serif;
}


/* ==========================================
   BIBLIOTECA
========================================== */

#library {
  position: fixed;
  left: 0;
  top: 0;

  width: 240px;
  height: 100vh;

  background: rgba(20, 20, 20, 0.94);
  color: #ffffff;

  z-index: 10000;

  padding: 20px;
  overflow-y: auto;

  box-shadow: 5px 0 20px rgba(0, 0, 0, 0.3);
}


/* Encabezado */

.library-header {
  margin-bottom: 25px;
}

.library-header h2 {
  font-size: 21px;
  margin-bottom: 8px;
}

.library-header p {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.7;
}


/* ==========================================
   ELEMENTOS DE LA BIBLIOTECA
========================================== */

#elements-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.library-item {
  height: 90px;

  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  cursor: grab;
  user-select: none;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.library-item:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-3px);
}

.library-item:active {
  cursor: grabbing;
  transform: scale(0.95);
}

.library-item img {
  width: 55px;
  max-height: 60px;

  object-fit: contain;

  pointer-events: none;
  user-select: none;
}

.library-item span {
  margin-top: 7px;

  font-size: 11px;
  text-align: center;

  opacity: 0.85;
}


/* ==========================================
   BOTONES DE LA BIBLIOTECA
========================================== */

#reset-btn,
#save-btn {
  display: block;

  width: 100%;
  border: none;
  border-radius: 8px;

  padding: 12px;
  margin-top: 12px;

  font-size: 14px;
  cursor: pointer;

  transition: all 0.2s ease;
}

#reset-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

#save-btn {
  background: #ffffff;
  color: #222222;
}

#reset-btn:hover,
#save-btn:hover {
  transform: translateY(-2px);
}


/* ==========================================
   MESA / OFRENDA
========================================== */

#altar-container {
  position: relative;

  margin-left: 240px;
  width: calc(100% - 240px);
  height: 100vh;

  background-color: #dcdde2;
  background-image: url('../img/fondo.png');

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  overflow: hidden;
}


/* ==========================================
   CAMPO DE TEXTO DE LA OFRENDA
========================================== */

/* Contenedor centrado sobre la ofrenda */

#altar-container .text-container {
  position: absolute;

  top: 5%;
  left: 0;
  right: 0;

  width: 40%;
  margin-left: auto;
  margin-right: auto;

  z-index: 100;
}

/* Formulario */

#altar-container .text-container form {
  display: block;
  width: 100%;
  margin: 0;
}

/* Input de texto */

#altar-container input.text-box {
  display: block;

  width: 100%;
  height: 52px;

  padding: 10px 20px;

  appearance: none;
  -webkit-appearance: none;

  background-color: rgba(255, 248, 238, 0.92);
  color: #85663c;

  font-family: Arial, sans-serif;
  font-size: 20px;
  font-weight: bold;
  text-align: center;

  border: 2px solid #e6caa3;
  border-bottom: 5px solid #b85d18;
  border-radius: 8px;

  outline: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);

  opacity: 1;
  transition: all 0.3s ease;
}

/* Texto de ejemplo */

#altar-container input.text-box::placeholder {
  color: #9c7c61;
  opacity: 1;

  font-family: Arial, sans-serif;
  font-size: 18px;
  font-weight: normal;
  text-align: center;
  font-style: italic;
}

/* Estado al escribir (Mantiene el fondo beige y solo resalta los bordes y la sombra) */

#altar-container input.text-box:focus {
  background-color: rgba(255, 248, 238, 0.98); /* Mantiene el tono beige cálido */
  border-color: #d99b43;
  border-bottom-color: #d94e1f;
  box-shadow: 0 6px 20px rgba(184, 93, 24, 0.25);
  outline: none;
}


/* ==========================================
   ELEMENTOS SOBRE LA OFRENDA
========================================== */

.draggable {
  position: absolute;

  width: 100px;
  height: auto;

  display: block;

  cursor: grab;
  user-select: none;

  -webkit-user-select: none;
  -webkit-user-drag: none;

  touch-action: none;

  z-index: 10;

  will-change: left, top, width;
}

.draggable.dragging {
  cursor: grabbing;
  transform: scale(1.04);
}

.draggable.selected {
  outline: 2px dashed rgba(255, 255, 255, 0.9);
  outline-offset: 5px;
}


/* ==========================================
   CONTROLES DEL ELEMENTO SELECCIONADO
========================================== */

#element-controls {
  position: fixed;

  display: none;
  align-items: center;
  gap: 5px;

  padding: 6px;
  border-radius: 8px;

  background: rgba(20, 20, 20, 0.9);

  z-index: 20000;

  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

#element-controls button {
  width: 34px;
  height: 34px;

  border: none;
  border-radius: 6px;

  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;

  font-size: 20px;
  cursor: pointer;
}

#element-controls button:hover {
  background: rgba(255, 255, 255, 0.25);
}

#element-controls #delete-element:hover {
  background: rgba(200, 50, 50, 0.8);
}

#size-value {
  color: #ffffff;

  font-size: 12px;
  min-width: 35px;

  text-align: center;
}


/* ==========================================
   DISEÑO RESPONSIVO
========================================== */

@media (max-width: 700px) {

  /* Biblioteca lateral */

  #library {
    width: 100px;
    padding: 12px;
  }

  /* Área de la ofrenda */

  #altar-container {
    margin-left: 100px;
    width: calc(100% - 100px);
  }

  /* Elementos de la biblioteca */

  #elements-list {
    grid-template-columns: 1fr;
  }

  .library-header h2 {
    font-size: 17px;
  }

  .library-header p {
    font-size: 11px;
  }

  /* Campo de texto */

  #altar-container .text-container {
    width: 85%;
    top: 4%;
  }

  #altar-container input.text-box {
    height: 44px;
    padding: 8px;

    font-size: 16px;
  }

  #altar-container input.text-box::placeholder {
    font-size: 12px;
  }

  /* Botones de la biblioteca */

  #reset-btn,
  #save-btn {
    padding: 8px 4px;
    font-size: 11px;
  }
}



.draggable.locked {
  cursor: default !important;
}

.draggable.locked.selected {
  outline: 2px dashed rgba(220, 53, 69, 0.9); /* Borde rojo al estar seleccionado y bloqueado */
}

#element-controls #lock-element.active {
  background: rgba(220, 53, 69, 0.8); /* Botón en rojo cuando está bloqueado */
}