/* ========== Global layout ========== */

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f5;
  color: #222;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid #ddd;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .logo {
  height: 32px;
  width: auto;
}

header .actions a {
  margin-left: 10px;
  font-size: 14px;
  color: #333;
  text-decoration: none;
}

header .actions a:hover {
  text-decoration: underline;
}

/* Non-grid pages */
body > main:not(.workspace) {
  max-width: 960px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

/* ========== Cards & forms ========== */

.form-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.form-card h1 {
  margin-top: 0;
  font-size: 22px;
  margin-bottom: 12px;
}

.form-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
}

.form-card label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  gap: 4px;
}

.form-card label.radio-inline {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"] {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 14px;
}

.form-card input[type="text"]:focus,
.form-card input[type="email"]:focus,
.form-card input[type="password"]:focus {
  outline: none;
  border-color: #0074d9;
  box-shadow: 0 0 0 1px rgba(0, 116, 217, 0.2);
}

/* Buttons */

.btn-primary {
  background: #0074d9;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary:hover {
  background: #005fa8;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #e2e2e2;
}

/* Error messages */

.form-errors {
  background: #fee;
  border: 1px solid #f5a3a3;
  color: #a40000;
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 13px;
}

/* Helper text */

.helper-text {
  font-size: 14px;
  color: #555;
  margin-top: 0;
  margin-bottom: 4px;
}

/* ========== Landing page (index) ========== */

.landing-content {
  text-align: center;
}

.landing-title {
  font-size: 28px;
  margin-bottom: 8px;
}

.landing-tagline {
  font-size: 15px;
  color: #444;
  margin: 8px 0 16px;
}

.landing-features {
  list-style: disc;
  text-align: left;
  max-width: 480px;
  margin: 0 auto 16px;
  padding-left: 20px;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

/* Hero logo on landing */

.hero-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border-radius: 0;
  margin-bottom: 12px;
}

.hero-logo {
  max-width: 220px;
  height: auto;
  display: block;
}

/* ========== Grid workspace layout ========== */

main.workspace {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Builder header (full-width, centered) ===== */

.builder-header {
  background: #ffffff;
  padding: 18px 20px;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-align: center;
}

.builder-header h1 {
  margin: 0 0 6px 0;
  font-size: 28px;
  font-weight: 700;
}

.builder-subtext {
  margin: 4px 0;
  font-size: 14px;
  color: #555;
}

/* Centered layout + export format row */
.builder-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.builder-controls-row label {
  font-size: 14px;
}

/* ===== Two-column body ===== */

.workspace-body {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* Left column */

.lg-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center; /* center buttons + grid */
}

/* Centered button row above grid */

.left-action-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

/* Grid container & cells */

.grid-container {
  --rows: 1;
  --cols: 3;
  width: 100%;
  max-width: 560px;      /* fixed visual width */
  height: 360px;         /* fixed visual height */
  margin-top: 4px;

  display: grid;
  grid-template-rows: repeat(var(--rows), 1fr);
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 4px;

  background: #e2e2e2;
  padding: 6px;
  border-radius: 6px;
}

.grid-cell {
  position: relative;
  background: #ffffff;
  border: 1px dashed #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Gray "+" on empty, active cells */
.grid-cell[data-has-image="0"]:not(.inactive)::after {
  content: "+";
  position: absolute;
  font-size: 32px;
  color: #c7c7c7;
  pointer-events: none;
}

/* inactive filler cells (pattern layout) */
.grid-cell.inactive {
  background: transparent;
  border: none;
  pointer-events: none;
}

.cell-label {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  color: #666;
}

.cell-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.hidden-file-input {
  display: none;
}

.delete-btn {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #333;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.grid-cell.dragover {
  outline: 2px solid #007bff;
  outline-offset: -2px;
}

.grid-container.dragover-grid {
  box-shadow: 0 0 0 2px #007bff inset;
}

/* Right column */

.lg-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;  /* center header + preview */
}

/* Header above preview, same width as preview box */

.right-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 12px;
}

.right-header h2 {
  margin: 0;
  font-size: 20px;
  text-align: center;
}

/* Inline download button (appears after export) */

.download-inline {
  font-size: 13px;
  padding: 6px 10px;
  background: #0074d9;
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
}

.download-inline:hover {
  background: #005fa8;
}

/* Preview / output area */

.output-area {
  border: 1px dashed #bbb;
  border-radius: 6px;
  padding: 16px;
  background: #fafafa;

  width: 100%;
  max-width: 340px;       /* fixed visual width */
  height: 360px;          /* fixed visual height */
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Exported preview image */
.exported-image {
  max-width: 100%;
  max-height: 320px;      /* keep preview from going huge */
  height: auto;
  display: block;
  margin-bottom: 8px;
}

/* Preview placeholder box */

.preview-box {
  border: 1px dashed #bbb;
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  min-height: 200px;
  width: 100%;
  background: #fff;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preview-label {
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 14px;
  color: #555;
}

.preview-layout {
  font-size: 13px;
  color: #333;
}

/* Download link (legacy style in case used elsewhere) */
.download-link {
  display: inline-block;
  margin-top: 6px;
  text-decoration: none;
}

/* ========== Upgrade page ========== */

.upgrade-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.upgrade-column {
  flex: 1 1 220px;
  background: #fafafa;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #eee;
  font-size: 14px;
}

.upgrade-column h3 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 16px;
}

.upgrade-column ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

/* ========== Landing samples section ========== */

.samples-section {
  max-width: 960px;
  margin: 20px auto 0;
  padding: 0 16px 40px;
}

.samples-section h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.samples-intro {
  font-size: 14px;
  color: #555;
  margin-bottom: 16px;
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sample-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-size: 13px;
}

.sample-card img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  margin-bottom: 8px;
}

/* ========== Login form width fix ========== */

.form-card form {
  max-width: 420px;
  margin: 0 auto;
}

/* ========== Responsive ========== */

@media (max-width: 900px) {
  .workspace-body {
    flex-direction: column;
  }

  .grid-container {
    max-width: 100%;
  }

  .output-area,
  .right-header {
    max-width: 100%;
  }
}
