/* 
  Plastic Diary - Modernized Mobile-First Stylesheet
*/
:root {
  --bg-color: #FFD7B5;
  --frame-bg: #FFEEF9;
  --text-color: #6C5B7B;
  --ink-color: #2F2A38;
  --menu-color: #7B8A96;
  --menu-active: #E06C8B;
  --line-color: rgba(224, 108, 139, 0.2);
  --glass-bg: rgba(255, 255, 255, 0.65);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Jura', sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

/* Background grid (Mesa/entorno) */
.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: linear-gradient(rgba(248, 202, 231, 0.35) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(248, 202, 231, 0.35) 1px, transparent 1px);
  background-size: 20px 20px;
  z-index: 0;
  pointer-events: none;
}

/* Contenedor Principal (Mobile-First) */
.app-container {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 393px;
  height: 100dvh;
  max-height: 900px;
  padding: 72px 48px 24px 48px;
  flex-direction: column;
  align-items: flex-start;
  box-sizing: border-box;
  overflow: hidden;
  z-index: 10;
}

/* SVG Decorativo Absoluto (top: 12px, left: 12px, 370px × 131px) */
.decor-container {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 370px;
  height: 131px;
  z-index: 70;
  pointer-events: none;
}

.decor-container svg {
  width: 370px;
  height: 131px;
  display: block;
}

/* Elementos interactivos del SVG */
.decor-item {
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
  transform-origin: center;
}

.decor-item:active, .decor-item.tap-pulse {
  transform: scale(1.28);
  filter: drop-shadow(0 0 6px rgba(224, 108, 139, 0.8));
}

#decor-butterfly {
  cursor: pointer;
  pointer-events: auto;
  transform-origin: 185px 25px;
  transition: transform 0.25s ease, filter 0.25s ease, fill 0.3s ease;
}

#decor-butterfly:active {
  transform: scale(1.15);
  filter: drop-shadow(0 0 10px #E06C8B);
}

#decor-butterfly.save-glow {
  animation: butterflySaveGlow 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes butterflySaveGlow {
  0% { fill: #EC91CD; filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
  35% { fill: #48BB78; filter: drop-shadow(0 0 14px #48BB78); transform: scale(1.18); }
  70% { fill: #FF70A6; filter: drop-shadow(0 0 8px #FF70A6); transform: scale(1.05); }
  100% { fill: #EC91CD; filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
}

/* Frame Interior (#FFEEF9) */
.inner-frame {
  display: flex;
  padding: 24px 0;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  flex: 1 0 0;
  align-self: stretch;
  border-radius: 16px;
  background: #FFEEF9;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(108, 91, 123, 0.12);
}

/* SPA Screens */
.spa-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  opacity: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.spa-screen.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* --- Pantalla 1: Bloqueo / PIN Secuencia --- */
.lock-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 0 24px;
  gap: 24px;
}

.lock-wrapper.shake {
  animation: lockShake 0.4s ease-in-out;
}

@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.lock-info {
  text-align: center;
}

.lock-title {
  font-family: 'Jura', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--menu-active);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.lock-subtitle {
  font-size: 0.85rem;
  color: var(--menu-color);
}

.lock-dots {
  display: flex;
  gap: 16px;
}

.lock-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--menu-active);
  background: transparent;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lock-dot.filled {
  background: var(--menu-active);
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(224, 108, 139, 0.6);
}

.lock-dot.error {
  background: #E53E3E;
  border-color: #E53E3E;
}

.lock-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.text-btn {
  background: none;
  border: none;
  font-family: 'Jura', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--menu-color);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 12px;
  transition: all 0.15s;
}

.text-btn:active {
  color: var(--menu-active);
  background: rgba(224, 108, 139, 0.1);
}

.primary-btn {
  background: var(--menu-active);
  color: white;
  border: none;
  font-family: 'Jura', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(224, 108, 139, 0.3);
  transition: transform 0.1s;
}

.primary-btn:active { transform: scale(0.95); }

.error-msg {
  color: #E53E3E;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* --- Pantalla 2: Inicio (Home Menu) --- */
.home-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 16px;
  padding: 16px 0;
  overflow-y: auto;
}

.home-menu-item {
  font-family: 'Jura', sans-serif;
  font-size: 1.22rem;
  font-weight: 600;
  color: #4A3E56;
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
  outline: none;
}

.home-menu-item:active {
  color: var(--menu-active);
  transform: scale(1.04);
}

.home-dropdown-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dropdown-chevron {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.dropdown-toggle.open .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  width: 100%;
  animation: dropdownExpand 0.25s ease;
}

@keyframes dropdownExpand {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  font-family: 'Jura', sans-serif;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--menu-color);
  background: none;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-item:active {
  color: var(--menu-active);
  transform: scale(1.03);
}

.legacy-item {
  color: #A36B9E;
  font-style: italic;
}

/* --- Pantalla 3: Escribir & Pantalla 4: Leer --- */
.page-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  height: 38px;
}

.page-date {
  font-family: 'Jura', sans-serif;
  color: var(--menu-active);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 1px;
}

.save-pill {
  font-family: 'Jura', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(72, 187, 120, 0.18);
  color: #2F855A;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.save-pill.visible {
  opacity: 1;
  transform: translateY(0);
}

.read-header {
  justify-content: space-between;
}

.nav-arrow {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--menu-color);
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1;
}

.nav-arrow:active {
  color: var(--menu-active);
  transform: scale(1.15);
}

.page-scroll-area {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 20px 16px;
  box-sizing: border-box;
  position: relative;
}

.page-paper {
  position: relative;
  width: 100%;
  min-height: 100%;
}

.diary-text {
  width: 100%;
  min-height: 480px;
  font-family: 'Caveat', cursive;
  font-size: 1.8rem;
  line-height: 32px;
  color: var(--ink-color);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 31px,
    var(--line-color) 31px,
    var(--line-color) 32px
  );
  background-attachment: local;
}

.diary-text:empty::before {
  content: attr(data-placeholder);
  color: rgba(108, 91, 123, 0.35);
}

.diary-text.read-only {
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

.read-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 10px 20px 4px 20px;
  box-sizing: border-box;
}

.small-nav-btn {
  background: none;
  border: 1px solid var(--menu-color);
  border-radius: 16px;
  padding: 5px 12px;
  font-family: 'Jura', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--menu-color);
  cursor: pointer;
  transition: all 0.15s;
}

.small-nav-btn:active {
  border-color: var(--menu-active);
  color: var(--menu-active);
}

/* --- Polaroids con Text-Wrap & Tesafí --- */
.polaroids-wrapper {
  /* Contenedor lógico de polaroids */
}

.polaroid-item {
  position: relative;
  background: #FFFFFF;
  padding: 6px 6px 20px 6px;
  box-shadow: 0 4px 12px rgba(60, 40, 70, 0.16), 0 1px 3px rgba(0,0,0,0.06);
  border-radius: 2px;
  box-sizing: border-box;
  width: 135px;
  max-width: 48%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
  margin-bottom: 12px;
}

.polaroid-item.float-right {
  float: right;
  margin-left: 14px;
  margin-right: 2px;
  shape-outside: margin-box;
}

.polaroid-item.float-left {
  float: left;
  margin-right: 14px;
  margin-left: 2px;
  shape-outside: margin-box;
}

.polaroid-item::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(2deg);
  width: 44px;
  height: 13px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  z-index: 5;
  pointer-events: none;
}

.polaroid-item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 1px;
  pointer-events: none;
}

/* Estado de Arrastre */
.polaroid-item.is-dragging {
  position: fixed !important;
  z-index: 9999 !important;
  opacity: 0.92;
  transform: scale(1.08) rotate(0deg) !important;
  box-shadow: 0 16px 36px rgba(40, 20, 50, 0.35);
  pointer-events: none;
  transition: none !important;
}

.polaroid-item.edge-warning {
  box-shadow: 0 0 0 3px #E53E3E, 0 16px 36px rgba(229, 62, 62, 0.4) !important;
  filter: saturate(1.4);
}

/* Indicadores laterales de eliminación */
.edge-drop-zone {
  position: absolute;
  top: 72px;
  bottom: 24px;
  width: 48px;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.edge-drop-zone.edge-left {
  left: 0;
  border-radius: 0 16px 16px 0;
}

.edge-drop-zone.edge-right {
  right: 0;
  border-radius: 16px 0 0 16px;
}

.edge-drop-zone.active-hover {
  background: rgba(229, 62, 62, 0.35);
}

.edge-delete-hint {
  font-size: 1.8rem;
  animation: pulseHint 0.8s infinite alternate;
}

@keyframes pulseHint {
  from { transform: scale(0.9); }
  to { transform: scale(1.2); }
}

/* --- Menú Mariposa Emergente --- */
.glass-menu {
  position: absolute;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 18px;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(108, 91, 123, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 200;
  width: 80%;
  max-width: 270px;
  animation: menuFadeDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes menuFadeDown {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.butterfly-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.butterfly-menu-list li {
  font-family: 'Jura', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--menu-color);
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.butterfly-menu-list li:active {
  color: var(--menu-active);
  background: rgba(224, 108, 139, 0.1);
  transform: scale(0.98);
}

.menu-icon {
  font-size: 1.2rem;
}

/* --- Modales Personalizados --- */
.custom-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(40, 30, 45, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  box-sizing: border-box;
}

.modal-glass-card {
  background: rgba(255, 255, 255, 0.95);
  padding: 22px;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.8);
  text-align: center;
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.modal-icon {
  font-size: 2.2rem;
}

.modal-glass-card h3 {
  font-size: 1.15rem;
  color: #333;
}

.modal-glass-card p {
  font-size: 0.85rem;
  color: #666;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.modal-btn {
  font-family: 'Jura', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  flex: 1;
  transition: transform 0.1s ease;
}

.modal-btn:active { transform: scale(0.95); }
.btn-secondary { background: #E2E8F0; color: #4A5568; }
.btn-danger { background: #E53E3E; color: #FFFFFF; }
.btn-primary { background: var(--menu-active); color: #FFFFFF; }

.date-picker-input {
  font-family: 'Jura', sans-serif;
  font-size: 1rem;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #CBD5E0;
  outline: none;
  text-align: center;
}

/* --- Zoom Cámara al 90% --- */
.camera-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 15, 25, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.camera-zoom-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
}

.camera-zoom-content {
  position: relative;
  z-index: 10;
  width: 90vw;
  max-width: 360px;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: cameraZoomIn 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}

@keyframes cameraZoomIn {
  from {
    transform: scale(0.65) rotate(-5deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.camera-zoom-polaroid {
  background: #FFFFFF;
  padding: 10px 10px 28px 10px;
  border-radius: 3px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  width: 100%;
  position: relative;
}

.camera-zoom-polaroid img {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
  border-radius: 2px;
}

.camera-zoom-caption {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: #666;
  text-align: center;
  margin-top: 10px;
}

/* --- Pantalla 5: Ver Galería (Álbum) --- */
.gallery-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  padding: 8px 16px 16px 16px;
  box-sizing: border-box;
}

.gallery-counter {
  font-family: 'Jura', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--menu-active);
  letter-spacing: 1px;
}

.gallery-album-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gallery-polaroid {
  background: white;
  padding: 10px 10px 28px 10px;
  border-radius: 3px;
  box-shadow: 0 12px 30px rgba(80, 50, 80, 0.2);
  max-width: 250px;
  width: 85%;
  position: relative;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.gallery-polaroid::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(2deg);
  width: 50px;
  height: 15px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gallery-polaroid img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  border-radius: 2px;
}

.gallery-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.gallery-date {
  font-family: 'Jura', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #4A3E56;
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--menu-active);
  font-family: 'Jura', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
}

.gallery-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 10px;
}

.gallery-arrow {
  background: none;
  border: none;
  font-size: 2.2rem;
  color: var(--menu-color);
  cursor: pointer;
  padding: 4px 14px;
  line-height: 1;
}

.gallery-arrow:active {
  color: var(--menu-active);
  transform: scale(1.15);
}

.home-link-btn {
  background: none;
  border: 1px solid var(--menu-color);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: 'Jura', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--menu-color);
  cursor: pointer;
}

.home-link-btn:active {
  border-color: var(--menu-active);
  color: var(--menu-active);
}
