:root {
  --sidebar-bg: #0f1117;
  --sidebar-text: #9ca3af;
  --sidebar-active-bg: #1e2330;
  --sidebar-active-text: #ffffff;
  --accent: #3b82f6;
  --manager-bg: #eff6ff;
  --manager-border: #bfdbfe;
  --customer-bg: #f3f4f6;
  --content-bg: #f9fafb;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --toast-success: #22c55e;
  --toast-error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Geist", "Inter", system-ui, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: #111827;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

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

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
}

.logo-sub {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b7280;
}

.lang-toggle {
  display: flex;
  gap: 8px;
}

.lang-btn {
  flex: 1;
  border: 1px solid #1f2937;
  background: #111827;
  color: var(--sidebar-text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.lang-btn.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-color: #2b3242;
}

.search-box input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #1f2937;
  background: #111827;
  color: #e5e7eb;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-btn {
  border: 1px solid #273043;
  background: transparent;
  color: #e5e7eb;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.filter-btn.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.admin-link {
  display: block;
  text-decoration: none;
  border: 1px solid #273043;
  background: transparent;
  color: #e5e7eb;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}

.admin-link:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-color: #2b3242;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding-right: 6px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.category-btn:hover {
  background: #141824;
  color: #e5e7eb;
}

.category-btn.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.cat-badge {
  margin-left: auto;
  background: #f59e0b;
  color: #111827;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
}

.content {
  flex: 1;
  background: var(--content-bg);
  padding: 32px;
}

.content-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.content-header h1 {
  margin: 0;
  font-size: 26px;
}

.content-sub {
  margin-top: 4px;
  font-size: 14px;
  color: #6b7280;
}

.hamburger {
  display: none;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.card-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.bookmark-btn {
  border: 1px solid var(--card-border);
  background: #ffffff;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #f59e0b;
}

.bookmark-btn.active {
  background: #fef3c7;
  border-color: #fcd34d;
}

.edit-btn {
  border: 1px solid var(--card-border);
  background: #ffffff;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.edit-btn:hover {
  opacity: 1;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.step-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.dialogue-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialogue-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.dialogue-row.customer {
  justify-content: flex-end;
}

.bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 1.4;
}

.bubble.manager {
  background: var(--manager-bg);
  border-color: var(--manager-border);
}

.bubble.customer {
  background: var(--customer-bg);
}

.dialogue-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option-chip {
  background: #e5e7eb;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-badge {
  min-width: 36px;
  text-align: center;
  background: #111827;
  color: #ffffff;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 8px;
}

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 4px solid #60a5fa;
  background: #eff6ff;
  padding: 12px 14px;
  border-radius: 12px;
}

.info-box.yellow {
  border-left-color: #f59e0b;
  background: #fef3c7;
}

.info-box.red {
  border-left-color: #ef4444;
  background: #fee2e2;
}

.info-box.green {
  border-left-color: #22c55e;
  background: #dcfce7;
}

.copy-btn {
  border: 0;
  background: #f3f4f6;
  color: #111827;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 14px;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: #6b7280;
  border: 1px dashed #d1d5db;
  border-radius: 14px;
  background: #ffffff;
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
}

.toast {
  padding: 10px 14px;
  border-radius: 10px;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
  animation: toast-in 0.2s ease;
}

.toast.success {
  background: var(--toast-success);
}

.toast.error {
  background: var(--toast-error);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.skeleton-card {
  position: relative;
  overflow: hidden;
  height: 220px;
  border-radius: 16px;
  background: #e5e7eb;
}

.skeleton-line {
  height: 12px;
  margin: 14px;
  border-radius: 999px;
  background: #d1d5db;
}

.skeleton-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10;
}

.overlay.show {
  display: block;
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 20;
  }

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

  .content {
    padding: 24px;
  }

  .hamburger {
    display: inline-flex;
  }
}

/* Admin styles */
.admin {
  background: #f5f6f8;
}

.admin .login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin .login-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 320px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.admin .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.admin .field input,
.admin .field select,
.admin .field textarea {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
}

.primary-btn {
  border: 0;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.ghost-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.danger-btn {
  border: 0;
  background: #ef4444;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.admin .admin-view {
  padding: 28px 32px 40px;
}

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

.admin .admin-sub {
  color: #6b7280;
  font-size: 14px;
}

.admin .admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.admin .tab-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.admin .tab-btn.active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}

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

.admin .table-wrap {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

.admin table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin thead {
  background: #f3f4f6;
}

.admin th,
.admin td {
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

.admin tbody tr:hover {
  background: #f9fafb;
}

.admin .toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin .bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px;
}

.admin .bar-row {
  display: grid;
  grid-template-columns: 200px 1fr 60px;
  gap: 12px;
  align-items: center;
}

.admin .bar-track {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.admin .bar-fill {
  height: 100%;
  background: var(--accent);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}

.modal {
  background: #ffffff;
  border-radius: 16px;
  width: min(980px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
}

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

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.step-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.step-actions button {
  border: 1px dashed #cbd5f5;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.steps-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-item {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
}

.step-item.dragging {
  opacity: 0.6;
}

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

.step-title-label {
  font-weight: 600;
}

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

.step-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-row,
.option-row,
.item-row {
  display: grid;
  grid-template-columns: 120px 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.message-row select,
.option-row input,
.item-row input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 8px;
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 780px) {
  .admin .bar-row {
    grid-template-columns: 1fr;
  }

  .message-row,
  .option-row,
  .item-row {
    grid-template-columns: 1fr;
  }
}
