/* ═══════════════════════════════════════════════════════════════════════════
   Link-in-Bio Editor Styles
   Mobile PWA - Reachh
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Header ─────────────────────────────────────────────────────────────── */

.lib-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
}

.lib-editor-header .header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lib-editor-header .header-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.lib-editor-header .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lib-editor-btn-back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f3f4f6;
  color: #374151;
  border: none;
  font-size: 20px;
}

.lib-editor-btn-preview {
  padding: 6px 14px;
  border-radius: 20px;
  background: #f3f4f6;
  color: #374151;
  border: none;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lib-editor-btn-save {
  padding: 6px 18px;
  border-radius: 20px;
  background: #7C3AED;
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.lib-editor-btn-save.saved {
  background: #10B981;
}

.lib-editor-btn-save.saving {
  background: #6B7280;
  pointer-events: none;
}

.lib-editor-btn-save .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lib-spin 0.6s linear infinite;
}

@keyframes lib-spin {
  to { transform: rotate(360deg); }
}

/* ─── Live Preview Frame ─────────────────────────────────────────────────── */

.lib-preview-frame {
  margin: 68px auto 8px;
  width: 320px;
  max-width: 90vw;
  height: 480px;
  border-radius: 28px;
  border: 3px solid #1f2937;
  overflow: hidden;
  position: relative;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.lib-preview-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 22px;
  background: #1f2937;
  border-radius: 0 0 14px 14px;
  z-index: 5;
}

.lib-preview-inner {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.lib-preview-inner::-webkit-scrollbar {
  display: none;
}

/* ─── Editor Tab Bar ─────────────────────────────────────────────────────── */

.lib-editor-tabs {
  display: flex;
  gap: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.lib-editor-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.2s;
  border-bottom: 2px solid transparent;
}

.lib-editor-tab i {
  font-size: 18px;
}

.lib-editor-tab.active {
  color: #7C3AED;
  border-bottom-color: #7C3AED;
}

.lib-editor-tab-panel {
  display: none;
  padding: 16px;
}

.lib-editor-tab-panel.active {
  display: block;
}

/* ─── Block List ─────────────────────────────────────────────────────────── */

.lib-block-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-block-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  transition: box-shadow 0.2s;
}

.lib-block-item.dragging {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  opacity: 0.9;
}

.lib-block-item .drag-handle {
  color: #d1d5db;
  font-size: 18px;
  cursor: grab;
  padding: 4px;
  flex-shrink: 0;
}

.lib-block-item .block-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 16px;
  flex-shrink: 0;
}

.lib-block-item .block-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.lib-block-item .block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lib-block-item .block-actions button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: #9ca3af;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.lib-block-item .block-actions button:hover {
  background: #f3f4f6;
  color: #374151;
}

.lib-block-item .block-actions button.visibility-off {
  color: #d1d5db;
}

.lib-block-item .block-actions .btn-delete:hover {
  background: #FEE2E2;
  color: #EF4444;
}

.lib-add-block-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: none;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lib-add-block-btn:hover {
  border-color: #7C3AED;
  color: #7C3AED;
  background: #F5F3FF;
}

/* ─── Add Block Grid ─────────────────────────────────────────────────────── */

.lib-add-block-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
}

.lib-add-block-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.lib-add-block-option:hover,
.lib-add-block-option:active {
  border-color: #7C3AED;
  background: #F5F3FF;
}

.lib-add-block-option i {
  font-size: 24px;
  color: #7C3AED;
}

.lib-add-block-option span {
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  text-align: center;
  line-height: 1.2;
}

/* ─── Theme Gallery ──────────────────────────────────────────────────────── */

.lib-theme-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.lib-theme-swatch {
  aspect-ratio: 3/4;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.lib-theme-swatch.active {
  border-color: #7C3AED;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.3);
}

.lib-theme-swatch .swatch-preview {
  width: 100%;
  height: 70%;
}

.lib-theme-swatch .swatch-label {
  padding: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #374151;
  background: #fff;
  height: 30%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Color Pickers ──────────────────────────────────────────────────────── */

.lib-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.lib-color-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.lib-color-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  position: relative;
  overflow: hidden;
}

.lib-color-circle input[type="color"] {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  border: none;
  cursor: pointer;
}

.lib-color-label {
  font-size: 9px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Font Selector ──────────────────────────────────────────────────────── */

.lib-font-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lib-font-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  color: #1f2937;
  background: #fff;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ─── Background Panel ───────────────────────────────────────────────────── */

.lib-bg-type-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.lib-bg-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 10px;
  font-weight: 600;
  color: #6b7280;
}

.lib-bg-type-card.active {
  border-color: #7C3AED;
  color: #7C3AED;
  background: #F5F3FF;
}

.lib-bg-type-card i {
  font-size: 20px;
}

/* Gradient presets */
.lib-gradient-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.lib-gradient-swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.lib-gradient-swatch.active {
  border-color: #7C3AED;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.3);
}

/* ─── Section Headers ────────────────────────────────────────────────────── */

.lib-section-header {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f3f4f6;
}

.lib-section-header:first-child {
  margin-top: 0;
}

/* ─── Toggle Switch ──────────────────────────────────────────────────────── */

.lib-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.lib-toggle-row label {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.lib-toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.lib-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.lib-toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  border-radius: 24px;
  transition: 0.3s;
}

.lib-toggle .slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}

.lib-toggle input:checked + .slider {
  background: #7C3AED;
}

.lib-toggle input:checked + .slider::before {
  transform: translateX(20px);
}

/* ─── Sticker Editor ─────────────────────────────────────────────────────── */

.lib-sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.lib-sticker-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.lib-sticker-item:hover {
  border-color: #7C3AED;
  background: #F5F3FF;
}

.lib-sticker-item.active {
  border-color: #7C3AED;
  background: #EDE9FE;
}

/* ─── Block Settings Modal ───────────────────────────────────────────────── */

.lib-settings-form {
  padding: 16px;
}

.lib-settings-form .form-group {
  margin-bottom: 16px;
}

.lib-settings-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.lib-settings-form .form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  color: #1f2937;
  background: #fff;
}

.lib-settings-form .form-control:focus {
  border-color: #7C3AED;
  outline: none;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.lib-settings-form textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* ─── Link Editor ────────────────────────────────────────────────────────── */

.lib-link-editor-item {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  position: relative;
}

.lib-link-editor-item .remove-link {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #FEE2E2;
  color: #EF4444;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}

/* ─── Animation Select ───────────────────────────────────────────────────── */

.lib-anim-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.lib-anim-option {
  padding: 10px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.2s;
}

.lib-anim-option.active {
  border-color: #7C3AED;
  color: #7C3AED;
  background: #F5F3FF;
}

/* ─── URL Slug ───────────────────────────────────────────────────────────── */

.lib-slug-input {
  display: flex;
  align-items: center;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.lib-slug-prefix {
  padding: 10px 12px;
  background: #f3f4f6;
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
}

.lib-slug-input input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

/* ─── Empty State ────────────────────────────────────────────────────────── */

.lib-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
}

.lib-empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.lib-empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 360px) {
  .lib-theme-gallery {
    grid-template-columns: repeat(3, 1fr);
  }

  .lib-add-block-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lib-bg-type-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
