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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f0f0f;
  color: #e8e8e8;
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: #161616;
  border-right: 1px solid #2a2a2a;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 1rem;
  border-bottom: 1px solid #2a2a2a;
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 15px; font-weight: 600; color: #fff; }

.nav-section { display: flex; flex-direction: column; gap: 6px; }
.nav-label { font-size: 11px; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; }

.nav-btn {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  background: transparent;
  color: #888;
  text-align: left;
  transition: all 0.1s;
}
.nav-btn:hover { background: #1e1e1e; color: #ccc; }
.nav-btn.active { background: #fff; color: #000; border-color: #fff; font-weight: 500; }

.key-field { display: flex; flex-direction: column; gap: 4px; }
.key-field label { font-size: 12px; color: #666; }
.key-field input, .key-field select {
  padding: 7px 10px;
  font-size: 13px;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  color: #e8e8e8;
  width: 100%;
}
.key-field select option { background: #1e1e1e; }

.save-keys-btn {
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  color: #888;
  transition: all 0.1s;
  margin-top: 2px;
}
.save-keys-btn:hover { border-color: #555; color: #ccc; }
.keys-saved { font-size: 12px; color: #4ade80; text-align: center; }

.gen-btn {
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  transition: opacity 0.15s;
  margin-top: auto;
}
.gen-btn:hover { opacity: 0.88; }
.gen-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.queue-count { font-size: 12px; color: #555; text-align: center; margin-top: 6px; }

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #2a2a2a;
  background: #161616;
  padding: 0 1.5rem;
}
.tab {
  padding: 12px 20px;
  font-size: 14px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.1s;
}
.tab:hover { color: #aaa; }
.tab.active { color: #fff; border-bottom-color: #fff; }

#generateTab, #queueTab {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: #444;
  gap: 10px;
  font-size: 15px;
}
.empty-icon { font-size: 48px; }
.empty-sub { font-size: 13px; color: #333; }

/* Loading */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  color: #666;
  font-size: 14px;
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid #2a2a2a;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Preview */
.preview-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.preview-left {}

.post-card {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  overflow: hidden;
}

.post-image {
  width: 100%;
  aspect-ratio: 1;
  background: #1e1e1e;
  position: relative;
  overflow: hidden;
}
.post-image img { width: 100%; height: 100%; object-fit: cover; }
.post-image .img-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #666; font-size: 13px;
  background: #1e1e1e;
}

.post-body { padding: 1rem; }
.post-account { font-size: 12px; font-weight: 600; color: #aaa; margin-bottom: 8px; }
.post-hook { font-size: 15px; font-weight: 600; line-height: 1.5; color: #fff; margin-bottom: 8px; }
.post-caption { font-size: 13px; color: #888; line-height: 1.6; margin-bottom: 10px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #1e1e1e; color: #555; border: 1px solid #2a2a2a; }

.action-row { display: flex; gap: 8px; }
.approve-btn {
  flex: 1; padding: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; background: #4ade80; color: #000;
  border: none; border-radius: 8px; transition: opacity 0.1s;
}
.approve-btn:hover { opacity: 0.85; }
.edit-btn, .reject-btn {
  padding: 8px 14px; font-size: 13px; cursor: pointer;
  background: transparent; color: #666;
  border: 1px solid #2a2a2a; border-radius: 8px;
  transition: all 0.1s;
}
.edit-btn:hover, .reject-btn:hover { border-color: #555; color: #aaa; }

.edit-panel { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.edit-panel textarea {
  width: 100%; padding: 8px 10px; font-size: 13px; line-height: 1.6;
  background: #1e1e1e; border: 1px solid #2a2a2a; border-radius: 6px;
  color: #e8e8e8; resize: vertical; font-family: inherit;
}
.save-edit-btn {
  align-self: flex-start; padding: 6px 14px; font-size: 13px;
  cursor: pointer; background: #fff; color: #000;
  border: none; border-radius: 6px;
}

/* Detail cards */
.preview-right { display: flex; flex-direction: column; gap: 12px; max-height: 90vh; overflow-y: auto; padding-right: 4px; }

.detail-card {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.detail-label {
  font-size: 11px; font-weight: 600; color: #555;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between;
}
.detail-content { font-size: 13px; color: #888; line-height: 1.6; white-space: pre-wrap; }
.detail-scroll { max-height: 200px; overflow-y: auto; }
.slides-scroll { max-height: 220px; overflow-y: auto; }

.slide-item { padding: 7px 0; border-bottom: 1px solid #2a2a2a; font-size: 13px; color: #aaa; line-height: 1.5; }
.slide-item:last-child { border-bottom: none; }
.slide-num { font-size: 11px; color: #444; margin-bottom: 2px; }

.copy-btn {
  font-size: 11px; padding: 3px 8px; cursor: pointer;
  background: transparent; border: 1px solid #2a2a2a; border-radius: 4px; color: #555;
  transition: all 0.1s;
}
.copy-btn:hover { border-color: #555; color: #aaa; }
.copy-btn.copied { color: #4ade80; border-color: #4ade80; }

/* Queue */
.queue-item {
  background: #161616; border: 1px solid #2a2a2a;
  border-radius: 12px; padding: 1rem 1.25rem;
  margin-bottom: 10px; display: flex; align-items: center; gap: 14px;
}
.queue-thumb {
  width: 56px; height: 56px; border-radius: 8px;
  object-fit: cover; background: #1e1e1e; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.queue-thumb img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
.queue-info { flex: 1; min-width: 0; }
.queue-hook { font-size: 14px; font-weight: 500; color: #e8e8e8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-meta { font-size: 12px; color: #555; margin-top: 3px; }
.queue-badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; background: #052e16; color: #4ade80; border: 1px solid #166534; white-space: nowrap; }
.queue-delete { padding: 5px 10px; font-size: 12px; cursor: pointer; background: transparent; color: #555; border: 1px solid #2a2a2a; border-radius: 6px; }
.queue-delete:hover { color: #f87171; border-color: #f87171; }

.queue-empty { text-align: center; padding: 3rem; color: #444; font-size: 14px; }
