:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e7e8f0;
  --text: #1a1b2e;
  --text-muted: #6b6d84;
  --sidebar-bg: #14152b;
  --sidebar-text: #b8b9d1;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #1e1f3d;
  --accent: #6c5ce7;
  --accent-hover: #5b4bd6;
  --accent-soft: #efecfe;
  --ok: #16a34a;
  --ok-bg: #e9f9ef;
  --danger: #e0245e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20,21,43,0.04), 0 4px 16px rgba(20,21,43,0.06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Sidebar ---------- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  transition: width 0.15s ease, padding 0.15s ease;
  overflow: hidden;
}

/* ---------- Sidebar daraltilmis (sadece ikonlar) hali ---------- */

.sidebar.collapsed {
  width: 72px;
  padding-left: 10px;
  padding-right: 10px;
}

.sidebar.collapsed .brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .status-pill span,
.sidebar.collapsed .sidebar-collapse-btn span {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .status-pill {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .sidebar-collapse-btn {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .sidebar-collapse-btn .collapse-icon {
  transform: rotate(180deg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.brand-name {
  color: white;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.2px;
}

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

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b6c8a;
  padding: 16px 10px 6px;
  font-weight: 600;
}

.nav-section:first-child {
  padding-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  padding: 10px 10px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-item.active {
  background: var(--accent);
  color: white;
}

.sidebar-footer {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: #9394ac;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-collapse-btn .collapse-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--sidebar-hover);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b6c8a;
  flex-shrink: 0;
}
.dot.ok { background: #2ecc71; }
.dot.err { background: var(--danger); }

/* ---------- Main ---------- */

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 40px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.view { display: none; }
.view.active { display: block; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 100px;
}

.tag-muted {
  color: var(--text-muted);
  background: #f0f0f5;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

textarea, select, input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fbfbfd;
  resize: vertical;
  transition: border-color 0.15s ease;
}

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

.field-row {
  display: flex;
  gap: 12px;
  margin: 14px 0 18px;
}

.field { flex: 1; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  background: #d8d8e6;
  color: #9797ab;
  cursor: not-allowed;
}

.btn-sm { padding: 9px 14px; font-size: 13px; }

.btn-icon { width: 16px; height: 16px; fill: currentColor; stroke: none; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-secondary:hover { background: #f5f5fa; }

.btn-secondary svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

.hint {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0 0;
  min-height: 0;
}

.result-card { min-height: 300px; display: flex; flex-direction: column; }

.result-empty, .result-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13.5px;
  gap: 10px;
  padding: 30px 10px;
}

.empty-icon {
  width: 34px; height: 34px;
  fill: none; stroke: #c8c9dc; stroke-width: 1.4;
}

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.caption-box {
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  min-height: 140px;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.usage-note {
  color: var(--text-muted);
  font-size: 11.5px;
  margin: 10px 0 0;
}

.placeholder-card {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
  color: var(--text-muted);
  max-width: 480px;
}

.placeholder-icon {
  width: 36px; height: 36px;
  fill: none; stroke: #c8c9dc; stroke-width: 1.4;
  margin-bottom: 12px;
}

.placeholder-card h2 {
  color: var(--text);
  font-size: 16px;
  margin: 0 0 6px;
}

.placeholder-card p {
  font-size: 13.5px;
  margin: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.settings-row:last-child { border-bottom: none; }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  background: #f0f0f5;
  color: var(--text-muted);
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-neutral { background: var(--accent-soft); color: var(--accent); }

.save-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.save-row input { flex: 1; }

.library-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.library-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.library-item-name {
  font-weight: 600;
  font-size: 14px;
}

.library-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.library-item-caption {
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text);
  margin: 8px 0;
}

.library-item-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.btn-danger-text {
  color: var(--danger);
  background: none;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.generated-image-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fbfbfd;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.generated-image-wrap img {
  width: 100%;
  display: block;
}

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

.media-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}

.media-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: #f0f0f5;
}

.media-card-body {
  padding: 10px 12px 12px;
}

.media-card-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.media-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-btn {
  color: var(--accent);
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 1150px) {
  .grid3 { grid-template-columns: 1fr; }
}

.step-inline-result {
  margin-top: 18px;
}

.result-empty-sm {
  padding: 10px 0 2px;
  min-height: 0;
}

.result-empty-sm p {
  margin: 0;
}

.image-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.image-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  background: #f0f0f5;
  flex-shrink: 0;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-thumb.selected {
  border-color: var(--accent);
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 30px;
}

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 18px;
  cursor: pointer;
}

/* ---------- Proje bari (Canva tarzi proje adi + liste) ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.project-bar { flex: 1; min-width: 0; }

.project-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.project-name-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: text;
}

.project-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  outline: none;
  border-bottom: 1px dashed var(--border);
  padding: 2px 4px;
  border-radius: 6px;
  cursor: text;
  min-width: 60px;
  display: inline-block;
}

.project-name-edit-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.65;
}

.project-name:hover { border-bottom-color: var(--accent); }

.project-name:focus {
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}

.project-saved-flag {
  color: var(--ok);
  font-size: 12.5px;
  font-weight: 600;
}

.project-switcher-wrap {
  position: relative;
  margin-left: auto;
}

.project-switcher-wrap .chevron-icon {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor; stroke-width: 2;
}

.project-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 20;
}

.project-dropdown-new {
  width: 100%;
  text-align: left;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 6px;
}

.project-dropdown-new:hover { background: #e4dffc; }

.project-dropdown-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.project-dropdown-item:hover { background: #f5f5fa; }

.project-dropdown-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.project-dropdown-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-dropdown-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.project-dropdown-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  flex-shrink: 0;
}

.project-dropdown-item-delete:hover { color: var(--danger); }

/* ---------- Adim 1 -> Adim 2 gecis butonu ---------- */

.step-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0 14px;
}

.btn-goto-step2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 6px 2px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.btn-goto-step2:hover { color: var(--accent-hover); }

.arrow-icon {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Adim 2 kilit gorunumu ---------- */

.step-lock-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.82);
  border-radius: var(--radius);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 20px;
  z-index: 5;
}

.step-lock-overlay .lock-icon {
  width: 30px; height: 30px;
  fill: none; stroke: #c8c9dc; stroke-width: 1.6;
}

.step-lock-overlay p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.step-locked {
  position: relative;
  pointer-events: none;
}

.step-locked .step-lock-overlay { display: flex; }

.step-locked > *:not(.step-lock-overlay) { opacity: 0.35; }

/* ---------- Adim 2 kontrol satiri (referans + stil + tur + prompt yaz) ---------- */

.control-row { align-items: flex-end; }

.control-row select,
.control-row .prompt-yaz-btn {
  height: 42px;
}

.control-row .prompt-yaz-btn { white-space: nowrap; }

.ref-upload-wrap {
  position: relative;
  width: 42px;
  flex-shrink: 0;
}

.ref-upload-btn, .ref-thumb-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

.ref-upload-btn {
  border: 1px dashed var(--border);
  background: #fbfbfd;
  cursor: pointer;
}

.ref-upload-btn:hover { background: #f5f5fa; }

.ref-upload-icon {
  width: 18px; height: 18px;
  fill: none; stroke: var(--text-muted); stroke-width: 1.8;
}

.ref-thumb-wrap {
  position: relative;
  border: 1px solid var(--border);
}

.ref-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-thumb-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: white;
  font-size: 10px;
  line-height: 18px;
  padding: 0;
  cursor: pointer;
}

/* ---------- Proje karsilama ekrani (Canva tarzi galeri) ---------- */

.project-welcome {
  max-width: 980px;
}

.btn-welcome-new {
  margin-bottom: 24px;
  padding: 13px 22px;
  font-size: 15px;
}

.project-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.project-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  gap: 8px;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.project-card:active {
  transform: translateY(0);
}

.project-card-name {
  width: 100%;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-brief {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-muted);
  min-height: 34px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-brief-empty {
  font-style: italic;
  opacity: 0.7;
}

.project-card-thumbs {
  display: flex;
  gap: 6px;
}

.project-card-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.project-card-date {
  margin-top: auto;
  padding-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.project-welcome-empty {
  padding: 30px 4px;
  color: var(--text-muted);
  font-size: 13.5px;
}
