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

:root {
  --bg:      #0d1117;
  --surface: #161b22;
  --surface2:#21262d;
  --surface3:#30363d;
  --border:  #30363d;
  --text:    #e6edf3;
  --text2:   #8b949e;
  --text3:   #484f58;
  --accent:  #1f6feb;
  --accent2: #388bfd;
  --green:   #3fb950;
  --yellow:  #d29922;
  --red:     #f85149;
  --purple:  #8b5cf6;
  --radius:  8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── LAYOUT ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }

/* ── BRAND ── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon {
  font-size: 22px;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-name { font-weight: 800; font-size: 14px; line-height: 1; }
.brand-sub  { color: var(--text3); font-size: 11px; margin-top: 3px; }

/* ── SECTION ── */
.section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── MODE TABS ── */
.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius);
}
.mode-tab {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-tab.active { background: var(--accent); color: #fff; }

/* ── FORM ── */
.form-group { margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }
label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 5px;
  font-weight: 500;
}
input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.badge-info {
  font-size: 10px;
  background: rgba(31,111,235,0.15);
  color: var(--accent2);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 400;
}

/* ── TOGGLE ── */
.toggle-label {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-bottom: 0 !important;
  color: var(--text) !important;
  font-size: 13px !important;
}
.toggle-wrap { position: relative; display: inline-block; }
.toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  display: block; width: 40px; height: 22px;
  background: var(--surface3); border-radius: 22px;
  cursor: pointer; transition: background 0.2s; position: relative;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; background: #fff;
  border-radius: 50%; top: 3px; left: 3px; transition: transform 0.2s;
}
.toggle-wrap input:checked + .toggle-slider { background: var(--green); }
.toggle-wrap input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── TITLE ACTIONS ── */
.title-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-upload {
  flex: 1; padding: 7px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text2);
  font-size: 12px; cursor: pointer; text-align: center; transition: all 0.15s;
}
.btn-upload:hover { border-color: var(--accent2); color: var(--text); }

.btn-clear {
  padding: 7px 12px;
  background: rgba(248,81,73,0.1);
  border: 1px solid rgba(248,81,73,0.2);
  border-radius: var(--radius); color: var(--red);
  font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.btn-clear:hover { background: rgba(248,81,73,0.2); }

/* tombol hapus semua history kecil */
.btn-clear-sm {
  padding: 3px 9px;
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.25);
  border-radius: 5px; color: var(--red);
  font-size: 10px; cursor: pointer; transition: all 0.15s;
}
.btn-clear-sm:hover { background: rgba(248,81,73,0.18); }

.title-count {
  background: var(--surface2); color: var(--text2);
  font-size: 10px; padding: 2px 7px; border-radius: 10px; font-weight: 400;
}

/* ── GENERATE BUTTON ── */
.btn-generate {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border: none; border-radius: var(--radius);
  color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px; transition: opacity 0.2s;
}
.btn-generate:hover { opacity: 0.9; }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── HISTORY SECTION ── */
#historySection { padding: 14px 20px; }

.history-empty {
  font-size: 11px; color: var(--text3);
  text-align: center; padding: 14px 0;
}

#historyList { display: flex; flex-direction: column; gap: 6px; }

.hist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: background 0.15s, border-color 0.15s;
}
.hist-item:hover { background: #1c2128; border-color: var(--surface3); }

.hist-content { flex: 1; min-width: 0; }

.hist-title {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-meta { font-size: 10px; color: var(--text3); margin-top: 2px; }

.hist-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.hist-actions button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.btn-hist-load {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent) !important;
}
.btn-hist-load:hover { opacity: 0.85; }

.btn-hist-dl {
  background: var(--surface2);
  color: var(--text2);
  border-color: var(--border) !important;
}
.btn-hist-dl:hover { border-color: var(--green) !important; color: var(--green); }

.btn-hist-del {
  background: transparent;
  color: var(--red);
  border-color: rgba(248,81,73,0.25) !important;
}
.btn-hist-del:hover { background: rgba(248,81,73,0.1); }

/* ── MAIN PANEL ── */
.main-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── TOOLBAR ── */
.toolbar {
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 12px;
}
.toolbar-title {
  font-size: 13px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn-tool {
  padding: 7px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.btn-tool:hover { border-color: var(--accent2); color: var(--accent2); }

.btn-tool-sm {
  padding: 6px 10px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text2);
  font-size: 11px; cursor: pointer; transition: all 0.15s;
}
.btn-tool-sm:hover { border-color: var(--green); color: var(--green); }

.divider-v { width: 1px; height: 24px; background: var(--border); }

/* ── PREVIEW ── */
.preview-wrap {
  flex: 1; position: relative; overflow: hidden; background: var(--bg);
}
.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.preview-empty-icon  { font-size: 48px; opacity: 0.3; }
.preview-empty-title { font-size: 18px; font-weight: 700; opacity: 0.4; }
.preview-empty-sub   { font-size: 13px; color: var(--text3); text-align: center; max-width: 300px; }

.preview-frame { width: 100%; height: 100%; border: none; background: #fff; }

/* ── SPINNER ── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; max-width: 320px;
  animation: slideIn 0.25s ease; border: 1px solid transparent;
}
.toast-success { background: rgba(63,185,80,0.15);  border-color: rgba(63,185,80,0.3);  color: var(--green);   }
.toast-error   { background: rgba(248,81,73,0.15);  border-color: rgba(248,81,73,0.3);  color: var(--red);     }
.toast-info    { background: rgba(31,111,235,0.15); border-color: rgba(31,111,235,0.3); color: var(--accent2); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── AMP TITLE / DESC PREVIEW BOX ── */
.amp-desc-preview,
.amp-title-preview {
  margin-top: 7px;
  padding: 8px 10px;
  background: rgba(56,139,253,0.06);
  border: 1px solid rgba(56,139,253,0.18);
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text2);
}

.amp-desc-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent2);
  margin-bottom: 3px;
}

/* ── UTILS ── */
.hidden { display: none !important; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }
