/* =========================================================
   MeColoreo v2.0 — UI estilo app, full-width, tablet-first
   ========================================================= */

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

.mc-app {
  --mc-bg: #fdfbff;
  --mc-surface: #ffffff;
  --mc-text: #1a1530;
  --mc-muted: #6b6585;
  --mc-primary: #7c3aed;
  --mc-primary-700: #6d28d9;
  --mc-accent: #ec4899;
  --mc-border: #e6e1f5;
  --mc-radius: 18px;
  --mc-shadow: 0 4px 20px rgba(124, 58, 237, .08);

  position: relative;
  width: 100%;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, #f3e8ff 0%, transparent 50%),
    radial-gradient(900px 500px at 110% 20%, #fce7f3 0%, transparent 50%),
    var(--mc-bg);
  color: var(--mc-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* Si está dentro del contenido de un theme, cancelamos el contenedor estrecho */
.mc-app { margin: 0 calc(50% - 50vw); }

/* ---------- Header ---------- */
.mc-app__header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--mc-border);
}
.mc-app__header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.mc-brand { display:flex; align-items:center; gap:10px; font-weight:700; }
.mc-brand__dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-accent));
}
.mc-brand__name { font-size: 1.05rem; letter-spacing: -.01em; }

.mc-nav { display:flex; align-items:center; gap: 8px; }
.mc-nav__link {
  color: var(--mc-text); text-decoration: none; padding: 8px 12px; border-radius: 10px;
}
.mc-nav__link:hover { background: #f5efff; }
.mc-nav__btn {
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-accent));
  color: #fff; text-decoration: none;
  padding: 9px 16px; border-radius: 12px; font-weight: 600;
}

/* ---------- Stepper ---------- */
.mc-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 1200px; margin: 18px auto 0;
  padding: 0 20px;
  gap: 8px;
}
.mc-step {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; border: 1px solid var(--mc-border);
  padding: 12px 14px; border-radius: 14px;
  font-weight: 600; color: var(--mc-muted);
  cursor: pointer;
}
.mc-step__n {
  width: 26px; height: 26px; border-radius: 50%;
  background: #f1ebff; color: var(--mc-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700;
}
.mc-step.is-active { border-color: var(--mc-primary); color: var(--mc-text); box-shadow: var(--mc-shadow); }
.mc-step.is-active .mc-step__n { background: var(--mc-primary); color: #fff; }
.mc-step.is-done .mc-step__n { background: #d8f5e1; color: #15803d; }

/* ---------- Main ---------- */
.mc-main {
  max-width: 1200px;
  margin: 18px auto 60px;
  padding: 0 20px;
}
.mc-title {
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 800; letter-spacing: -.02em;
  margin: 14px 0 22px;
}

.mc-form { display: flex; flex-direction: column; gap: 20px; }
.mc-panel {
  background: var(--mc-surface); border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius); padding: 24px; box-shadow: var(--mc-shadow);
}
.mc-panel.hidden, .hidden { display: none !important; }

.mc-help { color: var(--mc-muted); margin: 0 0 14px; }

/* ---------- Drop area ---------- */
.mc-drop {
  border: 2px dashed #c4b5fd; background: #faf7ff;
  border-radius: 16px; padding: 32px;
  text-align: center; cursor: pointer; transition: all .2s;
  min-height: 240px;
  display: flex; align-items: center; justify-content: center;
}
.mc-drop.is-over { background: #f3e8ff; border-color: var(--mc-primary); }
.mc-drop__icon { width: 56px; height: 56px; color: var(--mc-primary); margin: 0 auto 10px; }
.mc-drop__title { font-size: 1.15rem; font-weight: 600; margin: 0 0 4px; }
.mc-drop__hint { color: var(--mc-muted); margin: 0 0 14px; }
.mc-drop__preview { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mc-drop__preview img {
  max-height: 280px; max-width: 100%; border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
}

/* ---------- Form field ---------- */
.mc-field { display: block; margin-top: 22px; }
.mc-field__label { display: block; font-weight: 600; margin-bottom: 8px; }
.mc-field__label em { color: var(--mc-muted); font-style: normal; font-weight: 400; }
.mc-field input[type="text"] {
  width: 100%; padding: 14px 16px; border: 2px solid var(--mc-border);
  border-radius: 12px; font-size: 1rem; background: #fff; color: var(--mc-text);
  transition: border-color .15s;
}
.mc-field input[type="text"]:focus {
  outline: none; border-color: var(--mc-primary);
  box-shadow: 0 0 0 4px rgba(124,58,237,.12);
}

/* ---------- Cards (style/theme pickers) ---------- */
.mc-cards {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.mc-card {
  position: relative; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px; padding: 16px 12px;
  background: #fff; border: 2px solid var(--mc-border); border-radius: 16px;
  cursor: pointer; transition: all .15s;
  min-height: 168px;
}
.mc-card:hover { border-color: #c4b5fd; transform: translateY(-2px); }
.mc-card input { position: absolute; opacity: 0; pointer-events: none; }
.mc-card.is-selected {
  border-color: var(--mc-primary);
  background: #faf5ff; box-shadow: 0 4px 14px rgba(124,58,237,.18);
}
.mc-card.is-selected::after {
  content: "✓"; position: absolute; top: 8px; right: 10px;
  background: var(--mc-primary); color: #fff; width: 22px; height: 22px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
}
.mc-card__thumb {
  width: 88px; height: 88px; display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--mc-border); border-radius: 14px;
}
.mc-card__thumb svg { width: 70px; height: 70px; }
.mc-card__title { font-weight: 600; font-size: .95rem; }
.mc-card__desc { color: var(--mc-muted); font-size: .8rem; }

/* ---------- Actions / buttons ---------- */
.mc-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 22px;
}
.mc-actions--end { justify-content: flex-end; }

.mc-btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: 12px; font-size: 1rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .12s, box-shadow .12s, background .12s, color .12s;
  min-height: 48px;
}
.mc-btn:disabled { opacity: .5; cursor: not-allowed; }
.mc-btn--sm { padding: 8px 12px; font-size: .85rem; min-height: 36px; border-radius: 10px; }
.mc-btn--primary {
  background: var(--mc-primary); color: #fff;
}
.mc-btn--primary:hover:not(:disabled) { background: var(--mc-primary-700); }
.mc-btn--cta {
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-accent));
  color: #fff; box-shadow: 0 6px 20px rgba(236,72,153,.28);
}
.mc-btn--cta:hover:not(:disabled) { transform: translateY(-1px); }
.mc-btn--ghost {
  background: #fff; color: var(--mc-text); border-color: var(--mc-border);
}
.mc-btn--ghost:hover { background: #f6f1ff; }

/* ---------- Summary (step 4) ---------- */
.mc-summary {
  display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start;
}
.mc-summary__img img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.mc-summary__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mc-summary__list li { padding: 12px 14px; background: #faf7ff; border-radius: 10px; }

/* ---------- States: loading / result / error ---------- */
.mc-state {
  background: var(--mc-surface); border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius); padding: 36px; text-align: center;
  box-shadow: var(--mc-shadow);
}
.mc-state__title { font-size: 1.4rem; font-weight: 700; margin: 6px 0 6px; }
.mc-state__hint { color: var(--mc-muted); }

.mc-spinner {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 5px solid #ede9fe;
  border-top-color: var(--mc-primary);
  animation: mc-spin 1s linear infinite;
}
@keyframes mc-spin { to { transform: rotate(360deg); } }

.mc-result__image { margin: 18px auto; max-width: 640px; }
.mc-result__image img { width: 100%; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.12); }
.mc-result__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.mc-cta-card {
  margin-top: 20px;
  background: linear-gradient(135deg, #faf5ff, #fdf2f8);
  border: 1px solid #f0e7ff; border-radius: 14px;
  padding: 20px; text-align: center;
}
.mc-cta-card p { margin: 0 0 12px; }

.mc-error { background: #fff5f5; border-color: #fecaca; color: #991b1b; }

/* ---------- Library ---------- */
.mc-empty { text-align: center; padding: 60px 20px; color: var(--mc-muted); }
.mc-gallery {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.mc-tile {
  background: #fff; border: 1px solid var(--mc-border);
  border-radius: 16px; overflow: hidden; box-shadow: var(--mc-shadow);
  display: flex; flex-direction: column;
}
.mc-tile__img { display: block; aspect-ratio: 1; background: #faf7ff; }
.mc-tile__img img { width: 100%; height: 100%; object-fit: cover; }
.mc-tile__body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.mc-tile__title { margin: 0; font-size: .95rem; font-weight: 600; }
.mc-tile__date { margin: 0; color: var(--mc-muted); font-size: .8rem; }
.mc-tile__actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Painter ---------- */
.mc-app--painter .mc-painter {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px; max-width: 1400px; margin: 18px auto;
  padding: 0 20px; min-height: calc(100vh - 120px);
}
.mc-painter__toolbar {
  background: #fff; border: 1px solid var(--mc-border); border-radius: var(--mc-radius);
  padding: 18px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 80px; align-self: start;
  box-shadow: var(--mc-shadow);
}
.mc-tool-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mc-tool {
  width: 48px; height: 48px; border-radius: 12px;
  border: 1px solid var(--mc-border); background: #fff;
  font-size: 1.3rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.mc-tool:hover { background: #f6f1ff; }
.mc-tool.is-active { background: var(--mc-primary); color: #fff; border-color: var(--mc-primary); }

.mc-range { display: flex; flex-direction: column; gap: 6px; width: 100%; font-size: .85rem; color: var(--mc-muted); }
.mc-range input { width: 100%; }

.mc-palette {
  display: grid; gap: 6px;
  grid-template-columns: repeat(8, 1fr);
}
.mc-swatch {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--mc-border);
  cursor: pointer; padding: 0;
}
.mc-swatch.is-active { outline: 3px solid var(--mc-primary); outline-offset: 2px; }
.mc-swatch--custom { padding: 0; }

.mc-painter__stage {
  background: #fafafa;
  background-image:
    linear-gradient(45deg, #f0eafa 25%, transparent 25%),
    linear-gradient(-45deg, #f0eafa 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0eafa 75%),
    linear-gradient(-45deg, transparent 75%, #f0eafa 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius);
  box-shadow: var(--mc-shadow);
  overflow: hidden; position: relative;
  min-height: 500px;
}
.mc-canvas-wrap {
  position: absolute; top: 0; left: 0;
  line-height: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.mc-canvas-wrap canvas {
  display: block; touch-action: none;
  background: transparent;
}
.mc-canvas-wrap canvas[data-paint-canvas] {
  background: #fff;
  cursor: crosshair;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
}
.mc-canvas-wrap canvas[data-line-canvas],
.mc-canvas-wrap canvas[data-numbers-canvas] {
  position: absolute; inset: 0; pointer-events: none;
}

.mc-mode-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 10px; cursor: pointer;
  background: #faf5ff; border: 1px solid var(--mc-border);
  font-size: .9rem; font-weight: 600; user-select: none;
}
.mc-mode-toggle input { accent-color: var(--mc-primary); }

.mc-swatch.is-on { outline: 3px solid #15803d; }
.mc-btn.is-on { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }

.mc-numbers-legend {
  grid-column: 1 / -1;
  background: #fff; border: 1px solid var(--mc-border); border-radius: var(--mc-radius);
  padding: 14px 18px; margin-top: 12px;
}
.mc-numbers-legend__title { margin: 0 0 10px; font-size: .9rem; color: var(--mc-muted); }
.mc-numbers-legend__items { display: flex; flex-wrap: wrap; gap: 10px; }
.mc-numbers-legend__item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: #faf7ff; border-radius: 999px;
  font-weight: 700; font-size: .9rem;
}
.mc-numbers-legend__item i {
  width: 14px; height: 14px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(0,0,0,.1);
}

/* ---------- Responsive: tablet & móvil ---------- */
@media (max-width: 900px) {
  .mc-stepper { grid-template-columns: repeat(4, 1fr); }
  .mc-step__label { display: none; }
  .mc-step { padding: 10px; }
  .mc-summary { grid-template-columns: 1fr; }
  .mc-app--painter .mc-painter { grid-template-columns: 1fr; }
  .mc-painter__toolbar { position: static; flex-direction: row; flex-wrap: wrap; }
  .mc-palette { grid-template-columns: repeat(8, minmax(36px, 1fr)); }
}
@media (max-width: 560px) {
  .mc-app__header-inner { padding: 12px 14px; }
  .mc-main { padding: 0 14px; }
  .mc-panel { padding: 18px; }
  .mc-card { min-height: 150px; }
  .mc-card__thumb { width: 72px; height: 72px; }
  .mc-card__thumb svg { width: 56px; height: 56px; }
  .mc-result__actions .mc-btn { flex: 1 1 100%; }
}

/* Inputs accesibles en iOS (sin zoom al enfocar) */
.mc-app input, .mc-app select, .mc-app textarea { font-size: 16px; }
