@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0A0A0A;
  --bg2:      #111111;
  --bg3:      #161616;
  --surface:  rgba(201,168,76,0.06);
  --surface2: rgba(201,168,76,0.10);
  --border:   rgba(201,168,76,0.15);
  --border2:  rgba(201,168,76,0.25);
  --text:     #F5F0E8;
  --muted:    #8A7A60;
  --accent:   #C9A84C;
  --accent2:  #8B6914;
  --grad:     linear-gradient(135deg, #C9A84C, #8B6914);
  --danger:   #e05252;
  --success:  #52c27a;
  --warning:  #e0a052;
  --sidebar-w: 240px;
}

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; line-height: 1.6; min-height: 100vh; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── LAYOUT ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-logo {
  padding: 28px 24px 20px; border-bottom: 1px solid var(--border);
  font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 900;
  background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}
.sidebar-logo span { display: block; font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 500; letter-spacing: 1px; color: var(--muted); -webkit-text-fill-color: var(--muted); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s;
  text-decoration: none; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--accent); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }
.user-info { padding: 10px 12px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); margin-top: 1px; }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 60px; background: rgba(10,10,10,0.8); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 32px; position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; }
.content { padding: 32px; flex: 1; max-width: 1200px; }

/* ── SECTIONS ── */
.section { display: none; }
.section.active { display: block; }

/* ── CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 24px; transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-label { font-size: 12px; font-weight: 600; letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 36px; font-weight: 700; color: var(--text); margin-top: 8px; line-height: 1; }
.stat-value.accent { color: var(--accent); }
.stat-value.danger { color: var(--danger); }
.stat-value.success { color: var(--success); }

/* ── SECTION HEADER ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; border: none; text-decoration: none;
}
.btn-primary { background: var(--grad); color: #0A0A0A; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border2); background: var(--surface2); }
.btn-danger { background: rgba(224,82,82,0.15); border: 1px solid rgba(224,82,82,0.3); color: var(--danger); }
.btn-danger:hover { background: rgba(224,82,82,0.25); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── TABLES ── */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--border); background: var(--bg3); }
td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid rgba(201,168,76,0.06); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface); }
.td-actions { display: flex; gap: 8px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-active   { background: rgba(82,194,122,0.15); color: var(--success); border: 1px solid rgba(82,194,122,0.3); }
.badge-paused   { background: rgba(224,160,82,0.15); color: var(--warning); border: 1px solid rgba(224,160,82,0.3); }
.badge-draft    { background: rgba(138,122,96,0.15); color: var(--muted); border: 1px solid rgba(138,122,96,0.3); }
.badge-finished { background: rgba(138,122,96,0.10); color: var(--muted); border: 1px solid rgba(138,122,96,0.2); }
.badge-sent     { background: rgba(82,194,122,0.15); color: var(--success); border: 1px solid rgba(82,194,122,0.3); }
.badge-error    { background: rgba(224,82,82,0.15); color: var(--danger); border: 1px solid rgba(224,82,82,0.3); }
.badge-pending  { background: rgba(201,168,76,0.12); color: var(--accent); border: 1px solid rgba(201,168,76,0.25); }
.badge-connected    { background: rgba(82,194,122,0.15); color: var(--success); border: 1px solid rgba(82,194,122,0.3); }
.badge-disconnected { background: rgba(224,82,82,0.15); color: var(--danger); border: 1px solid rgba(224,82,82,0.3); }
.badge-suspended    { background: rgba(224,82,82,0.10); color: var(--danger); border: 1px solid rgba(224,82,82,0.2); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.3px; }
input, textarea, select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; color: var(--text); font-size: 14px; font-family: 'Inter', sans-serif;
  transition: border-color .15s; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select option { background: var(--bg2); }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  transform: translateY(16px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ── PROGRESS BAR ── */
.progress-bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--grad); border-radius: 3px; transition: width .3s; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; justify-content: center; }
.page-btn { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: all .15s; }
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--grad); color: #0A0A0A; border-color: transparent; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--muted); }

/* ── STATUS DOT ── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-green  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-red    { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.dot-yellow { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.dot-grey   { background: var(--muted); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ── ALERTS ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error   { background: rgba(224,82,82,0.12); border: 1px solid rgba(224,82,82,0.3); color: #f08080; }
.alert-success { background: rgba(82,194,122,0.12); border: 1px solid rgba(82,194,122,0.3); color: #7dd8a0; }

/* ── QR MODAL ── */
.qr-container { text-align: center; padding: 16px 0; }
.qr-container img { width: 240px; height: 240px; border-radius: 12px; background: #fff; padding: 8px; }
.qr-hint { font-size: 13px; color: var(--muted); margin-top: 12px; }

/* ── TEMPLATE LIST ── */
.template-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.template-body { font-size: 13px; color: var(--text); flex: 1; white-space: pre-wrap; word-break: break-word; }
.template-count { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 32px;
  text-align: center; cursor: pointer; transition: border-color .15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); }
.upload-zone p { color: var(--muted); font-size: 14px; margin-top: 8px; }
.upload-zone input { display: none; }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 20px; font-size: 14px; max-width: 340px;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: all .25s;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.toast-success { border-color: rgba(82,194,122,0.4); color: var(--success); }
#toast.toast-error   { border-color: rgba(224,82,82,0.4); color: var(--danger); }

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { width: auto; flex: 1; min-width: 140px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
