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

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #273549;
  --border:    #334155;
  --primary:   #3b82f6;
  --primary-h: #2563eb;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --text:      #f1f5f9;
  --text-sm:   #94a3b8;
  --radius:    8px;
  --shadow:    0 4px 20px rgba(0,0,0,.4);
}

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

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

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.btn-success  { background: var(--success);  color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #dc2626; }
.btn-warning  { background: var(--warning);  color: #000; }
.btn-ghost    { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 6px; }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
label { font-size: 13px; font-weight: 500; color: var(--text-sm); }
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 9px 12px;
  font-size: 14px; width: 100%; transition: border-color .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
}
input[type="color"] { padding: 4px; height: 38px; cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }

/* ─── Auth page ─────────────────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 { font-size: 28px; font-weight: 700; color: var(--primary); }
.auth-logo p  { color: var(--text-sm); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 28px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; text-align: center; padding: 10px; cursor: pointer;
  color: var(--text-sm); font-weight: 500; border-bottom: 2px solid transparent;
  transition: all .15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-error {
  background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 16px; display: none;
}
.auth-error.show { display: block; }

/* ─── Topnav ────────────────────────────────────────────── */
.topnav {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 100;
}
.topnav-brand { font-size: 20px; font-weight: 700; color: var(--primary); }
.topnav-right { display: flex; align-items: center; gap: 12px; }
.topnav-user { font-size: 13px; color: var(--text-sm); }

/* ─── Dashboard ─────────────────────────────────────────── */
.dashboard-main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h2 { font-size: 22px; font-weight: 600; }
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.card-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; transition: border-color .15s, transform .15s;
}
.card-item:hover { border-color: var(--primary); transform: translateY(-2px); }
.card-thumb {
  width: 100%; aspect-ratio: 1.75; background: var(--surface2);
  object-fit: cover; display: block;
}
.card-thumb-placeholder {
  width: 100%; aspect-ratio: 1.75; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sm); font-size: 12px;
}
.card-info { padding: 12px 14px; }
.card-info h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.card-meta { font-size: 11px; color: var(--text-sm); margin-bottom: 10px; }
.card-actions { display: flex; gap: 6px; }
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-sm); grid-column: 1/-1;
}
.empty-state p { margin-bottom: 16px; }

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; width: 100%; max-width: 520px;
  box-shadow: var(--shadow); transform: translateY(10px); transition: transform .2s;
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-sm); cursor: pointer; font-size: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ─── Alert / Toast ─────────────────────────────────────── */
.toast-container {
  position: fixed; top: 70px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius); font-size: 13px;
  font-weight: 500; box-shadow: var(--shadow); animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error   { background: var(--danger);  color: #fff; }
.toast.info    { background: var(--primary); color: #fff; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── QR tabs ───────────────────────────────────────────── */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn {
  padding: 8px 18px; cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text-sm); border-bottom: 2px solid transparent; transition: all .15s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── Designer layout ───────────────────────────────────── */
.designer-layout {
  display: grid;
  grid-template-columns: 210px 1fr 220px;
  grid-template-rows: 60px 1fr;
  height: 100vh;
}
.designer-topbar {
  grid-column: 1 / -1; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
}
.designer-topbar .card-name-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 6px 12px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; width: 200px;
}
.designer-topbar .spacer { flex: 1; }
.designer-left {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px; overflow-y: auto;
}
.designer-left h4, .designer-right h4 {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-sm); margin-bottom: 10px;
}
.tool-btn {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 7px; cursor: pointer; border: none;
  background: transparent; color: var(--text); font-size: 13px;
  transition: background .12s; margin-bottom: 2px;
}
.tool-btn:hover { background: var(--surface2); }
.tool-icon { font-size: 16px; width: 20px; text-align: center; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.designer-canvas-area {
  background: #2a2a2a; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 30px;
}
.canvas-wrapper { box-shadow: 0 8px 40px rgba(0,0,0,.7); position: relative; }
.designer-right {
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 14px; overflow-y: auto;
}
.prop-row { margin-bottom: 12px; }
.prop-row label { font-size: 11px; color: var(--text-sm); display: block; margin-bottom: 4px; }
.prop-row input, .prop-row select { width: 100%; font-size: 13px; padding: 6px 9px; }
.prop-row input[type="color"] { padding: 3px; height: 34px; }
.prop-row input[type="range"] { padding: 0; }
.prop-inline { display: flex; gap: 6px; }
.prop-inline > * { flex: 1; }
.toggle-group { display: flex; gap: 4px; }
.toggle-btn {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 5px;
  background: transparent; color: var(--text-sm); cursor: pointer; font-size: 13px;
  transition: all .12s;
}
.toggle-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#props-empty {
  color: var(--text-sm); font-size: 12px; text-align: center;
  margin-top: 40px; line-height: 1.7;
}
.qr-preview { text-align: center; margin-top: 14px; }
.qr-preview img { border-radius: var(--radius); box-shadow: var(--shadow); }

/* ─── Admin layout ──────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.admin-sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 24px 0;
}
.admin-sidebar .brand {
  padding: 0 20px 20px; font-size: 18px; font-weight: 700; color: var(--primary);
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-sm); cursor: pointer;
  font-size: 14px; transition: all .12s; border-left: 3px solid transparent;
}
.admin-nav-item:hover  { background: var(--surface2); color: var(--text); }
.admin-nav-item.active { background: var(--surface2); color: var(--primary); border-left-color: var(--primary); }
.admin-main { padding: 32px; overflow-y: auto; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; text-align: center;
}
.stat-card .stat-num { font-size: 36px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-sm); margin-top: 4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 14px; background: var(--surface2);
  border-bottom: 1px solid var(--border); color: var(--text-sm); font-weight: 600;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-admin  { background: rgba(59,130,246,.2); color: #93c5fd; }
.badge-user   { background: rgba(148,163,184,.1); color: var(--text-sm); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-header h2 { font-size: 18px; font-weight: 600; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .designer-layout { grid-template-columns: 1fr; grid-template-rows: 60px auto 1fr auto; }
  .designer-left, .designer-right { display: none; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
}
