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

:root {
  --bg:         #f0f2f8;
  --white:      #ffffff;
  --blue:       #2563eb;
  --blue-light: #dbeafe;
  --text-dark:  #0f172a;
  --text-muted: #64748b;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
  --radius:     18px;
  --nav-h:      64px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ─── Top Navigation ─────────────────────────────────────────────────────────*/
.navbar {
  height: var(--nav-h);
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -.5px;
  margin-right: auto;
}

.navbar a {
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  padding: .35rem .75rem;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.navbar a:hover, .navbar a.active {
  background: var(--blue-light);
  color: var(--blue);
}

.navbar .user-pill {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg);
  border-radius: 999px;
  padding: .3rem .85rem .3rem .55rem;
  font-size: .85rem;
  font-weight: 500;
}

.navbar .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.btn-logout {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: .35rem .85rem;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: #ef4444; color: #ef4444; }

/* ─── Page wrapper ───────────────────────────────────────────────────────────*/
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: .4rem;
}
.page-sub {
  color: var(--text-muted);
  font-size: .95rem;
  margin-bottom: 2.5rem;
}

/* ─── Card Grid ──────────────────────────────────────────────────────────────*/
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

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

/* ─── Feature Card ───────────────────────────────────────────────────────────*/
.feature-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
}

.card-illustration {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* per-card gradient backgrounds */
.card-illustration.grad-blue   { background: linear-gradient(135deg,#eff6ff 0%,#dbeafe 100%); }
.card-illustration.grad-green  { background: linear-gradient(135deg,#f0fdf4 0%,#dcfce7 100%); }
.card-illustration.grad-indigo { background: linear-gradient(135deg,#eef2ff 0%,#e0e7ff 100%); }
.card-illustration.grad-orange { background: linear-gradient(135deg,#fff7ed 0%,#fed7aa 100%); }
.card-illustration.grad-violet { background: linear-gradient(135deg,#faf5ff 0%,#ede9fe 100%); }
.card-illustration.grad-teal   { background: linear-gradient(135deg,#f0fdfa 0%,#ccfbf1 100%); }

/* SVG illustrations embedded inline via CSS */
.card-illustration svg {
  max-width: 75%;
  max-height: 75%;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.08));
}

.card-body {
  padding: 1.6rem 1.8rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  flex: 1;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
}

.card-desc {
  font-size: .9rem;
  line-height: 1.6;
  color: var(--text-muted);
  flex: 1;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--blue);
  font-size: .9rem;
  font-weight: 600;
  margin-top: .4rem;
  transition: gap .15s;
}
.card-link:hover { gap: .6rem; }
.card-link svg { transition: transform .15s; }
.card-link:hover svg { transform: translateX(3px); }

/* ─── Login page ─────────────────────────────────────────────────────────────*/
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f9ff 50%, #f0fdf4 100%);
  padding: 1rem;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
  padding: 2.8rem 2.5rem;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-mark {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -.5px;
}
.login-logo .logo-mark .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  margin-top: 2px;
}

.login-card h1 {
  font-size: 1.45rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .4rem;
}
.login-card .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.1rem;
}
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text-dark);
}
.form-group input {
  width: 100%;
  padding: .72rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
  background: #f8fafc;
}
.form-group input:focus { border-color: var(--blue); background: #fff; }

.btn-primary {
  width: 100%;
  padding: .8rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .4rem;
  transition: background .15s, transform .1s;
}
.btn-primary:hover  { background: #1d4ed8; }
.btn-primary:active { transform: scale(.98); }

.error-msg {
  color: #ef4444;
  font-size: .85rem;
  text-align: center;
  margin-top: .8rem;
  min-height: 1.2em;
}

/* ─── Admin page ─────────────────────────────────────────────────────────────*/
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem 1.8rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-icon.violet { background: #ede9fe; color: #7c3aed; }

.stat-info strong { font-size: 1.6rem; font-weight: 700; display: block; }
.stat-info span   { font-size: .85rem; color: var(--text-muted); }

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.data-table th {
  background: #f8fafc;
  text-align: left;
  padding: .9rem 1.2rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid #e2e8f0;
}
.data-table td {
  padding: .85rem 1.2rem;
  font-size: .9rem;
  border-bottom: 1px solid #f1f5f9;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-admin  { background: #dbeafe; color: #2563eb; }
.badge-user   { background: #dcfce7; color: #16a34a; }
.badge-active { background: #dcfce7; color: #16a34a; }

.admin-form-card {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.8rem;
  margin-top: 1.5rem;
  max-width: 480px;
}
.admin-form-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1.2rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.btn-secondary {
  padding: .65rem 1.5rem;
  background: var(--white);
  color: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--blue-light); }

.btn-sm {
  padding: .35rem .9rem;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  font-size: .8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-sm:hover { border-color: var(--blue); color: var(--blue); }
.btn-sm.danger:hover { border-color: #ef4444; color: #ef4444; }

/* ─── Alert Messages ────────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 1.2rem;
  border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

/* ─── Form Select ────────────────────────────────────────────────────────────── */
.form-select {
  width: 100%;
  padding: .72rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color .15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
.form-select:focus { border-color: var(--blue); background-color: #fff; }

.form-hint {
  display: block;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* ─── Upload Page ────────────────────────────────────────────────────────────── */
.upload-card {
  max-width: 640px;
  margin: 2rem auto;
  text-align: center;
}
.upload-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}
.upload-zone {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 2.5rem 1.5rem;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #f8fafc;
  margin: 1.5rem 0 .5rem;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-light);
}
.upload-zone-inner { pointer-events: none; }
.upload-zone-inner p { margin: .4rem 0; color: var(--text-muted); }
.upload-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.upload-info {
  margin-top: 2rem;
  text-align: left;
  background: var(--white);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow);
}
.upload-info h3 { font-size: .95rem; font-weight: 700; margin-bottom: .75rem; }
.upload-info ul { padding-left: 1.2rem; }
.upload-info li { font-size: .88rem; color: var(--text-muted); line-height: 1.7; }

/* ─── Settings Page ──────────────────────────────────────────────────────────── */
.settings-card {
  max-width: 560px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.2rem;
}
.settings-preview {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.settings-preview-page {
  width: 120px;
  height: 170px;
  background: var(--white);
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-preview-top    { background: #bfdbfe; transition: height .2s; }
.settings-preview-content { flex: 1; display:grid; place-items:center; font-size:.6rem; color:var(--text-muted); border-top:1px dashed #e2e8f0; border-bottom:1px dashed #e2e8f0; }
.settings-preview-bottom { background: #bfdbfe; transition: height .2s; }

/* ─── Generate Page ──────────────────────────────────────────────────────────── */
.generate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 768px) {
  .generate-grid { grid-template-columns: 1fr; }
}
.customer-form {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem 2rem;
}
.prompt-preview {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem 2rem;
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
}
.prompt-preview-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.2rem;
  max-height: 420px;
  overflow-y: auto;
}
.prompt-preview-box pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: .88rem;
  line-height: 1.7;
  color: var(--text-dark);
}

/* ─── Archive Table ──────────────────────────────────────────────────────────── */
.archive-actions {
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ─── Result / Document View ─────────────────────────────────────────────────── */
.result-preview {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 700px;
}
.result-iframe {
  width: 100%;
  height: 780px;
  border: none;
  display: block;
}

/* ─── Admin Prompts ──────────────────────────────────────────────────────────── */
.template-textarea {
  width: 100%;
  min-height: 160px;
  padding: .72rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-family: 'Courier New', monospace;
  font-size: .88rem;
  line-height: 1.6;
  resize: vertical;
  background: #f8fafc;
  outline: none;
  transition: border-color .15s;
}
.template-textarea:focus { border-color: var(--blue); background: #fff; }

.placeholder-hints {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.placeholder-hints strong { font-size: .85rem; color: var(--text-muted); }
.ph-tag {
  background: var(--blue-light);
  color: var(--blue);
  font-size: .8rem;
  padding: .2rem .55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.ph-tag:hover { background: #bfdbfe; }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}
.modal-overlay.active { display: block; }

.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 12px 50px rgba(0,0,0,.18);
  padding: 2rem 2.2rem;
  width: min(640px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 300;
}
.modal.active { display: block; }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.page-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: .82rem;
  color: var(--text-muted);
  border-top: 1px solid #e2e8f0;
  margin-top: 2rem;
}
