:root {
  --bg-main: #f8fafc; /* Slate 50 */
  --bg-sidebar: #ffffff;
  --fg-main: #0f172a; /* Slate 900 */
  --fg-muted: #64748b; /* Slate 500 */
  --accent: #4f46e5; /* Indigo 600 */
  --accent-hover: #4338ca;
  --border: #e2e8f0; /* Slate 200 */
  --radius: 10px;
  --font-main: "Inter", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--fg-main);
  height: 100vh;
  overflow: hidden;
}

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

/* SIDEBAR (Desktop default) */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-name small {
  font-size: 10px;
  color: var(--accent);
  background: #e0e7ff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.side-nav a {
  text-decoration: none;
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 8px;
  transition: 0.2s;
}

.side-nav a:hover, .side-nav a.active {
  background: #f1f5f9;
  color: var(--fg-main);
}

.side-nav a.active {
  background: #e0e7ff;
  color: var(--accent);
}

.sidebar-footer {
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.status {
  font-size: 12px;
  color: #16a34a;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* MAIN WRAPPER */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
}

.workspace {
  padding: 40px;
  max-width: 900px;
  margin: 0 auto;
}

.gen-panel h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.sub {
  color: var(--fg-muted);
  font-size: 15px;
  margin-bottom: 32px;
  line-height: 1.5;
}

.gen-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  background: #fff;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-main);
}

.input-group input, .input-group select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg-main);
  transition: 0.2s;
}

.input-group input:focus, .input-group select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: 0.2s;
  height: 44px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* PREVIEW */
.preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-top: 32px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.preview img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
  margin: 0 auto 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-actions {
  display: flex;
  justify-content: center;
}

.btn-secondary {
  text-decoration: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: 0.2s;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.hidden { display: none; }

/* HISTORY */
.history-section {
  padding: 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.history-header {
  margin-bottom: 32px;
}

.history-header h3 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.history-header p {
  font-size: 14px;
  color: var(--fg-muted);
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.grid figure {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.grid figure:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.grid img {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}

.grid figcaption {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--fg-main);
  font-weight: 500;
}

/* MOBILE ELEMENTS */
.mobile-topbar { display: none; }
.overlay { display: none; }

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
  body { overflow: auto; }
  
  .app-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .main-wrapper {
    overflow: visible;
  }

  /* Sidebar jadi Drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Overlay gelap */
  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Topbar Mobile */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .menu-btn {
    background: transparent;
    border: none;
    color: var(--fg-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
  }
  
  .menu-btn:hover { background: #f1f5f9; }

  .brand-mobile {
    font-weight: 700;
    font-size: 16px;
  }

  /* Penyesuaian Konten Mobile */
  .workspace, .history-section {
    padding: 24px 16px;
  }

  .gen-panel h1 { font-size: 28px; }

  .gen-form {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
    gap: 16px;
  }

  .input-group { flex: none; width: 100%; }

  .btn-primary { width: 100%; margin-top: 4px; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  
  .grid figcaption { padding: 10px; }
}
