/* ===================================================
   QRGen — Main Stylesheet
   =================================================== */

/* ----- Variables ----- */
:root {
  --bg:           #0f172a;
  --bg-card:      #1e293b;
  --bg-input:     #0f172a;
  --bg-hover:     #2d3f55;
  --border:       #334155;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --accent:       #6366f1;
  --accent-dark:  #4f46e5;
  --accent-glow:  rgba(99, 102, 241, 0.2);
  --success:      #22c55e;
  --error:        #ef4444;
  --warning:      #f59e0b;
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
  --shadow:       0 4px 24px rgba(0, 0, 0, 0.35);
  --transition:   180ms ease;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); }
img, svg { display: block; max-width: 100%; }

/* ----- Layout ----- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ----- Header ----- */
.header {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.9rem 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  flex-shrink: 0;
}

/* ----- Main ----- */
.main { flex: 1; padding: 3rem 0 4rem; }

/* ----- Hero ----- */
.hero {
  text-align: center;
  margin-bottom: 2.75rem;
}
.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  background: linear-gradient(135deg, #f1f5f9 30%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.6rem;
  line-height: 1.2;
}
.hero p {
  color: var(--text-muted);
  font-size: 1.0625rem;
  max-width: 480px;
  margin: 0 auto;
}

/* ----- Generator grid ----- */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 780px) {
  .generator-grid { grid-template-columns: 1fr; }
}

/* ----- Card ----- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

/* ----- Forms ----- */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  padding: 0.6875rem 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: vertical; min-height: 90px; }
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2394a3b8' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}
.char-count {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ----- Options grid ----- */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
.span-2 { grid-column: span 2; }

/* ----- Range ----- */
input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
  margin-top: 0.35rem;
  padding: 0;
  border: none;
  box-shadow: none;
}

/* ----- Color picker ----- */
.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.875rem;
  cursor: pointer;
  transition: border-color var(--transition);
}
.color-input-wrapper:hover { border-color: var(--accent); }
.color-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.color-input-wrapper input[type="color"] {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}
.color-input-wrapper span {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition), color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
  color: #fff;
  text-decoration: none;
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.6rem 1rem;
  font-size: 0.9375rem;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.btn-sm {
  padding: 0.45rem 0.875rem;
  font-size: 0.8125rem;
}
.btn-full { width: 100%; }

/* ----- Preview panel ----- */
.preview-panel { display: flex; flex-direction: column; }
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.preview-header h3 {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.preview-actions { display: flex; gap: 0.5rem; }
.preview-area {
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow: hidden;
}
.preview-area svg,
.preview-area img {
  max-width: 100%;
  max-height: 380px;
  height: auto;
  width: auto;
}
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  opacity: 0.45;
  user-select: none;
}
.preview-placeholder p { font-size: 0.875rem; }

/* ----- Toasts ----- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  max-width: 300px;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease forwards;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}
.toast.removing { animation: toastOut 0.2s ease forwards; }

/* ----- Footer ----- */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: auto;
}

/* ----- 404 error page ----- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
  gap: 0.75rem;
}
.error-code {
  font-size: 7rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.35;
  line-height: 1;
}
.error-page h2 { font-size: 1.5rem; }
.error-page p  { color: var(--text-muted); margin-bottom: 1.25rem; }

/* ===================================================
   Auth pages (login)
   =================================================== */
.auth-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.auth-container { width: 100%; max-width: 420px; }
.auth-card { padding: 2.25rem 2rem; }
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-decoration: none;
}
.auth-logo:hover { text-decoration: none; }
.auth-header { text-align: center; margin-bottom: 1.75rem; }
.auth-header h1 { font-size: 1.375rem; font-weight: 700; margin-bottom: 0.35rem; }
.auth-header p  { color: var(--text-muted); font-size: 0.9375rem; }
.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.auth-footer a { color: var(--text-muted); }
.auth-footer a:hover { color: var(--text); }

/* Password toggle */
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 4.5rem; }
.toggle-password {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.875rem;
  font-size: 0.8125rem;
  font-family: var(--font);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background var(--transition), color var(--transition);
}
.toggle-password:hover { background: var(--bg-hover); color: var(--text); }

/* Inline error message */
.error-message {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ===================================================
   Admin layout (dashboard)
   =================================================== */
.admin-body {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.admin-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.nav-brand::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success);
}
.nav-actions { display: flex; gap: 0.5rem; align-items: center; }

.admin-main { flex: 1; padding: 2.25rem 0 3rem; }

.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.625rem; font-weight: 700; margin-bottom: 0.2rem; }
.page-header p   { color: var(--text-muted); font-size: 0.9375rem; }

/* ----- Stats grid ----- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  font-size: 1.75rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.stat-icon.total { background: rgba(99, 102, 241, 0.15); }
.stat-icon.today { background: rgba(34, 197, 94, 0.15); }
.stat-icon.week  { background: rgba(245, 158, 11, 0.15); }
.stat-value { font-size: 1.875rem; font-weight: 700; line-height: 1; margin-bottom: 0.2rem; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); }

/* ----- Card header ----- */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }

/* ----- Data table ----- */
.table-wrapper { overflow-x: auto; margin: -1.75rem; padding: 0; margin-top: 0; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.7rem 1.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.825rem 1.75rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.time-cell    { color: var(--text-muted); white-space: nowrap; font-size: 0.8125rem; width: 180px; }
.content-cell { font-family: 'Courier New', monospace; font-size: 0.8125rem; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-center  { text-align: center; color: var(--text-muted); padding: 2rem 1.75rem; }
