/* ========================================
   GhostX Pay - Main Stylesheet
   Theme: Dark Premium / Cyberpunk-lite
======================================== */

/* Google Fonts preconnect - fallback to system Thai font if unavailable */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&display=swap');

:root {
  --bg-base: #0a0a0f;
  --bg-card: #111118;
  --bg-card2: #16161f;
  --bg-input: #1a1a24;
  --border: #2a2a3a;
  --border-glow: #7c3aed44;
  --accent: #7c3aed;
  --accent2: #a855f7;
  --accent-glow: #7c3aed33;
  --accent-btn: linear-gradient(135deg, #7c3aed, #a855f7);
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --text-primary: #f0f0ff;
  --text-secondary: #8888aa;
  --text-muted: #55556a;
  /* Syne ใช้ได้เฉพาะ Latin — ต้องใส่ IBM Plex Sans Thai เป็น fallback สำหรับภาษาไทย */
  --font-display: 'Syne', 'IBM Plex Sans Thai', 'Sarabun', 'Noto Sans Thai', Arial, sans-serif;
  --font-body: 'IBM Plex Sans Thai', 'Sarabun', 'Noto Sans Thai', Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 30px rgba(124,58,237,0.15);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

/* Background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 20% -20%, rgba(124,58,237,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(168,85,247,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a { color: var(--accent2); text-decoration: none; transition: color 0.2s; }
a:hover { color: #c084fc; }

/* ===== LAYOUT ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 0 20px; }
.container-md { max-width: 800px; margin: 0 auto; padding: 0 20px; }

/* ===== NAVBAR ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-brand .logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-btn);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 16px var(--accent-glow);
}

.navbar-brand span.brand-ghost { color: var(--accent2); }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.navbar-nav a {
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.navbar-nav a:hover, .navbar-nav a.active {
  color: var(--text-primary);
  background: var(--bg-card2);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px 5px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.user-avatar {
  width: 26px;
  height: 26px;
  background: var(--accent-btn);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  font-weight: 700;
}

/* ===== SIDEBAR (Admin/Member) ===== */
.layout-wrapper {
  display: flex;
  min-height: calc(100vh - 64px);
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 4px;
  margin-top: 16px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

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

.sidebar-item.active {
  background: var(--accent-glow);
  color: var(--accent2);
  border: 1px solid var(--border-glow);
}

.sidebar-item .icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
}

.main-content {
  flex: 1;
  padding: 32px 32px;
  overflow-x: hidden;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.stat-card.purple::before { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.stat-card.green::before { background: linear-gradient(90deg, #16a34a, var(--green)); }
.stat-card.blue::before { background: linear-gradient(90deg, #1d4ed8, var(--blue)); }
.stat-card.yellow::before { background: linear-gradient(90deg, #b45309, var(--yellow)); }

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

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-icon.purple { background: rgba(124,58,237,0.15); color: var(--accent2); }
.stat-icon.green { background: rgba(34,197,94,0.12); color: var(--green); }
.stat-icon.blue { background: rgba(59,130,246,0.12); color: var(--blue); }
.stat-icon.yellow { background: rgba(245,158,11,0.12); color: var(--yellow); }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Package Cards */
.package-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.package-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.04), rgba(168,85,247,0.04));
  opacity: 0;
  transition: opacity 0.3s;
}

.package-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(124,58,237,0.2);
  transform: translateY(-3px);
}

.package-card:hover::after { opacity: 1; }

.package-card.featured {
  border-color: var(--accent);
  background: linear-gradient(135deg, #111118, #16101f);
}

.package-badge {
  position: absolute;
  top: -1px;
  right: 20px;
  background: var(--accent-btn);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 0 0 8px 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.package-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.package-price {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent2);
  margin: 12px 0 4px;
  line-height: 1;
}

.package-price span {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-body);
}

.package-duration {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.package-features {
  list-style: none;
  text-align: left;
  margin: 16px 0;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.package-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

.package-features li::before {
  content: '✓';
  color: var(--green);
  font-weight: 700;
  font-size: 0.75rem;
  background: rgba(34,197,94,0.1);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-btn);
  color: white;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124,58,237,0.45);
  color: white;
}

.btn-secondary {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-success {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  color: white;
}

.btn-warning {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  color: white;
}

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

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

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

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

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== ALERTS / FLASH ===== */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}

.alert-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.25); color: #86efac; }
.alert-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.25); color: #fcd34d; }
.alert-info { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.25); color: #93c5fd; }

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

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

.table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(42,42,58,0.5);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td {
  background: rgba(255,255,255,0.02);
  color: var(--text-primary);
}

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.badge-red { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.badge-yellow { background: rgba(245,158,11,0.12); color: var(--yellow); border: 1px solid rgba(245,158,11,0.2); }
.badge-blue { background: rgba(59,130,246,0.12); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }
.badge-purple { background: rgba(124,58,237,0.12); color: var(--accent2); border: 1px solid rgba(124,58,237,0.2); }
.badge-gray { background: rgba(85,85,106,0.2); color: var(--text-muted); border: 1px solid var(--border); }

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: 40px 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-btn);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 24px;
  box-shadow: 0 0 24px var(--accent-glow);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== UPLOAD AREA ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg-input);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: rgba(124,58,237,0.05);
}

.upload-area input[type=file] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.upload-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.upload-text strong { color: var(--accent2); }

/* ===== API KEY DISPLAY ===== */
.api-key-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  word-break: break-all;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.page-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover, .page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ===== GRID ===== */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-accent { color: var(--accent2); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--blue); }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }

.d-flex { display: flex; } .align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex-1 { flex: 1; }

.page-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

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

/* ===== COPY BUTTON ===== */
.copy-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.copy-btn:hover { border-color: var(--accent); color: var(--accent2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 20px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}
