/* image-gen.css */
.hidden { display: none !important; }
body {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  background-color: #0b0f19;
  color: #fff;
  overflow: hidden; /* Prevent full page scroll */
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar overrides for Image Gen */
.sidebar {
  width: 400px; /* Slightly wider for all the controls */
  background: rgba(15, 23, 42, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  z-index: 10;
  position: relative;
}

.sidebar h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: #a855f7;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.control-group label {
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 600;
}

.control-input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: white;
  font-family: 'Outfit', sans-serif;
  width: 100%;
  box-sizing: border-box;
}

.control-input:focus {
  outline: none;
  border-color: #00d2ff;
}

.flex-row {
  display: flex;
  gap: 10px;
}

.action-btn {
  background: linear-gradient(135deg, #00d2ff, #3a7bd5);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 210, 255, 0.3);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
}
.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Template Selector */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.template-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.8rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.template-card:hover {
  background: rgba(255,255,255,0.1);
}

.template-card.active {
  border-color: #00d2ff;
  background: rgba(0, 210, 255, 0.1);
}

/* Spec Items */
.spec-list-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.spec-item-row {
  display: flex;
  gap: 8px;
}
.spec-item-row input {
  flex: 1;
}
.spec-item-row .remove-spec {
  background: rgba(255,0,0,0.2);
  color: #ff4444;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0 10px;
}

/* Global Spec Item Styles (Fallback & Em scaling) */
.specs-zone {
  min-width: 200px;
  min-height: 50px;
  display: block !important;
}
.specs-zone .spec-item {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-bottom: 0.5em;
}
.specs-zone .spec-icon {
  font-size: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.specs-zone .spec-text {
  font-size: 1.1em;
  font-weight: 700;
  line-height: 1.2;
}
.specs-zone .spec-sub {
  font-size: 0.8em;
  opacity: 0.9;
}

/* Social Inputs */
.social-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.social-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.social-row span {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

/* Main Canvas Area */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(circle at center, #1a2235 0%, #0b0f19 100%);
  overflow: auto;
  padding: 2rem;
}

/* The actual poster container to be exported */
#posterCanvas {
  position: relative;
  background-color: #ffffff;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform-origin: center center;
  /* Default size 1080x1080 */
  width: 1080px;
  height: 1080px;
  /* Scale it down for view but export at full size */
  transform: scale(0.6);
  flex-shrink: 0;
}

/* Draggable elements inside the canvas */
.draggable {
  position: absolute;
  cursor: grab;
  user-select: none;
}
.draggable:active {
  cursor: grabbing;
}
.draggable.selected {
  outline: 2px dashed #00d2ff;
}

/* Delete icon */
.delete-icon {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: none;
  z-index: 100;
}
.draggable.selected .delete-icon {
  display: block;
}

/* Resize handles (basic implementation) */
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #00d2ff;
  border-radius: 50%;
  bottom: -5px;
  right: -5px;
  cursor: se-resize;
  display: none;
}
.draggable.selected .resize-handle {
  display: block;
}

/* Inline Edit */
.inline-edit {
  outline: none;
  border: none;
  background: transparent;
}
.inline-edit[contenteditable="true"] {
  outline: 1px dashed rgba(255,255,255,0.5);
  cursor: text;
}

/* =========================================
   TEMPLATE LAYOUTS
   ========================================= */

/* Common Elements */
.canvas-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
}
.canvas-bg img {
  width: 100%; height: 100%; object-fit: cover;
}

.layer-social {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  z-index: 50;
  color: white;
  font-size: 18px;
}
.layer-social div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-product {
  z-index: 10;
}
.layer-product img {
  width: 100%; height: auto; display: block;
}

.layer-logo { z-index: 20; }
.layer-logo img { width: 100%; height: auto; }

.layer-text { z-index: 30; }

/* ---------------- T1: Tech Pro (Omen Style) ---------------- */
.template-t1 {
  background: #f0f4f8;
  color: #1a2235;
}
.template-t1 .layer-product {
  width: 700px;
  top: 250px;
  left: 300px;
}
.template-t1 .title-zone {
  width: 100%;
  text-align: center;
  top: 50px;
  font-size: 80px;
  font-weight: 900;
  color: #1a2235;
  text-transform: uppercase;
}
.template-t1 .tagline-zone {
  width: 100%;
  text-align: center;
  top: 150px;
  font-size: 30px;
  font-weight: 600;
  color: #0078d7;
  letter-spacing: 2px;
}
.template-t1 .specs-zone {
  top: 250px;
  left: 50px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.template-t1 .spec-item {
  display: flex;
  align-items: center;
  gap: 15px;
}
.template-t1 .spec-icon {
  width: 60px; height: 60px;
  border: 2px solid #0078d7;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #0078d7;
}
.template-t1 .spec-text {
  font-size: 24px; font-weight: 700; line-height: 1.2;
}
.template-t1 .spec-sub {
  font-size: 16px; font-weight: 400; color: #475569;
}
.template-t1 .badge-zone {
  top: 250px;
  right: 50px;
  display: flex;
  align-items: center;
  gap: 15px;
}
.template-t1 .badge-icon {
  font-size: 80px; color: #0078d7;
}
.template-t1 .badge-text {
  font-size: 40px; font-weight: 800; line-height: 1; color: #0078d7;
}
.template-t1 .price-zone {
  bottom: 120px;
  right: 50px;
  text-align: right;
}
.template-t1 .price-label { font-size: 30px; font-weight: 800; }
.template-t1 .price-value { font-size: 120px; font-weight: 900; color: #0078d7; line-height: 0.9; }

/* ---------------- T2: Clean Light (Dell Style) ---------------- */
.template-t2 {
  background: #ffffff;
}
/* Use a background image if provided, or solid color */
.template-t2 .canvas-bg {
  opacity: 0.3; /* Wash out bg */
}
.template-t2 .layer-logo {
  top: 40px;
  left: 40px;
  width: 300px;
}
.template-t2 .price-zone {
  top: 50px;
  right: 50px;
  font-size: 150px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 4px 4px 0 #0078d7, -2px -2px 0 #0078d7, 2px -2px 0 #0078d7, -2px 2px 0 #0078d7, 0 10px 20px rgba(0,0,0,0.5);
  font-style: italic;
}
.template-t2 .layer-product {
  width: 800px;
  top: 300px;
  left: 140px;
}
.template-t2 .specs-zone {
  top: 250px;
  left: 40px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.template-t2 .spec-item {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  padding: 10px;
  width: 250px;
  gap: 15px;
}
.template-t2 .spec-icon {
  width: 50px; height: 50px;
  background: #f0f4f8;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #0078d7;
  border-radius: 4px;
}
.template-t2 .spec-text {
  font-size: 22px; font-weight: 800; color: #1a2235;
}
.template-t2 .spec-sub {
  font-size: 16px; color: #475569;
}

/* ---------------- T3: Bold Promo ---------------- */
.template-t3 {
  background: linear-gradient(135deg, #ff007f, #7928ca);
  color: white;
}
.template-t3 .title-zone {
  top: 60px;
  width: 100%;
  text-align: center;
  font-size: 90px;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.template-t3 .layer-product {
  width: 900px;
  top: 250px;
  left: 90px;
  filter: drop-shadow(0 30px 40px rgba(0,0,0,0.5));
}
.template-t3 .price-zone {
  bottom: 120px;
  left: 60px;
  background: white;
  color: #ff007f;
  padding: 20px 40px;
  border-radius: 20px;
  font-size: 100px;
  font-weight: 900;
  transform: rotate(-5deg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.template-t3 .specs-zone {
  bottom: 150px;
  right: 60px;
  text-align: right;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.5;
}

/* ---------------- T4: Minimalist Studio ---------------- */
.template-t4 {
  background: #fafafa;
  color: #222;
}
.template-t4 .layer-logo {
  top: 50px;
  left: 50px;
  width: 200px;
}
.template-t4 .layer-product {
  width: 600px;
  top: 200px;
  left: 240px;
  filter: drop-shadow(0 40px 30px rgba(0,0,0,0.15));
}
.template-t4 .title-zone {
  top: 750px;
  width: 100%;
  text-align: center;
  font-size: 60px;
  font-weight: 300;
  letter-spacing: 5px;
}
.template-t4 .price-zone {
  top: 850px;
  width: 100%;
  text-align: center;
  font-size: 40px;
  font-weight: 600;
}

/* ---------------- T5: Social Story (1080x1920) ---------------- */
.template-t5 {
  width: 1080px;
  height: 1920px;
  background: linear-gradient(to bottom, #111, #333);
  color: white;
}
.template-t5 .layer-product {
  width: 900px;
  top: 600px;
  left: 90px;
}
.template-t5 .title-zone {
  top: 150px;
  width: 100%;
  text-align: center;
  font-size: 100px;
  font-weight: 900;
  background: -webkit-linear-gradient(#fff, #aaa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.template-t5 .price-zone {
  top: 350px;
  width: 100%;
  text-align: center;
  font-size: 120px;
  font-weight: 800;
  color: #00d2ff;
}
.template-t5 .specs-zone {
  top: 1300px;
  left: 100px;
  width: 880px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 30px;
  padding: 40px;
  font-size: 40px;
  line-height: 1.8;
}

/* ---------------- T6: Cyber Board (PCB.png) ---------------- */
.template-t6 {
  background: url('templates/PCB.png') center/cover no-repeat;
  color: #1a2235;
}
.template-t6 .layer-product {
  width: 700px;
  top: 380px;
  left: 190px;
}
.template-t6 .title-zone {
  top: 150px;
  width: 100%;
  text-align: center;
  font-size: 60px;
  font-weight: 900;
  color: #3b82f6;
  text-transform: uppercase;
}
.template-t6 .tagline-zone {
  top: 220px;
  width: 100%;
  text-align: center;
  font-size: 30px;
  color: #64748b;
}
.template-t6 .price-zone {
  bottom: 120px;
  width: 100%;
  text-align: center;
  font-size: 80px;
  font-weight: 900;
  color: #0f172a;
}
.template-t6 .specs-zone {
  top: 350px;
  left: 50px;
  font-size: 20px;
}

/* ---------------- T7: Speed Racing (Simple.png) ---------------- */
.template-t7 {
  background: url('templates/Simple.png') center/cover no-repeat;
  color: #333;
}
.template-t7 .title-zone {
  top: 80px;
  width: 100%;
  text-align: center;
  font-size: 70px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.template-t7 .tagline-zone {
  top: 160px;
  width: 100%;
  text-align: center;
  font-size: 35px;
  color: #666;
}
.template-t7 .layer-product {
  width: 650px;
  top: 300px;
  left: 215px;
  filter: drop-shadow(0 20px 40px rgba(255,255,255,0.8));
}
.template-t7 .price-zone {
  bottom: 120px;
  width: 100%;
  text-align: center;
  font-size: 90px;
  font-weight: 900;
  color: white;
  text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.template-t7 .specs-zone {
  bottom: 120px;
  left: 60px;
  width: 400px;
  color: #333;
  font-size: 22px;
}

/* ---------------- T8: Warzone (Warzone.png) ---------------- */
.template-t8 {
  background: url('templates/Warzone.png') center/cover no-repeat;
  color: white;
}
.template-t8 .layer-product {
  width: 700px;
  top: 400px;
  left: 190px;
  filter: drop-shadow(0 30px 40px rgba(0,0,0,0.8));
}
.template-t8 .title-zone {
  top: 120px;
  width: 100%;
  text-align: center;
  font-size: 90px;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 5px 20px rgba(0,0,0,0.8);
}
.template-t8 .specs-zone {
  top: 250px;
  left: 60px;
  font-size: 24px;
  width: 500px;
}
.template-t8 .tagline-zone {
  top: 220px;
  width: 100%;
  text-align: center;
  font-size: 40px;
  font-weight: bold;
  text-shadow: 2px 2px 10px rgba(0,0,0,0.9);
}
.template-t8 .price-zone {
  bottom: 150px;
  width: 100%;
  text-align: center;
  font-size: 110px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 5px 25px rgba(0,0,0,0.9);
}

/* ---------------- T9: Outdoor Easy (Clear.png) ---------------- */
.template-t9 {
  background: url('templates/Clear.png') center/cover no-repeat;
  color: #1a2235;
}
.template-t9 .layer-logo {
  top: 40px;
  left: 40px;
  width: 300px;
}
.template-t9 .price-zone {
  top: 60px;
  right: 60px;
  font-size: 130px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 4px 4px 0 #0078d7, -2px -2px 0 #0078d7, 2px -2px 0 #0078d7, -2px 2px 0 #0078d7, 0 10px 20px rgba(0,0,0,0.5);
  font-style: italic;
  transform: rotate(3deg);
}
.template-t9 .layer-product {
  width: 800px;
  top: 300px;
  left: 140px;
}
.template-t9 .specs-zone {
  top: 250px;
  left: 40px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.template-t9 .spec-item {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  padding: 10px;
  width: 250px;
  gap: 15px;
}
.template-t9 .spec-icon {
  width: 50px; height: 50px;
  background: #f0f4f8;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #0078d7;
  border-radius: 4px;
}
.template-t9 .spec-text {
  font-size: 22px; font-weight: 800; color: #1a2235;
}
.template-t9 .spec-sub {
  font-size: 16px; color: #475569;
}
.template-t9 .title-zone, .template-t9 .tagline-zone, .template-t9 .badge-zone {
  display: none; /* Hide extra text to match the clean original */
}
.template-t9 .specs-zone {
  top: 400px;
  left: 40px;
  width: 300px;
  font-size: 20px;
  color: #1a2235;
}

.template-t6 .layer-logo,
.template-t8 .layer-logo,
.template-t9 .layer-logo {
  display: none !important;
}

/* Add custom template section */
.add-template-card {
  background: rgba(168, 85, 247, 0.1);
  border: 1px dashed #a855f7;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  margin-top: 1rem;
}
.add-template-card h4 {
  color: #a855f7;
  margin-top: 0;
  margin-bottom: 0.5rem;
}
.add-template-card p {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

/* ── Guest Mode: Visual Lock Only (no blocking overlays) ── */
.guest-lock-overlay {
  display: none;
}
body.is-guest .guest-lock-overlay {
  display: none !important;
}
body.is-guest .sidebar .control-group:not(.no-lock) {
  opacity: 0.5;
  cursor: not-allowed;
}
body.is-guest .sidebar .control-group:not(.no-lock) * {
  pointer-events: none !important;
  user-select: none;
}
body.is-guest .no-lock,
body.is-guest .no-lock * {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: auto;
}
/* Guests CAN now drag and resize elements */
body.is-guest #posterCanvas {
  pointer-events: auto !important;
}
body.is-guest .draggable {
  pointer-events: auto !important;
  cursor: move !important;
}

/* Keep template grid + nav fully clickable */
body.is-guest #templateGrid,
body.is-guest .template-card,
body.is-guest .no-lock,
body.is-guest .no-lock * {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Visually dim locked sections — NO pseudo-elements that block scroll */
body.is-guest .sidebar .control-group:not(.no-lock),
body.is-guest .sidebar .form-group:not(.no-lock) {
  opacity: 0.5;
  cursor: not-allowed;
}

body.is-guest .sidebar .control-group:not(.no-lock) *,
body.is-guest .sidebar .form-group:not(.no-lock) * {
  pointer-events: none !important;
  user-select: none;
}

body.is-guest #exportControls {
  opacity: 0.4;
  cursor: not-allowed;
}
body.is-guest #exportControls * {
  pointer-events: none !important;
}

/* SIDEBAR LOCK OVERLAY */
.sidebar-lock {
  position: absolute;
  top: 480px; /* Shifted down to UNLOCK template selection */
  left: 0; 
  width: 100%; 
  height: calc(100% - 480px);
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

body.is-guest .sidebar-lock {
  display: flex;
}

.sidebar-lock .lock-content {
  background: rgba(15, 23, 42, 0.95);
  padding: 25px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  max-width: 90%;
}

.sidebar-lock .lock-icon { 
  font-size: 2.5rem; 
  display: block; 
  margin-bottom: 15px; 
}

.sidebar-lock p { 
  font-weight: 800; 
  text-transform: uppercase; 
  letter-spacing: 1px; 
  color: #fff; 
  margin: 0;
  font-size: 0.9rem;
}

.sidebar-lock .unlock-btn {
  margin-top: 15px;
  background: linear-gradient(135deg, #7c3aed, #9d50bb);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto !important; /* Ensure they can click login */
}
