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

:root {
  --bg: #f1f3f4;
  --surface: #ffffff;
  --surface-dim: #f8f9fa;
  --border: #dadce0;
  --border-light: #e8eaed;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-hint: #80868b;
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --primary-dark: #1765cc;
  --error: #d93025;
  --error-bg: #fce8e6;
  --success: #1e8e3e;
  --success-bg: #e6f4ea;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 340px;
  --shadow-1: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-2: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  --shadow-3: 0 6px 10px 4px rgba(60, 64, 67, 0.15), 0 2px 3px rgba(60, 64, 67, 0.3);
}

body {
  font-family: 'Roboto', 'Google Sans Text', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.d-none { display: none !important; }

/* ── App Shell ───────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100vh;
  box-shadow: var(--shadow-1);
  z-index: 2;
}

.sidebar-header {
  padding: 24px 24px 16px;
}

.site-logo {
  margin-bottom: 12px;
}

.site-logo img {
  width: 180px;
  height: auto;
  display: block;
}

.header-divider {
  height: 1px;
  background: var(--border-light);
  margin-bottom: 12px;
}

.app-title {
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.app-sub {
  font-size: 13px;
  color: var(--text-hint);
  margin-top: 2px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Field Groups ────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

/* ── Upload Zone ─────────────────────────────────────── */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  background: var(--surface-dim);
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#uploadPlaceholder {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-hint);
  font-size: 13px;
  pointer-events: none;
}

#uploadPlaceholder i { font-size: 20px; color: var(--primary); }

#logoPreviewWrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#logoPreviewWrap img {
  max-height: 56px;
  max-width: 80%;
  object-fit: contain;
}

.remove-logo {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--text-secondary);
  border: none;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}

.remove-logo:hover { background: var(--error); }

/* ── Color Pickers ───────────────────────────────────── */
.color-row {
  display: flex;
  gap: 12px;
}

.color-pick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-dim);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.color-pick:hover { border-color: var(--border); }

.color-pick input[type="color"] {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

.color-pick input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-pick input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }

.color-pick span {
  font-size: 12px;
  color: var(--text-hint);
}

/* ── Language Pills ──────────────────────────────────── */
.lang-pills {
  display: flex;
  gap: 0;
  background: var(--surface-dim);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 3px;
}

.lang-pills input[type="radio"] { display: none; }

.lang-pills label {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  border-radius: 6px;
}

.lang-pills label:hover {
  background: var(--border-light);
}

.lang-pills input:checked + label {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(26, 115, 232, 0.3);
}

/* ── Text Fields ─────────────────────────────────────── */
.text-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.text-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-dim);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.text-field-tag {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-hint);
  white-space: nowrap;
  min-width: 62px;
}

.hero-tag { color: var(--primary); font-weight: 600; }

.text-field input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  padding: 10px 0;
  font-family: inherit;
}

.hero-input { font-weight: 500; }

/* ── Model Select ────────────────────────────────────── */
.model-select {
  width: 100%;
  background: var(--surface-dim);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2380868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.2s;
}

.model-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.model-select option { background: var(--surface); }

/* ── Sidebar Footer ──────────────────────────────────── */
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

.sidebar-footer button {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(26, 115, 232, 0.3);
}

.sidebar-footer button:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-1);
}

.sidebar-footer button:active { box-shadow: none; }

.sidebar-footer button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Canvas Area ─────────────────────────────────────── */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: auto;
  padding: 32px;
}

.state-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── Empty State ─────────────────────────────────────── */
.empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-hint);
  box-shadow: var(--shadow-1);
}

.empty-text {
  color: var(--text-hint);
  font-size: 14px;
}

/* ── Loader ──────────────────────────────────────────── */
.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-text {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Result ──────────────────────────────────────────── */
.result-frame {
  max-height: calc(100vh - 120px);
  overflow: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  background: var(--surface);
}

.result-frame img {
  display: block;
  max-width: 360px;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--success);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
  box-shadow: 0 1px 2px rgba(30, 142, 62, 0.3);
}

.download-btn:hover { background: #1a7f38; color: #fff; }

/* ── Error ───────────────────────────────────────────── */
.error-box {
  background: var(--error-bg);
  border: 1px solid #f5c6c2;
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--error);
  font-size: 13px;
  max-width: 400px;
}

.error-box i { font-size: 18px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    box-shadow: none;
  }

  .sidebar-scroll {
    max-height: none;
    overflow: visible;
  }

  .canvas-area {
    min-height: 60vh;
    padding: 20px;
  }

  body { overflow: auto; }
}
