/* ============================================================
   MikroVoucher — Main Stylesheet
   Modern, elegant dengan tema warna switchable
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Variables (tema default: hijau) ---- */
:root {
  --primary:        #16a34a;
  --primary-dark:   #15803d;
  --primary-light:  #dcfce7;
  --primary-glow:   rgba(22, 163, 74, 0.20);

  --bg:             #0d1117;
  --bg-card:        #161b22;
  --bg-card2:       #1c2128;
  --bg-input:       #21262d;
  --border:         #30363d;
  --border-light:   #21262d;

  --text:           #e6edf3;
  --text-muted:     #8b949e;
  --text-dim:       #484f58;

  --success:        #2ea043;
  --warning:        #e3b341;
  --danger:         #f85149;
  --info:           #58a6ff;

  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --shadow:         0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.4);
  --transition:     .2s cubic-bezier(.4,0,.2,1);

  --sidebar-w:      240px;
  --font:           'Plus Jakarta Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;
}

/* Tema Biru */
[data-theme="blue"] {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --primary-glow:  rgba(37, 99, 235, 0.20);
  --success:       #3b82f6;
}

/* Tema Merah */
[data-theme="red"] {
  --primary:       #dc2626;
  --primary-dark:  #b91c1c;
  --primary-light: #fee2e2;
  --primary-glow:  rgba(220, 38, 38, 0.20);
  --success:       #ef4444;
}

/* Tema Ungu */
[data-theme="purple"] {
  --primary:       #7c3aed;
  --primary-dark:  #6d28d9;
  --primary-light: #ede9fe;
  --primary-glow:  rgba(124, 58, 237, 0.20);
  --success:       #8b5cf6;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

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

img { max-width: 100%; }

/* ---- Layout ---- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px var(--primary-glow);
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.sidebar-logo .logo-ver {
  font-size: .65rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Router selector */
.router-selector {
  padding: 12px 14px;
  margin: 12px;
  background: var(--bg-input);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.router-selector:hover { border-color: var(--primary); }

.router-selector .rs-label {
  font-size: .68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}

.router-selector .rs-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.router-selector .rs-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }

/* Nav */
.sidebar-nav {
  padding: 8px 10px;
  flex: 1;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  padding: 10px 8px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(255,255,255,.05);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

/* Sidebar bottom */
.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.theme-switcher {
  display: flex;
  gap: 6px;
  padding: 8px 4px 4px;
  justify-content: center;
}

.theme-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  outline: none;
}

.theme-btn:hover { transform: scale(1.2); }
.theme-btn.active { border-color: var(--text); }

.theme-btn[data-theme="green"]  { background: #16a34a; }
.theme-btn[data-theme="blue"]   { background: #2563eb; }
.theme-btn[data-theme="red"]    { background: #dc2626; }
.theme-btn[data-theme="purple"] { background: #7c3aed; }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--bg-input);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 600; color: var(--text); }
.user-role { font-size: .68rem; color: var(--text-muted); text-transform: capitalize; }

/* ---- Main Content ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
}

.breadcrumb span { color: var(--text-dim); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Page Content ---- */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: 3px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-card2);
}

/* ---- Stat Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: var(--primary-glow);
  border-radius: 50%;
  transform: translate(20px, -20px);
}

.stat-icon {
  width: 40px; height: 40px;
  background: var(--primary-glow);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead th {
  background: var(--bg-card2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card2); }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.td-mono {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--primary);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
}

.badge-success { background: rgba(46, 160, 67, .18); color: #3fb950; border: 1px solid rgba(46,160,67,.3); }
.badge-danger  { background: rgba(248, 81, 73, .15); color: #f85149; border: 1px solid rgba(248,81,73,.3); }
.badge-warning { background: rgba(227, 179, 65, .15); color: #e3b341; border: 1px solid rgba(227,179,65,.3); }
.badge-info    { background: rgba(88, 166, 255, .15); color: #58a6ff; border: 1px solid rgba(88,166,255,.3); }
.badge-muted   { background: var(--bg-card2); color: var(--text-muted); border: 1px solid var(--border); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
}
.btn-ghost:hover { background: var(--bg-card2); color: var(--text); }

.btn-danger {
  background: rgba(248,81,73,.15);
  color: var(--danger);
  border: 1px solid rgba(248,81,73,.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: .76rem; }
.btn-lg { padding: 11px 22px; font-size: .92rem; }
.btn-icon { padding: 8px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .87rem;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder { color: var(--text-dim); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-hint {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: 5px;
}

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

/* ---- Alert ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: rgba(46,160,67,.15); border: 1px solid rgba(46,160,67,.3); color: #3fb950; }
.alert-danger  { background: rgba(248,81,73,.12); border: 1px solid rgba(248,81,73,.3); color: #f85149; }
.alert-warning { background: rgba(227,179,65,.12); border: 1px solid rgba(227,179,65,.3); color: #e3b341; }
.alert-info    { background: rgba(88,166,255,.12); border: 1px solid rgba(88,166,255,.3); color: #58a6ff; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-body  { padding: 24px; }

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

/* ---- Search & Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
}

.search-input {
  padding-left: 36px !important;
}

/* ---- Loading ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(13,17,23,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

/* ---- Voucher Print Styles ---- */
.voucher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.voucher-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}

.voucher-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow);
}

.voucher-card.selected {
  border-color: var(--primary);
  background: rgba(22,163,74,.08);
}

.voucher-card .vc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.voucher-code {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
}

.voucher-pass {
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--text-muted);
}

.vc-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.vc-meta-item {
  font-size: .72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Misc ---- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: .4;
}

.empty-state h3 { font-size: 1rem; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: .85rem; }

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .72rem;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}

.tooltip:hover::after { opacity: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); font-size: .83rem; }
.fw-700 { font-weight: 700; }
.w-full { width: 100%; }

/* ---- Sidebar Mobile Toggle ---- */
.menu-toggle {
  display: none;
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.5);
  }

  .main { margin-left: 0; }

  .menu-toggle { display: flex; }

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

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .page-content { padding: 16px; }

  .topbar { padding: 0 16px; }
}

/* ============================================================
   PRINT STYLES — untuk cetak voucher
   ============================================================ */
@media print {
  body, .app-wrapper {
    background: #fff !important;
    color: #000 !important;
  }

  .sidebar, .topbar, .page-header .btn,
  .filter-bar, .no-print { display: none !important; }

  .main { margin-left: 0 !important; }

  .page-content { padding: 0 !important; }

  .voucher-print-area {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 4mm;
    page-break-inside: avoid;
  }

  .voucher-print-card {
    border: 1.5px solid #ddd !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    background: #fff !important;
    color: #000 !important;
    page-break-inside: avoid;
    font-family: Arial, sans-serif;
  }
}
