:root {
  --bg-dark: #090d16;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --brand-orange: #ea580c;
  --brand-orange-light: #ff5a1f;
  --primary: #4f46e5;
  --accent: #06b6d4;
  --success: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Top SaaS Navigation Bar (Inspired by freeappmaker.ai + CreateApp Branding) */
.topbar {
  height: 66px;
  background: #fffaf5;
  color: #1c1917;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(234, 88, 12, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #1c1917;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ea580c, #ff5a1f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #1c1917;
}

.brand-title .orange {
  color: #ea580c;
}

.saas-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.saas-nav-link {
  color: #44403c;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}

.saas-nav-link:hover {
  color: #ea580c;
}

/* Convert Dropdown Menu (Exact Red-Circled Feature!) */
.convert-dropdown-wrap {
  position: relative;
}

.convert-trigger {
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: #c2410c;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.convert-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 295px;
  max-height: 410px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e7e5e4;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
  padding: 8px;
  display: none;
  z-index: 200;
}

.convert-dropdown-wrap:hover .convert-dropdown-menu,
.convert-dropdown-menu.open {
  display: block;
}

.convert-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: #1c1917;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}

.convert-menu-item:hover {
  background: #fff7ed;
}

.convert-menu-item strong {
  font-weight: 700;
  color: #1c1917;
}

.convert-menu-item span {
  color: #78716c;
  font-size: 12px;
}

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

.telemetry-pill {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #047857;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 9px;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-convert {
  background: linear-gradient(135deg, #ea580c 0%, #ff5a1f 100%);
  color: #ffffff;
  padding: 10px 22px;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35);
}

.btn-convert:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.5);
}

/* Warm SaaS Hero Strip (freeappmaker.ai style) */
.hero-banner {
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: #1c1917;
  padding: 16px 28px;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-pill {
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: #ea580c;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.hero-headline {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #1c1917;
}

.hero-headline .accent-orange {
  color: #ea580c;
}

.hero-platform-checks {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #fdba74;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #292524;
}

.hero-platform-checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* Main Workspace Layout */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 230px 1fr 470px;
  min-height: calc(100vh - 130px);
}

/* Left Service Navigation Sidebar */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 6px 10px;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  transition: all 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-item.active {
  background: rgba(234, 88, 12, 0.18);
  border-color: rgba(251, 146, 60, 0.5);
  color: #fff;
}

.sidebar-footer {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Center Configuration Editor */
.editor-pane {
  padding: 20px 24px;
  overflow-y: auto;
  background: #0b1120;
}

.tab-panel {
  display: none;
  max-width: 760px;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}

.panel-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

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

.input, select.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.input:focus {
  border-color: #f97316;
}

.url-bar-row {
  display: flex;
  gap: 8px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.preset-chip {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fdba74;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
}

.preset-chip:hover {
  background: #334155;
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-info strong {
  display: block;
  font-size: 13px;
  color: #f1f5f9;
}

.toggle-info span {
  font-size: 11.5px;
  color: var(--text-muted);
}

.switch {
  position: relative;
  width: 42px;
  height: 22px;
  display: inline-block;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #334155;
  transition: 0.2s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #ea580c;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Right Live Simulator & Output Console */
.preview-pane {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
}

.device-switcher {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.dev-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 4px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.dev-btn.active {
  background: #ea580c;
  color: #fff;
}

/* True-Viewport Auto-Scaling Stage (412x860 Real Phone Viewport!) */
.simulator-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  overflow: hidden;
  position: relative;
}

.sim-scale-box {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.device-frame {
  background: #0f172a;
  border: 10px solid #334155;
  border-radius: 38px;
  width: 432px;
  height: 860px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.65);
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
}

.device-frame.mode-tablet {
  width: 820px;
  height: 980px;
  border-radius: 26px;
}

.device-frame.mode-windows {
  width: 960px;
  height: 600px;
  border-radius: 12px;
  border-width: 4px;
  border-color: #475569;
}

.sim-statusbar {
  height: 28px;
  background: #4f46e5;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.sim-appbar {
  height: 46px;
  background: #4f46e5;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.sim-body-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: #fff;
  position: relative;
}

.sim-tablet-rail {
  display: none;
  width: 150px;
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 8px;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid #334155;
  flex-shrink: 0;
}

.device-frame.mode-tablet .sim-tablet-rail {
  display: flex;
}

.rail-item {
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.sim-webview {
  border: none;
  width: calc(100% + 17px);
  height: 100%;
  background: #ffffff;
  flex-shrink: 0;
}

.sim-bottomnav {
  height: 56px;
  background: #0f172a;
  border-top: 1px solid #334155;
  display: none;
  align-items: center;
  justify-content: space-around;
  color: #cbd5e1;
  font-size: 12px;
  flex-shrink: 0;
}

.device-frame.mode-tablet .sim-bottomnav {
  display: none !important;
}

.sim-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: #94a3b8;
  font-weight: 600;
}

.sim-tab-btn.active {
  color: #38bdf8;
}

.splash-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #ea580c, #4f46e5);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 20;
}

.splash-overlay.show {
  display: flex;
}

/* Output Result Card */
.build-result-box {
  background: #0f172a;
  border: 1px solid #10b981;
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
  display: none;
  flex-shrink: 0;
}

.build-result-box.show {
  display: block;
}

.dl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.dl-link {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  text-decoration: none;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dl-link:hover {
  background: #334155;
  border-color: #38bdf8;
}

.service-badge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.service-item {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.service-item strong {
  display: block;
  color: #fb923c;
  margin-bottom: 3px;
}

/* Mobile & Tablet Responsive Layout */
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar > div {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  .nav-group-label, .sidebar-footer {
    display: none;
  }
  .nav-item {
    white-space: nowrap;
    margin-bottom: 0;
  }
  .saas-nav {
    gap: 10px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
