/* Diseño profesional - tema oscuro inspirado en editores */
:root {
  --bg: #0f1115;
  --panel: #0b0c0f;
  --muted: #9aa3b2;
  --accent: #7dd3fc;
  --accent-2: #60a5fa;
  --success: #4ade80;
  --danger: #fb7185;
  --glass: rgba(255, 255, 255, 0.03);
  --card-shadow: 0 8px 20px rgba(2, 6, 23, 0.6);
  --radius: 12px;
  --mono: "Fira Code", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo,
    Monaco, monospace;
}

/* Tipografías básicas */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  background: linear-gradient(180deg, #071019 0%, #0b1020 100%);
  color: #e6eef3;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  backdrop-filter: blur(6px);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: var(--card-shadow);
}
.brand h1 {
  margin: 0;
  font-size: 18px;
}
.brand small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-wrap {
  width: 260px;
  height: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s ease;
}

.level-indicator {
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(13, 28, 48, 0.35);
}

.btn.primary {
  background: linear-gradient(90deg, #16202b, #0f1724);
  color: var(--accent);
  border: 1px solid rgba(125, 211, 252, 0.12);
}
.btn.success {
  background: linear-gradient(90deg, #052a0e, #062b11);
  color: var(--success);
  border: 1px solid rgba(74, 222, 128, 0.08);
}
.btn.secondary {
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.btn.help {
  background: linear-gradient(90deg, #2d1b69, #1e1b4b);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.12);
}

.app-grid {
  display: grid;
  grid-template-columns: 300px 1fr 420px;
  gap: 20px;
  padding: 22px;
  align-items: start;
}

/* Paneles */
.panel {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(255, 255, 255, 0.03);
  overflow: hidden;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}
.panel .panel-header {
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.panel .panel-body {
  padding: 16px;
  color: var(--muted);
  flex: 1;
}
.panel .scroll {
  overflow: auto;
}

/* Left */
.left .level-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  list-style: none;
}
.left .level-list li {
  padding: 6px 0;
  font-size: 14px;
}
.left .level-list .category-header {
  list-style: none;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}
.level-tags {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Center editor */
.center {
  padding: 0;
  display: flex;
  flex-direction: column;
}
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.editor-container {
  height: 420px;
  background: #0b0c0f;
}
.CodeMirror {
  height: 100%;
  font-family: var(--mono);
  font-size: 13px;
}

/* footer of editor */
.editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.02);
}
.message {
  font-weight: 700;
  color: var(--muted);
}
.spacer {
  flex: 1;
}

/* Right preview */
.preview-frame {
  padding: 14px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.015),
    rgba(255, 255, 255, 0.01)
  );
  min-height: 420px;
}
.preview-frame * {
  transition: all 0.15s ease;
}

/* nivel completado badge */
.badge {
  display: inline-block;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.08);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}

/* Responsive */
@media (max-width: 1100px) {
  .app-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .left,
  .right {
    order: 2;
    min-height: 260px;
  }
  .center {
    order: 1;
  }
  .preview-frame {
    min-height: 240px;
  }
}

/* small code look in preview to mimic editing */
.preview-frame pre {
  background: rgba(255, 255, 255, 0.02);
  padding: 8px;
  border-radius: 8px;
  overflow: auto;
  color: var(--muted);
}
.small {
  font-size: 12px;
  color: var(--muted);
}

/* progreso visual final */
.completed {
  animation: pop 0.6s ease forwards;
}
@keyframes pop {
  0% {
    transform: scale(0.96);
    opacity: 0.6;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
/* Panel de Ayuda */
.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.help-overlay.active {
  opacity: 1;
  visibility: visible;
}

.help-panel {
  position: fixed;
  top: 0;
  right: -600px;
  width: 600px;
  height: 100vh;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
  z-index: 999;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.help-panel.active {
  right: 0;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.help-header h2 {
  margin: 0;
  color: #e6eef3;
  font-size: 18px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #e6eef3;
}

.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.help-body {
  padding: 24px;
  line-height: 1.6;
}

.help-body h3 {
  color: var(--accent);
  margin: 24px 0 12px 0;
  font-size: 16px;
  border-bottom: 1px solid rgba(125, 211, 252, 0.2);
  padding-bottom: 8px;
}

.help-body h4 {
  color: #e6eef3;
  margin: 20px 0 8px 0;
  font-size: 14px;
}

.help-body p {
  color: var(--muted);
  margin: 12px 0;
  font-size: 14px;
}

.help-body code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
}

.help-body pre {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.help-body pre code {
  background: none;
  padding: 0;
  color: #e6eef3;
}

.help-body ul {
  margin: 12px 0;
  padding-left: 20px;
}

.help-body li {
  color: var(--muted);
  margin: 6px 0;
  font-size: 14px;
}

.help-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.help-section:last-child {
  border-bottom: none;
}

.help-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(125, 211, 252, 0.3);
  transition: all 0.2s ease;
}

.help-body a:hover {
  color: #e6eef3;
  border-bottom-color: var(--accent);
}

.help-example {
  background: rgba(74, 222, 128, 0.05);
  border: 1px solid rgba(74, 222, 128, 0.1);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.help-tip {
  background: rgba(167, 139, 250, 0.05);
  border: 1px solid rgba(167, 139, 250, 0.1);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.help-tip::before {
  content: "💡 ";
  font-size: 16px;
}

/* Responsive para panel de ayuda */
@media (max-width: 768px) {
  .help-panel {
    width: 100%;
    right: -100%;
  }
}

/* Footer Styles */
.footer {
  margin-top: 40px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius) var(--radius) 0 0;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  align-items: start;
}

/* Brand Section */
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-logo h3 {
  margin: 0;
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
}

.brand-logo p {
  margin: 4px 0 0 0;
  color: var(--muted);
  font-size: 14px;
}

.social-links {
  display: flex;
  gap: 12px;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s ease;
}

.social-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  transform: translateY(-2px);
}

.social-link.tiktok:hover {
  color: #ff0050;
  border-color: rgba(255, 0, 80, 0.2);
}

.social-icon {
  font-size: 16px;
}

/* Share Section */
.footer-share {
  background: rgba(74, 222, 128, 0.05);
  border: 1px solid rgba(74, 222, 128, 0.1);
  border-radius: 12px;
  padding: 20px;
}

.footer-share h4 {
  margin: 0 0 8px 0;
  color: var(--success);
  font-size: 16px;
}

.footer-share p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 14px;
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.share-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-btn.whatsapp:hover {
  background: rgba(37, 211, 102, 0.1);
  border-color: rgba(37, 211, 102, 0.3);
  color: #25d366;
}

.share-btn.facebook:hover {
  background: rgba(24, 119, 242, 0.1);
  border-color: rgba(24, 119, 242, 0.3);
  color: #1877f2;
}

.share-btn.twitter:hover {
  background: rgba(29, 161, 242, 0.1);
  border-color: rgba(29, 161, 242, 0.3);
  color: #1da1f2;
}

.share-btn.linkedin:hover {
  background: rgba(10, 102, 194, 0.1);
  border-color: rgba(10, 102, 194, 0.3);
  color: #0a66c2;
}

.share-btn.copy-link:hover {
  background: rgba(125, 211, 252, 0.1);
  border-color: rgba(125, 211, 252, 0.3);
  color: var(--accent);
}

.share-icon {
  font-size: 14px;
}

/* Donation Section */
.footer-donate h4 {
  margin: 0 0 8px 0;
  color: var(--accent);
  font-size: 16px;
}

.footer-donate p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 14px;
}

.donation-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.donation-details {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}

.alias {
  color: var(--accent);
  font-weight: 600;
  font-family: var(--mono);
}

.recipient {
  color: var(--muted);
}

.donation-reward {
  background: rgba(167, 139, 250, 0.05);
  border: 1px solid rgba(167, 139, 250, 0.1);
  border-radius: 8px;
  padding: 12px;
}

.reward-text {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.donate-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #8b5cf6, #a855f7);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  justify-content: center;
}

.donate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}

.donate-icon {
  font-size: 16px;
}

/* Footer Bottom */
.footer-bottom {
  grid-column: 1 / -1;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  margin-top: 12px;
}

.footer-bottom small {
  color: var(--muted);
  font-size: 12px;
}

/* Responsive Footer */
@media (max-width: 1024px) {
  .footer-content {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .footer-donate {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 24px 16px;
  }

  .share-buttons {
    justify-content: center;
  }

  .donation-info {
    align-items: center;
  }
}

/* Success animation for share section */
.footer-share.show {
  animation: slideInUp 0.6s ease forwards;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
