:root {
  --bg-app: #0f1115;
  --bg-panel: #181b21;
  --border: #2d313a;
  --primary: #4f46e5;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --input-bg: #0f1115;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

/* --- LAYOUT UTAMA --- */
.app-layout {
  display: grid;
  grid-template-columns: 320px 1fr; /* Sidebar fixed 320px */
  height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  height: 100vh; /* KUNCI: Harus set tinggi pasti */
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden; /* Mencegah scrollbar ganda */
}
.sidebar-header,
.sidebar-footer {
  flex-shrink: 0;
}

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

.brand {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-link {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
}

#resetBtn:hover {
  background-color: var(--border);
  color: white !important;
  border-color: white !important;
}

.controls-container {
  flex: 1; /* Mengisi sisa ruang kosong */
  overflow-y: auto; /* KUNCI: Scrollbar muncul jika konten panjang */
  min-height: 0; /* FIX PENTING: Mencegah flex item "bablas" keluar layar */

  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;

  /* Styling Scrollbar Firefox */
  scrollbar-width: thin;
  scrollbar-color: #4b5563 var(--bg-panel);
}

/* Custom Scrollbar Styles (Chrome, Edge, Safari) */
.controls-container::-webkit-scrollbar {
  width: 6px; /* Lebar scrollbar */
}

.controls-container::-webkit-scrollbar-track {
  background: transparent;
}

.controls-container::-webkit-scrollbar-thumb {
  background-color: #374151; /* Abu-abu gelap */
  border-radius: 10px;
  border: 2px solid var(--bg-panel); /* Memberi jarak dari pinggir */
}

.controls-container::-webkit-scrollbar-thumb:hover {
  background-color: #6b7280; /* Lebih terang saat di-hover */
}

/* Inputs Styling */
.control-group label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="text"],
textarea,
select, /* Tambahan untuk dropdown */
.file-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: white;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  box-sizing: border-box;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 5px 0;
}

/* Bento Grid Colors */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-picker {
  width: 100%;
  height: 35px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 15px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.btn-action {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-action:hover {
  background: #4338ca;
}

/* Tombol Sekunder (Salin Code) - BARU */
.btn-secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.btn-secondary:hover {
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

/* --- PREVIEW AREA (DESKTOP DEFAULT) --- */
.preview-area {
  display: flex;
  flex-direction: column;
  background-color: #000;
  background-image: radial-gradient(#2d313a 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
  overflow: hidden;
}

.preview-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 40px;
}

/* OG Canvas Base */
.og-canvas {
  width: 1200px;
  height: 630px;
  background: #111827;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 80px;
  box-sizing: border-box;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);

  /* Desktop Scaling Default */
  transform-origin: center;
  transform: scale(0.6);
  user-select: none;
  transition: background-color 0.2s; /* Smooth color change */
}

/* Content Elements */
.og-content {
  z-index: 2;
}

.og-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 40px;
  font-size: 24px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.og-brand img {
  height: 40px;
  width: auto;
}

.og-main-text h1 {
  font-size: 72px;
  line-height: 1.1;
  margin: 0 0 20px 0;
  font-weight: 800;
  color: #fff;
}

.og-main-text p {
  font-size: 32px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  max-width: 900px;
}

.og-accent-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 15px;
  background: var(--primary);
}

/* Footer (Desktop) */
.app-footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.ecs-mini a {
  color: var(--text-muted);
  text-decoration: none;
  margin: 0 5px;
}
.ecs-mini a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* --- LAYOUT TEMPLATES (Styles) --- */

/* 1. Layout: Centered */
.og-canvas.layout-center {
  text-align: center;
  justify-content: center;
  gap: 40px;
}
.og-canvas.layout-center .og-brand {
  justify-content: center;
  margin-bottom: 20px;
  order: -1;
}
.og-canvas.layout-center .og-main-text p {
  margin: 0 auto;
}
.og-canvas.layout-center .og-accent-bar {
  height: 8px;
  top: 0;
  bottom: auto;
}

/* 2. Layout: Frame */
.og-canvas.layout-frame {
  padding: 60px;
  background-color: var(--bg-panel);
}
.og-canvas.layout-frame .og-content {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 60px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}
/* FIX: Agar Aksen Muncul di Layout Frame */
.og-canvas.layout-frame .og-accent-bar {
  display: block !important; /* 1. Paksa Muncul */

  /* 2. Posisikan di Atas Kartu (Header Line) */
  position: absolute;
  top: 60px; /* Sesuaikan dengan padding canvas (60px) */
  left: 60px;
  right: 60px;
  bottom: auto; /* Reset posisi bawah */

  /* 3. Styling Tampilan */
  width: auto;
  height: 6px; /* Ketebalan garis aksen */
  border-radius: 18px 18px 0 0; /* Melengkung di atas agar pas dengan sudut kartu */
  z-index: 10;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); /* Sedikit glow */
}

/* --- BACKGROUND PATTERNS (UPDATED - LEBIH TEBAL) --- */

/* Pattern: Dots (Titik) - DIPERBAIKI */
.og-canvas.pattern-dots {
  background-image: radial-gradient(
    circle,
    /* Tambahkan 'circle' agar bentuknya bulat sempurna */
      rgba(255, 255, 255, 0.5) 2px,
    /* Ukuran titik diperbesar jadi 2px & opacity 0.5 */ transparent 2.5px
  ) !important;
  background-size: 30px 30px; /* Jarak antar titik */
}

/* Pattern: Grid (Kotak) */
.og-canvas.pattern-grid {
  /* Opacity dinaikkan ke 0.2 (20%) */
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.2) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px) !important;
  background-size: 40px 40px;
}

/* Pattern: Diagonal Lines (Garis) */
.og-canvas.pattern-lines {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0.15) 2px,
    /* Garis lebih tebal (2px) */ transparent 2px,
    transparent 15px
  ) !important;
}

/* --- TYPOGRAPHY STYLES --- */

/* Default: Inter */
.og-canvas.font-inter {
  font-family: "Inter", system-ui, sans-serif;
}

/* Elegant: Playfair Display */
.og-canvas.font-serif {
  font-family: "Playfair Display", serif;
}
.og-canvas.font-serif h1 {
  font-style: italic;
} /* Sentuhan manis untuk serif */

/* Coding: Fira Code */
.og-canvas.font-mono {
  font-family: "Fira Code", monospace;
  letter-spacing: -1px;
}

/* Bold: Oswald */
.og-canvas.font-bold {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase; /* Oswald bagus kalau kapital semua */
  letter-spacing: 1px;
}

/* --- THEME BUTTONS --- */
.theme-buttons {
  display: flex;
  gap: 10px;
  margin-top: 5px;
}

.theme-btn {
  width: 35px;
  height: 35px;
  border-radius: 50%; /* Bulat */
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.theme-btn:hover {
  transform: scale(1.1);
  border-color: white;
}

.theme-btn:active {
  transform: scale(0.95);
}

/* --- RESPONSIVE MOBILE FIX (VERSI ANTI-BLANK) --- */
@media (max-width: 1024px) {
  .app-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow-x: hidden;
  }

  body {
    overflow-y: auto;
  }

  /* 1. Preview Area */
  .preview-area {
    order: 1;
    width: 100%;
    background-color: #000;
    display: flex;
    flex-direction: column;
    align-items: center; /* Pastikan di tengah */
    padding: 40px 10px; /* Padding kiri kanan dikurangi */
    min-height: 300px;
    box-sizing: border-box;
    overflow: hidden; /* Potong bayangan yang keluar layar */
  }

  /* 2. Controls / Sidebar */
  .sidebar {
    order: 2;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 10; /* Pastikan sidebar di atas */
  }

  .controls-container {
    padding-bottom: 50px;
  }

  /* 3. Wrapper (Hapus overflow hidden agar tidak blank) */
  .preview-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    /* JANGAN pakai overflow: hidden disini */
    overflow: visible;
    z-index: 1;
  }

  /* 4. Canvas (Scale dari Tengah Atas) */
  .og-canvas {
    min-width: 1200px !important;
    width: 1200px !important;
    height: 630px !important;

    /* Ubah ke Top Center agar aman */
    transform-origin: top center;
    margin: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
  }

  .app-footer {
    display: none;
  }
}

/* --- DESKTOP ACTIONS (Tombol Kanan Atas) --- */
.desktop-actions {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 15px;
  z-index: 50; /* Pastikan di atas segalanya */
}

/* Style khusus tombol desktop agar kontras dengan background gelap */
.desktop-actions .btn-secondary {
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}
.desktop-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: white;
}

/* --- RESPONSIVE LOGIC (PENTING) --- */

/* DI DESKTOP: Sembunyikan Footer Sidebar, Tampilkan Tombol Atas */
@media (min-width: 1025px) {
  .sidebar-footer {
    display: none !important;
  }
  .desktop-actions {
    display: flex !important;
  }
}

/* DI MOBILE: Sembunyikan Tombol Atas, Tampilkan Footer Sidebar */
@media (max-width: 1024px) {
  .desktop-actions {
    display: none !important;
  }
  .sidebar-footer {
    display: block !important;
  }
}
