:root {
  --bg-page: #0b1120;
  --bg-surface: #111827;
  --bg-panel: #1e293b;
  --border-subtle: rgba(148, 163, 184, 0.18);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-hover: #059669;
  --danger: #ef4444;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #172554 0%, var(--bg-page) 55%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: #38bdf8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: rgba(15, 23, 42, 0.75);
  padding: 2px 6px;
  border-radius: 5px;
  color: #67e8f9;
  word-break: break-all;
}

/* Barra superior */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  font-size: 1.4rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.73rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.pill-online {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.pill-local {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

/* Botones generales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  color: #fff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #042f2e;
}

.btn-primary:hover:not(:disabled) {
  background: #34d399;
}

.btn-outline {
  background: rgba(30, 41, 59, 0.7);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  border-color: #64748b;
  background: rgba(51, 65, 85, 0.8);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 700;
}

.btn-icon-sm:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Pantalla de carga */
.center-screen {
  min-height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-box {
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 12px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Pantalla de Autenticación */
.auth-screen {
  max-width: 460px;
  margin: 42px auto;
  padding: 0 16px;
}

.auth-panel {
  background: rgba(30, 41, 59, 0.82);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.auth-header h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.auth-header p {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(15, 23, 42, 0.75);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

.auth-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 9px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--bg-panel);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 5px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.color-input {
  width: 100%;
  height: 40px;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.8);
  cursor: pointer;
}

.md5-info-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px dashed rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.md5-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.helper-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 6px 0 14px;
}

/* Editor + Vista previa */
.editor-layout {
  max-width: 1220px;
  margin: 24px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 410px);
  gap: 28px;
  align-items: start;
}

.editor-SaveBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.editor-SaveBar h2 {
  margin: 0;
  font-size: 1.35rem;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.editor-top-btns {
  display: flex;
  gap: 8px;
}

.blob-meta-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 0.8rem;
}

.meta-full {
  grid-column: 1 / -1;
  word-break: break-all;
}

.meta-tag {
  color: var(--text-muted);
  margin-right: 4px;
}

.panel-card {
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 18px;
}

.panel-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.panel-desc {
  margin: 0 0 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-wa {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

.bg-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-btn {
  cursor: pointer;
}

.swatches-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch-btn:hover {
  transform: scale(1.07);
}

.swatch-btn.active {
  border-color: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35);
}

/* Organizador Drag & Drop */
.organizer-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.organizer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.organizer-item.drag-over {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.12);
}

.organizer-item.dragging {
  opacity: 0.45;
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.1rem;
  user-select: none;
}

.organizer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  cursor: pointer;
  font-size: 0.88rem;
}

.organizer-arrows {
  display: flex;
  gap: 4px;
}

/* Columna de Vista Previa Móvil */
.preview-sticky {
  position: sticky;
  top: 76px;
}

.preview-label-bar {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.phone-frame {
  border-radius: 30px;
  padding: 10px;
  background: #090d16;
  border: 2px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55);
}

/* =========================================================
   TARJETA DE CONTACTO VIRTUAL (Compartida: QR Público + Preview)
   ========================================================= */
.public-card-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
}

.public-card-wrapper {
  width: 100%;
  max-width: 430px;
}

.public-footer {
  margin-top: 18px;
  font-size: 0.8rem;
  opacity: 0.75;
}

.notfound-box {
  max-width: 400px;
  text-align: center;
  background: var(--bg-panel);
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.virtual-card {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  min-height: 540px;
  color: var(--card-text, #ffffff);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}

.virtual-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, var(--card-overlay-alpha, 0.45));
  pointer-events: none;
}

.virtual-card-content {
  position: relative;
  z-index: 2;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.virtual-card.align-center .virtual-card-content {
  text-align: center;
  align-items: center;
}

.virtual-card.align-left .virtual-card-content {
  text-align: left;
  align-items: stretch;
}

.vc-block {
  width: 100%;
  margin: 0;
}

.vc-avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  border: 2px solid var(--card-accent, #25D366);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.vc-name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}

.vc-job {
  margin: 5px 0 0;
  font-size: 0.96rem;
  font-weight: 600;
  opacity: 0.92;
}

.vc-company {
  margin: 2px 0 0;
  font-size: 0.85rem;
  opacity: 0.78;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vc-btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  background: var(--card-accent, #25D366);
  color: #052e16;
  font-weight: 800;
  font-size: 0.98rem;
  text-decoration: none !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.vc-btn-whatsapp:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.vc-btn-disabled {
  opacity: 0.65;
  cursor: default;
}

.vc-bio {
  font-size: 0.9rem;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(6px);
  padding: 12px 14px;
  border-radius: 12px;
}

.vc-contact-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.vc-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  color: inherit;
  text-decoration: none !important;
  font-size: 0.88rem;
  transition: background 0.14s ease;
}

.vc-contact-item:hover {
  background: rgba(255, 255, 255, 0.2);
}

.vc-contact-text {
  word-break: break-word;
}

.vc-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.virtual-card.align-left .vc-actions-row {
  justify-content: flex-start;
}

.vc-chip-link {
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  backdrop-filter: blur(6px);
}

.vc-chip-link:hover {
  background: rgba(255, 255, 255, 0.24);
}

.vc-qr-section {
  display: flex;
  justify-content: center;
}

.vc-qr-box {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  padding: 14px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
}

.vc-qr-canvas {
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  max-width: 100%;
  height: auto;
}

.vc-qr-caption {
  margin: 8px 0 6px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #334155;
}

.vc-qr-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.vc-qr-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.vc-qr-btn:hover {
  background: #e2e8f0;
}

/* Modal Configuración Blob */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-dialog {
  width: 100%;
  max-width: 500px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-header h3 {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #065f46;
  color: #ecfdf5;
  border: 1px solid #10b981;
}

.toast-error {
  background: #7f1d1d;
  color: #fef2f2;
  border: 1px solid #ef4444;
}

/* Responsividad */
@media (max-width: 940px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .preview-sticky {
    position: static;
    max-width: 420px;
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 10px 14px;
  }

  .status-pill {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }

  .grid-2,
  .grid-wa,
  .blob-meta-strip {
    grid-template-columns: 1fr;
  }
}


/* Foto de perfil del usuario */
.vc-avatar-photo {
  padding: 0;
  overflow: hidden;
  width: 96px;
  height: 96px;
}

.vc-avatar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.avatar-thumb {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid var(--border-subtle);
}

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