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

:root {
  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-light: #eff6ff;
  --accent:      #7c3aed;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 20px 48px rgba(0,0,0,.14), 0 4px 16px rgba(0,0,0,.08);
  --transition:  0.18s ease;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 34px;
  height: 34px;
  background: var(--brand);
  color: #fff;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.5px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.header-actions { margin-left: auto; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,.35);
}
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 2px 8px rgba(37,99,235,.45); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-upload { cursor: pointer; }

/* ── Main ─────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  width: 100%;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text);
  line-height: 1.15;
}

.brand { color: var(--brand); }

.hero-subtitle {
  margin-top: 12px;
  font-size: 18px;
  color: var(--text-2);
  font-weight: 400;
}

/* ── Action Cards ─────────────────────────────────────────── */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 56px;
}

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

.action-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  user-select: none;
}

.action-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.action-card--primary {
  border-color: var(--brand);
  background: linear-gradient(135deg, #f0f5ff 0%, #ffffff 60%);
}
.action-card--primary:hover { border-color: var(--brand-dark); box-shadow: 0 8px 24px rgba(37,99,235,.15); }

.action-card--secondary:hover { border-color: #a5b4fc; }

.action-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-card--primary .action-card-icon {
  background: var(--brand-light);
  color: var(--brand);
}
.action-card--secondary .action-card-icon {
  background: #f5f3ff;
  color: var(--accent);
}

.action-card-icon svg { width: 26px; height: 26px; }

.action-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.action-card-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

.action-card-cta {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
}
.action-card--secondary .action-card-cta { color: var(--accent); }

/* ── Recent Designs Section ───────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

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

.design-thumb {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.design-thumb:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #a5b4fc;
}

.design-thumb-preview {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.design-thumb-info {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.design-thumb-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.design-thumb-meta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.designs-empty {
  grid-column: 1 / -1;
  padding: 48px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 24px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-3);
}

.footer-brand { font-weight: 600; color: var(--text-2); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.2s ease;
  overflow: hidden;
}

.modal--wide { max-width: 640px; }

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
  padding: 20px 24px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-2);
}

.modal-divider {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  margin: 20px 0;
  position: relative;
}
.modal-divider::before, .modal-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--border);
}
.modal-divider::before { left: 0; }
.modal-divider::after  { right: 0; }

/* ── Template Grid ────────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .template-grid { grid-template-columns: repeat(2, 1fr); }
}

.template-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.template-card:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); color: var(--brand); }
.template-card.selected { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.template-card span { padding: 8px; }

.template-preview {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.template-preview svg { width: 30px; height: 30px; }

.template-preview--blank  { background: #f1f5f9; color: #94a3b8; }
.template-preview--label  { background: #ecfdf5; color: #059669; }
.template-preview--card   { background: #fff7ed; color: #d97706; }
.template-preview--flyer  { background: #f5f3ff; color: #7c3aed; }

/* ── Inputs ───────────────────────────────────────────────── */
.input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.input::placeholder { color: var(--text-3); }

input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
input[type="file"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* ── Design List (Open modal) ─────────────────────────────── */
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.search-row .input { flex: 1; }

.designs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.design-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
}
.design-row:hover { background: var(--surface-2); }
.design-row.selected { border-color: var(--brand); background: var(--brand-light); }

.design-row-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.design-row-info { flex: 1; min-width: 0; }
.design-row-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.design-row-meta { font-size: 12px; color: var(--text-3); }

.designs-list-empty {
  padding: 48px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
