/* ============================================================
   SIMY — AI Project Generator | Main Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Syne:wght@400;600;700;800&display=swap');

/* ---- CSS Variables ---------------------------------------- */
:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #18181f;
  --surface: #1e1e28;
  --surface2: #252530;
  --border: #2e2e3e;
  --border2: #3a3a4e;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --accent3: #22d3ee;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #5a5a72;
  --glow: 0 0 20px rgba(108,99,255,0.3);
  --glow2: 0 0 40px rgba(108,99,255,0.15);
  --radius: 14px;
  --radius-sm: 8px;
  --font-main: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg: #f0f0f8;
  --bg2: #e8e8f2;
  --bg3: #dddde8;
  --surface: #ffffff;
  --surface2: #f5f5fc;
  --border: #d0d0e0;
  --border2: #b8b8cc;
  --text: #1a1a2e;
  --text2: #4a4a6a;
  --text3: #8888aa;
  --glow: 0 0 20px rgba(108,99,255,0.15);
  --glow2: 0 0 40px rgba(108,99,255,0.08);
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ---- Layout ----------------------------------------------- */
.app-wrap {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---- Noise Overlay ---------------------------------------- */
.noise-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
}

/* ---- Header ----------------------------------------------- */
.app-header {
  padding: 20px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: var(--glow);
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 15px rgba(108,99,255,0.4); }
  50% { box-shadow: 0 0 30px rgba(108,99,255,0.7), 0 0 60px rgba(108,99,255,0.2); }
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent2), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}

.header-actions { display: flex; gap: 8px; }

.btn-icon {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: var(--transition);
  font-size: 15px;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--surface2); }

/* ---- Greeting --------------------------------------------- */
.greeting-section {
  padding: 28px 20px 0;
  position: relative; z-index: 10;
}

.greeting-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(108,99,255,0.12);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent2);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.greeting-badge .dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.2; } }

.greeting-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 6px;
}

.greeting-sub {
  font-size: 13px;
  color: var(--text2);
  font-family: var(--font-mono);
  line-height: 1.5;
}

/* ---- Prompt Section --------------------------------------- */
.prompt-section {
  padding: 20px 20px 0;
  position: relative; z-index: 10;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.prompt-card:focus-within {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.prompt-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.6;
  padding: 16px 16px 12px;
  resize: none;
  min-height: 100px;
}

.prompt-textarea::placeholder { color: var(--text3); }

.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.prompt-tools { display: flex; gap: 6px; }

.tool-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: var(--transition);
  font-family: var(--font-mono);
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn.active { background: rgba(108,99,255,0.15); border-color: var(--accent); color: var(--accent2); }

.upload-label {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: var(--transition);
  font-family: var(--font-mono);
}
.upload-label:hover { border-color: var(--accent3); color: var(--accent3); }
#file-upload { display: none; }

.btn-generate {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(108,99,255,0.3);
  white-space: nowrap;
}
.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(108,99,255,0.5);
}
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---- Config Section --------------------------------------- */
.config-section {
  padding: 16px 20px 0;
  position: relative; z-index: 10;
}

.config-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.config-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
}
.chip:hover { border-color: var(--border2); color: var(--text); }
.chip.selected {
  background: rgba(108,99,255,0.18);
  border-color: var(--accent);
  color: var(--accent2);
}

/* ---- Uploaded File Preview -------------------------------- */
.upload-preview {
  margin: 12px 20px 0;
  display: none;
  position: relative; z-index: 10;
}

.upload-preview.show { display: block; }

.upload-preview-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-thumb {
  width: 42px; height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.preview-info { flex: 1; min-width: 0; }
.preview-name { font-size: 13px; font-weight: 600; truncate: true; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-size { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

.preview-remove {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 16px; padding: 4px; transition: color var(--transition);
}
.preview-remove:hover { color: var(--red); }

/* ---- Output Section --------------------------------------- */
.output-section {
  padding: 20px 20px 0;
  flex: 1;
  position: relative; z-index: 10;
}

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

.output-title {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.output-actions { display: flex; gap: 6px; }

/* ---- Steps / Progress ------------------------------------- */
.steps-container {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.steps-container.show { display: flex; }

.step-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color var(--transition);
}

.step-item.active { border-color: var(--accent); }
.step-item.done { border-color: var(--green); opacity: 0.8; }
.step-item.error { border-color: var(--red); }

.step-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-item.waiting .step-icon { background: var(--surface2); color: var(--text3); }
.step-item.active .step-icon { background: rgba(108,99,255,0.2); color: var(--accent2); animation: spin 1s linear infinite; }
.step-item.done .step-icon { background: rgba(74,222,128,0.2); color: var(--green); }
.step-item.error .step-icon { background: rgba(248,113,113,0.2); color: var(--red); }

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

.step-info { flex: 1; }
.step-label { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.step-desc { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

/* ---- Code Blocks ------------------------------------------ */
.code-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent2);
  letter-spacing: 0.5px;
}

.code-copy {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 12px; font-family: var(--font-mono); display: flex; align-items: center; gap: 4px;
  transition: color var(--transition); padding: 2px 6px;
}
.code-copy:hover { color: var(--text); }

.code-content {
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text2);
  overflow-x: auto;
  white-space: pre;
  max-height: 300px;
  overflow-y: auto;
}

/* Syntax highlight classes */
.kw { color: #c792ea; }
.str { color: #c3e88d; }
.num { color: #f78c6c; }
.cmt { color: #546e7a; font-style: italic; }
.fn { color: #82aaff; }
.tag { color: #f07178; }
.atr { color: #ffcb6b; }

/* ---- File Tree -------------------------------------------- */
.file-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.file-tree-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  font-family: var(--font-mono);
}

.file-tree-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.file-tree-item:last-child { border-bottom: none; }
.file-tree-item:hover { background: var(--surface2); }
.file-tree-item.selected { background: rgba(108,99,255,0.1); color: var(--accent2); }

.file-icon { font-size: 14px; flex-shrink: 0; }
.file-indent { padding-left: 20px; }
.file-indent2 { padding-left: 36px; }
.file-size { margin-left: auto; color: var(--text3); font-size: 10px; }

/* ---- AI Message ------------------------------------------- */
.ai-message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
  position: relative;
  overflow: hidden;
}

.ai-message::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(to bottom, var(--accent), var(--accent3));
  border-radius: 99px;
}

.ai-message-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent2);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ---- Streaming Cursor ------------------------------------- */
.cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--accent2);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursor-blink 0.8s ease-in-out infinite;
}

@keyframes cursor-blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* ---- Action Buttons --------------------------------------- */
.action-row {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.btn {
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(108,99,255,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 25px rgba(108,99,255,0.5); transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border2); background: var(--surface2); }

.btn-outline {
  background: transparent;
  color: var(--accent2);
  border-color: var(--accent);
}
.btn-outline:hover { background: rgba(108,99,255,0.1); }

.btn-green {
  background: rgba(74,222,128,0.15);
  color: var(--green);
  border-color: rgba(74,222,128,0.3);
}
.btn-green:hover { background: rgba(74,222,128,0.25); }

/* ---- Toast ------------------------------------------------ */
.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 99px;
  padding: 10px 20px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}

.toast.success { border-color: rgba(74,222,128,0.4); color: var(--green); }
.toast.error { border-color: rgba(248,113,113,0.4); color: var(--red); }

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

/* ---- History Drawer --------------------------------------- */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(4px);
}

.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(360px, 90vw);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title { font-size: 16px; font-weight: 700; }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.history-item:hover { border-color: var(--accent); background: var(--surface2); }

.history-prompt { font-size: 13px; line-height: 1.4; margin-bottom: 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-meta { font-size: 10px; font-family: var(--font-mono); color: var(--text3); display: flex; gap: 10px; }

/* ---- Deploy Status ---------------------------------------- */
.deploy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: none;
}

.deploy-card.show { display: block; }

.deploy-url {
  display: flex; align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
}

.deploy-url-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deploy-copy {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 14px; padding: 2px 6px;
  transition: color var(--transition);
}
.deploy-copy:hover { color: var(--accent3); }

/* ---- Image Analysis Result -------------------------------- */
.analysis-card {
  background: linear-gradient(135deg, rgba(108,99,255,0.08), rgba(34,211,238,0.05));
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: none;
}

.analysis-card.show { display: block; }
.analysis-card-title { font-size: 11px; font-family: var(--font-mono); color: var(--accent2); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.analysis-card-text { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 480px) {
  .greeting-title { font-size: 22px; }
  .prompt-toolbar { flex-wrap: wrap; }
  .action-row { padding: 12px 16px; }
}

/* ---- Skeleton Loading ------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Floating Background Orbs ----------------------------- */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.08;
}

.orb-1 {
  width: 400px; height: 400px;
  background: var(--accent);
  top: -100px; right: -100px;
  animation: float1 8s ease-in-out infinite;
}

.orb-2 {
  width: 300px; height: 300px;
  background: var(--accent3);
  bottom: 100px; left: -80px;
  animation: float2 10s ease-in-out infinite;
}

@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-30px, 30px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(20px, -20px); } }

/* ---- Bottom Padding --------------------------------------- */
.bottom-pad { height: 40px; }
