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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #0f0f1a;
  --bg-card: #13131f;
  --bg-card2: #1a1a2e;
  --border: #2a2a3e;
  --border-glow: #7c3aed44;
  --purple: #7c3aed;
  --purple-light: #9f5cf7;
  --purple-dark: #5b21b6;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #6b7280;
  --text-dim: #94a3b8;
  --gradient: linear-gradient(135deg, #7c3aed, #ec4899);
  --gradient2: linear-gradient(135deg, #06b6d4, #7c3aed);
  --glow-purple: 0 0 30px #7c3aed55;
  --glow-pink: 0 0 30px #ec489955;
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-lg: 20px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 3px; }

/* ---- Typography ---- */
h1,h2,h3,h4,h5,h6 { font-family: 'Space Grotesk', sans-serif; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: 10px; font-weight: 600; font-size: 14px;
  border: none; cursor: pointer; transition: all 0.3s ease; text-decoration: none;
  position: relative; overflow: hidden; white-space: nowrap;
}
.btn::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0.1); opacity: 0; transition: opacity 0.2s;
}
.btn:hover::before { opacity: 1; }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 20px #7c3aed44;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px #7c3aed66; }

.btn-success { background: linear-gradient(135deg,#10b981,#059669); color:#fff; }
.btn-danger  { background: linear-gradient(135deg,#ef4444,#dc2626); color:#fff; }
.btn-warning { background: linear-gradient(135deg,#f59e0b,#d97706); color:#fff; }
.btn-cyan    { background: linear-gradient(135deg,#06b6d4,#0284c7); color:#fff; }
.btn-ghost   { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--purple); color: var(--purple-light); }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s;
}
.card:hover { border-color: var(--border-glow); }
.card-glow { border-color: var(--border-glow); box-shadow: var(--glow-purple), var(--shadow-card); }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px;
}
.form-control {
  width: 100%; padding: 12px 16px;
  background: var(--bg-secondary); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: 'Inter', sans-serif;
  transition: all 0.3s;
}
.form-control:focus {
  outline: none; border-color: var(--purple);
  box-shadow: 0 0 0 3px #7c3aed22;
  background: var(--bg-card2);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-success { background: #10b98122; color: #10b981; border: 1px solid #10b98144; }
.badge-danger  { background: #ef444422; color: #ef4444; border: 1px solid #ef444444; }
.badge-warning { background: #f59e0b22; color: #f59e0b; border: 1px solid #f59e0b44; }
.badge-purple  { background: #7c3aed22; color: #a78bfa; border: 1px solid #7c3aed44; }
.badge-cyan    { background: #06b6d422; color: #06b6d4; border: 1px solid #06b6d444; }
.badge-gray    { background: #6b728022; color: #9ca3af; border: 1px solid #6b728044; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--bg-card2); }
thead th {
  padding: 12px 16px; text-align: left;
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
tbody tr:hover { background: var(--bg-card2); }
tbody td { padding: 14px 16px; color: var(--text-dim); vertical-align: middle; }
tbody td strong { color: var(--text); }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 20px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative; overflow: hidden;
  transition: all 0.3s;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient);
}
.stat-card:hover { transform: translateY(-4px); border-color: var(--border-glow); box-shadow: var(--glow-purple); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
  background: var(--bg-card2);
}
.stat-value { font-size: 28px; font-weight: 800; font-family: 'Space Grotesk',sans-serif; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; letter-spacing: 0.5px; }

/* ---- Notification Toast ---- */
#toast-container {
  position: fixed; top: 24px; right: 24px;
  z-index: 99999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-radius: 14px;
  min-width: 320px; max-width: 420px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: slideIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
  position: relative; overflow: hidden;
}
.toast::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.toast-success::before { background: var(--green); }
.toast-error::before   { background: var(--red); }
.toast-warning::before { background: var(--yellow); }
.toast-info::before    { background: var(--purple); }
.toast-icon { font-size: 22px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 700; font-size: 14px; color: var(--text); }
.toast-msg   { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; flex-shrink: 0;
  transition: color 0.2s; line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast.hiding { animation: slideOut 0.3s ease forwards; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* ---- Sidebar Layout ---- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--bg-secondary);
  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;
}
.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--gradient); display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0; color: #fff;
}
.sidebar-title { font-family: 'Space Grotesk',sans-serif; font-weight: 700; font-size: 16px; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-section { margin-bottom: 24px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0 8px; margin-bottom: 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all 0.2s; margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active {
  background: linear-gradient(135deg, #7c3aed22, #ec489922);
  color: var(--purple-light);
  border: 1px solid #7c3aed33;
}
.nav-link .nav-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  transition: all 0.2s;
  color: var(--text-muted);
}
.nav-link:hover .nav-icon {
  background: var(--bg-card);
  border-color: var(--border-glow);
  color: var(--purple-light);
}
.nav-link.active .nav-icon {
  background: linear-gradient(135deg,#7c3aed33,#ec489933);
  border-color: #7c3aed55;
  color: var(--purple-light);
}
.nav-badge {
  margin-left: auto; background: var(--purple); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-card); margin-bottom: 8px;
}
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--gradient); display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar-user-name { font-weight: 600; font-size: 14px; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ---- Main Content ---- */
.main-content {
  margin-left: 260px; flex: 1;
  display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
  height: 64px; padding: 0 28px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.topbar-title { font-size: 20px; font-weight: 700; font-family: 'Space Grotesk',sans-serif; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.credit-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 10px;
  background: var(--bg-card2); border: 1px solid var(--border);
  font-weight: 700; font-size: 15px; color: var(--green);
}

.page-content { padding: 28px; flex: 1; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  background: var(--bg-card2); border: 1px solid var(--border);
  color: var(--text-muted); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }

/* ---- Duration Row ---- */
.duration-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 10px; align-items: center; margin-bottom: 10px;
}
.duration-remove {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--red); border: none;
  color: #fff; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.duration-remove:hover { background: #dc2626; transform: scale(1.1); }

/* ---- Glow text ---- */
.glow-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Section header ---- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { font-size: 18px; font-weight: 700; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; color: var(--text-dim); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ---- Product card public ---- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 24px; }
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s;
  position: relative;
}
.product-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-glow);
  box-shadow: var(--glow-purple), var(--shadow-card);
}
.product-card-img {
  height: 180px; background: var(--bg-card2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.product-card-img img { width:100%; height:100%; object-fit:cover; }
.product-card-img .no-img { font-size: 48px; opacity: 0.3; }
.product-card-body { padding: 20px; }
.product-card-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.product-card-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 16px; }
.product-card-prices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.price-tag {
  padding: 4px 12px; border-radius: 20px;
  background: var(--bg-card2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
}
.price-tag span { color: var(--purple-light); }

/* ---- Key display ---- */
.key-box {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px; color: var(--cyan);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.copy-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
  transition: color 0.2s; flex-shrink: 0;
}
.copy-btn:hover { color: var(--purple-light); }

/* ---- Login page ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 20% 50%, #7c3aed15 0%, transparent 50%),
                    radial-gradient(ellipse at 80% 20%, #ec489915 0%, transparent 50%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--gradient); display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 30px; margin-bottom: 16px;
  box-shadow: 0 8px 32px #7c3aed44;
}
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); }

/* ---- Dividers ---- */
.divider {
  height: 1px; background: var(--border); margin: 20px 0;
}

/* ---- File upload ---- */
.file-upload-wrapper {
  position: relative;
}
.file-upload-label {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  border: 2px dashed var(--border); cursor: pointer;
  transition: all 0.3s; background: var(--bg-secondary);
  font-size: 14px; color: var(--text-muted);
}
.file-upload-label:hover { border-color: var(--purple); color: var(--purple-light); }
.file-upload-input { display: none; }
.file-name { flex: 1; }

/* ---- Global Confirm Modal ---- */
#confirm-overlay {
  position: fixed; inset: 0; z-index: 99998;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#confirm-overlay.open { opacity: 1; pointer-events: all; }
#confirm-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  width: 90%; max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  transform: scale(0.88) translateY(24px);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
}
#confirm-overlay.open #confirm-box { transform: scale(1) translateY(0); }
#confirm-icon-wrap {
  width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 18px;
}
#confirm-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
#confirm-message { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }
#confirm-actions { display: flex; gap: 12px; }
#confirm-actions .btn { flex: 1; }

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.4s ease; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
.pulse { animation: pulse 2s infinite; }

/* ---- Loader ---- */
.loader {
  width: 20px; height: 20px; border: 2px solid #ffffff33;
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Credit Amount Colors ---- */
.amount-positive { color: var(--green); font-weight: 700; }
.amount-negative { color: var(--red); font-weight: 700; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* --- scrollbar for modal --- */
.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 2px; }

/* ---- Tab Navigation ---- */
.tab-nav {
  display: flex; gap: 4px;
  background: var(--bg-card2); border-radius: 12px;
  padding: 4px; margin-bottom: 24px;
  border: 1px solid var(--border);
}
.tab-btn {
  flex: 1; padding: 9px 16px; border-radius: 9px;
  border: none; background: transparent;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; font-family: 'Inter',sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab-btn.active {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 16px #7c3aed44;
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeInUp 0.3s ease; }
