/* Style It Workflow (mobile-first bottom sheet) */

/* Animations for smooth transitions */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

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

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

@keyframes toastDrop {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(24px); }
}
/* Backdrop behind the Style It drawer */
.style-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 10060;
}
.style-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.style-sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 96vh; background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.2); transform: translateY(110%); transition: transform .25s ease; z-index: 10070; display:flex; flex-direction:column; }
.style-sheet.open { transform: translateY(0); }
.style-head { display:grid; grid-template-columns:auto 1fr auto; align-items:center; padding:12px 16px; border-bottom:1px solid #eee; column-gap:12px; }
.style-title { font-weight:800; }
.style-head-middle { display:flex; justify-content:center; }
.style-magic {
  background: #f8fafc;
  color: #1f2937;
  border: 2px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 20px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.style-magic:hover {
  background: #eff3f9;
  border-color: #d7dce3;
  box-shadow: none;
}
.style-magic:active {
  background: #e7ecf5;
  border-color: #cbd2dc;
  box-shadow: none;
}
.style-close { border:none; background:#f3f4f6; border-radius:8px; padding:6px 12px; cursor:pointer; font-weight:600; }
.style-body { padding:12px 16px; overflow:auto; display:grid; gap:12px; }
/* Hide scrollbars (still scrollable on overflow) */
.style-body { -ms-overflow-style: none; scrollbar-width: none; }
.style-body::-webkit-scrollbar { width: 0; height: 0; display: none; }
.style-row { display:flex; gap:10px; flex-wrap:wrap; }
.style-chips-wrap { position: relative; }
.style-chips-wrap.collapsed #style-chips { overflow: hidden; }
.style-chips-fade { display:none; position:absolute; left:0; right:0; height:28px; pointer-events:none; background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 70%); }
.style-chips-wrap.collapsed .style-chips-fade { display:block; bottom:36px; }
.style-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 2px solid #e5e7eb;
  background: #fff;
  border-radius: 18px;
  padding: 5px 14px;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.style-chip { padding:8px 12px; border:2px solid #e5e7eb; border-radius:9999px; cursor:pointer; font-weight:700; background:#f8fafc; }
.style-chip.active { background:#111827; color:#fff; border-color:#111827; }
.style-chip.magic-selected {
  position:relative;
  animation: magicPulse .8s ease-in-out 2;
}
@keyframes magicPulse {
  0% { box-shadow:0 0 0 0 rgba(102,126,234,0.55); transform: scale(1); }
  50% { box-shadow:0 0 0 8px rgba(102,126,234,0); transform: scale(1.04); }
  100% { box-shadow:0 0 0 0 rgba(102,126,234,0); transform: scale(1); }
}
.style-prompt { display:flex; flex-direction:column; gap:6px; }
.style-prompt textarea { width:100%; min-height:84px; padding:10px 12px; border:2px solid #e5e7eb; border-radius:10px; font-size:.95rem; resize:vertical; }
.style-prompt.collapsed textarea { display:none; }
.style-prompt-header { display:flex; align-items:center; justify-content:flex-end; gap:8px; }
.style-prompt-spacer { flex:1; }
.style-prompt-toggle {
  border:1px solid #e5e7eb;
  background:rgba(255,255,255,0.6);
  color:#64748b;
  border-radius:20px;
  padding:4px 12px;
  font-weight:600;
  font-size:11.5px;
  cursor:pointer;
  transition: background .15s ease, box-shadow .15s ease, color .15s ease, border-color .15s ease;
}
.style-prompt-toggle:hover {
  background:#f8fafc;
  border-color:#d4d7dc;
}
.style-prompt-toggle.active {
  background:#eef2ff;
  color:#374151;
  border-color:#c7cffc;
  box-shadow:0 4px 12px rgba(102,126,234,0.18);
}
.style-prompt-toggle:hover { background:#e5e7eb; }
.style-preview {
  display:flex;
  flex-direction: row;
  align-items: stretch;
  gap:12px;
}
.style-preview .style-img-wrap {
  flex:1 1 0;
  min-width:0;
  min-height:260px;
}
.style-preview img { width:100%; border-radius:10px; object-fit:contain; background:#fff; }
.style-img-wrap { position: relative; min-height: 260px; display:flex; align-items:center; justify-content:center; background:#fafafa; border-radius:10px; border:1px solid rgba(0,0,0,.08); overflow:visible; }
.style-enlarge-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: #ffffff;
  background-color: #ffffff;
  color: #1f2937;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  z-index: 3;
  color-scheme: light;
}
.style-enlarge-btn:hover {
  background: #fff;
  border-color: rgba(148, 163, 184, 0.8);
  color: #111827;
}
.style-enlarge-btn span { pointer-events: none; line-height: 1; }
.style-anim-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:#fff; }
.style-img-wrap img { border: none; max-width: 100%; max-height: 100%; }
#style-wrap-b img { border: none; }
/* Hide the generated img element when it has no src to prevent broken icon */
.style-img-wrap img:not([src]), .style-img-wrap img[src=""] { display: none; }
#style-wrap-b img { border: none; }
.style-ref-strip {
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:14px;
  flex-wrap:wrap;
}
.style-ref-strip::-webkit-scrollbar { display:none; }
.style-ref-add,
.style-ref-manage {
  border-radius:12px;
  padding:8px 14px;
  font-weight:700;
  cursor:pointer;
  white-space:nowrap;
  transition: transform .15s ease, box-shadow .15s ease;
}
.style-ref-add {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #f8fafc;
  color: #334155;
  box-shadow: none;
}
.style-ref-add:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.55);
}
.style-ref-add:active {
  transform: translateY(0);
  background: #eef2ff;
  border-color: rgba(129, 140, 248, 0.45);
}
.style-ref-manage {
  border:1px solid rgba(148,163,184,0.4);
  background:#f8fafc;
  color:#1f2937;
}
.style-ref-thumb {
  width:48px;
  height:48px;
  border-radius:12px;
  border:2px solid transparent;
  background:#f1f5f9;
  display:grid;
  place-items:center;
  position:relative;
  cursor:pointer;
  padding:0;
}
.style-ref-thumb img {
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:10px;
}
.style-ref-thumb.active { border-color:#4c51bf; box-shadow:0 4px 12px rgba(76,81,191,0.25); }
.style-ref-check {
  position:absolute;
  bottom:-6px;
  right:-6px;
  width:20px;
  height:20px;
  border-radius:50%;
  background:#4c51bf;
  color:#fff;
  display:grid;
  place-items:center;
  font-size:12px;
  font-weight:800;
}
.style-ref-thumb.manage .style-ref-check { display:none; }
.style-ref-thumb.manage .style-ref-remove {
  display:grid;
}
.style-ref-remove {
  position:absolute;
  top:-8px;
  right:-8px;
  width:20px;
  height:20px;
  border-radius:50%;
  background:#ef4444;
  color:#fff;
  font-size:12px;
  font-weight:800;
  display:none;
  place-items:center;
}
.style-placeholder { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; flex-direction:column; color:#9aa0b4; font-weight:700; gap:6px; border:2px dashed #e5e7eb; border-radius:10px; margin:8px; pointer-events:none; }
.style-upload-hint { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:#6b7280; font-weight:800; border:2px dashed #e5e7eb; border-radius:10px; margin:8px; pointer-events:none; }
.style-clear-btn { position:absolute; top:8px; right:8px; background:rgba(255,255,255,.95); border:2px solid rgba(0,0,0,.12); border-radius:12px; width:34px; height:34px; display:grid; place-items:center; font-weight:900; cursor:pointer; z-index:1000; box-shadow:0 6px 14px rgba(0,0,0,.18); color:#111; }
.style-clear-btn:hover { transform: translateY(-1px); }
.style-replace-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  background: #ffffff;
  background-color: #ffffff;
  color: #1f2937;
  border: 1px solid rgba(148, 163, 184, 0.55);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  color-scheme: light;
}
.style-replace-btn:hover {
  background: #fff;
  border-color: rgba(148, 163, 184, 0.8);
  color: #111827;
}
.style-replace-btn:active {
  background: #eef2ff;
  border-color: rgba(129, 140, 248, 0.6);
}

/* Full-screen viewer for generated image */
.style-viewer { position: fixed; inset: 0; background: rgba(17,24,39,.85); display: none; align-items: center; justify-content: center; z-index: 10100; }
.style-viewer.open { display: flex; }
.style-viewer img { max-width: 94vw; max-height: 94vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.style-viewer-close { position:absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 12px; background: #fff; border: 2px solid rgba(0,0,0,.15); display:grid; place-items:center; font-weight: 900; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.style-reset-btn { position:absolute; bottom:10px; left:10px; background:#fff; border:1.5px solid #e5e7eb; border-radius:10px; padding:6px 8px; font-weight:800; cursor:pointer; z-index:2; box-shadow:0 2px 8px rgba(0,0,0,.06); }
.style-img-wrap { position: relative; min-height: 220px; display:flex; align-items:center; justify-content:center; background:#fafafa; border-radius:10px; border:1px solid rgba(0,0,0,.08); overflow:visible; }
.style-anim-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:#fff; }
#style-wrap-b img { border: none; }
.style-foot { padding:12px 16px; border-top:1px solid #eee; display:grid; gap:8px; grid-template-columns: 1fr 1fr; position: relative; z-index: 10; }
.style-btn { height:44px; border:none; border-radius:10px; font-weight:800; cursor:pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; pointer-events: auto; position: relative; z-index: 11; transition: filter .15s ease, opacity .15s ease, transform .15s ease; }
.style-btn.primary { background: linear-gradient(135deg, #667eea, #764ba2); color:#fff; }
.style-btn.secondary { background:#f3f4f6; }
.style-btn.primary.is-loading,
.style-btn.primary[disabled] {
  background: linear-gradient(135deg, #d1d5db, #9ca3af);
  color: #1f2937;
  opacity: 0.85;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
  filter: grayscale(0.4);
}
.style-btn.secondary.is-loading,
.style-btn.secondary[disabled] { background:#e5e7eb; color:#9ca3af; cursor: default; pointer-events: none; }
.style-status { font-size:.9rem; color:#555; padding: 0 16px 8px; }

/* Washing animation cloned from unified UI (trimmed) */
.washing-machine-container { display:flex; flex-direction:column; align-items:center; padding:12px; }
.washing-machine { width:160px; height:160px; background: linear-gradient(145deg,#e6e6e6,#fff); border-radius:18px; box-shadow:0 8px 22px rgba(0,0,0,.18); display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden; }
.washing-drum { width:130px; height:130px; background: radial-gradient(circle,#f0f0f0 30%, #d0d0d0 70%); border-radius:50%; display:flex; align-items:center; justify-content:center; position:relative; box-shadow: inset 0 0 24px rgba(0,0,0,.25); overflow:hidden; }
.washing-content { width:100px; height:100px; border-radius:10px; object-fit:cover; animation: spin-wash 2s linear infinite; filter: blur(1px); }
@keyframes spin-wash { 0%{transform:rotate(0) scale(.92);filter:blur(1px)} 25%{transform:rotate(90deg) scale(.86);filter:blur(2px)} 50%{transform:rotate(180deg) scale(.92);filter:blur(1px)} 75%{transform:rotate(270deg) scale(.86);filter:blur(2px)} 100%{transform:rotate(360deg) scale(.92);filter:blur(1px)} }
.water-effect { position:absolute; bottom:0; width:100%; height:50%; background: linear-gradient(to top, rgba(100,150,200,.3) 0%, transparent 100%); animation: water-wave 3s ease-in-out infinite; }
@keyframes water-wave { 0%,100%{ transform:translateY(4px); opacity:.3 } 50%{ transform:translateY(-4px); opacity:.5 } }
.bubble { position:absolute; background: radial-gradient(circle, rgba(255,255,255,.8), transparent); border-radius:50%; animation: bubble-up 4s ease-in-out infinite; }
.bubble:nth-child(1){ width:18px; height:18px; left:20%; animation-delay:0s }
.bubble:nth-child(2){ width:14px; height:14px; left:50%; animation-delay:.8s }
.bubble:nth-child(3){ width:22px; height:22px; left:70%; animation-delay:1.6s }
@keyframes bubble-up { 0%{ bottom:10px; opacity:0 } 20%{ opacity:.8 } 80%{ opacity:.8 } 100%{ bottom:80%; opacity:0 } }
.washing-status { margin-top:10px; font-size:.95rem; color:#667eea; font-weight:600; text-align:center; }
.washing-complete { animation: complete-glow .5s ease; }
@keyframes complete-glow { 0%{ transform:scale(1)} 50%{ transform:scale(1.05); box-shadow:0 0 18px rgba(102,126,234,.45)} 100%{ transform:scale(1)} }

/* Toast animations */
@keyframes slideUp {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(100px); opacity: 0; }
}

/* Desktop: side panel */
@media (min-width: 900px) {
  .style-sheet {
    right: max(20px, calc((100vw - min(1400px, calc(100vw - 24px))) / 2));
    left: auto;
    width: 420px;
    top: 80px;
    bottom: 20px;
    border-radius: 16px;
  }
}

@media (max-width: 640px) {
  .style-preview { gap: 10px; }
  .style-preview .style-img-wrap { min-height: 210px; }
  .style-replace-btn {
    top: -12px;
    right: -4px;
    background: #ffffff;
    background-color: #ffffff;
    color: #1f2937;
    border: 1px solid rgba(148, 163, 184, 0.55);
    box-shadow: none;
  }
  .style-ref-strip {
    overflow-x:auto;
    padding-bottom:4px;
  }
  .style-ref-thumb {
    width:44px;
    height:44px;
  }
}
