/* ============================================
   WebApp Store - Main Stylesheet
   Modern, Clean App Store Design
   ============================================ */

/* Google Fonts loaded in header.php */

:root {
  --primary: #0166fe;
  --primary-light: #3d88fe;
  --primary-dark: #0050cc;
  --primary-bg: #e8f0fe;
  --secondary: #fe7201;
  --secondary-light: #ff9234;
  --secondary-dark: #cc5a00;
  --secondary-bg: #fff0e6;
  --success: #10B981;
  --success-bg: #D1FAE5;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  --purple: #8B5CF6;
  --purple-bg: #EDE9FE;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --bg-main: #F8FAFC;
  --bg-white: #FFFFFF;
  --bg-card: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-blue: 0 8px 24px rgba(1,102,254,0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --font-main: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --nav-h: 64px;
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

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

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-main); }

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
}

/* LOGO */
.navbar-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  line-height: 1;
}

.navbar-logo-img {
  height: 72px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* CENTER NAV */
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.navbar-nav a {
  display: flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

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

/* RIGHT ACTIONS — always visible, fixed width */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.btn-nav-login {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.btn-nav-login:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-nav-signup {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 3px 10px rgba(1,102,254,0.28);
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.btn-nav-signup:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(1,102,254,0.38);
}

/* HAMBURGER — hidden on desktop */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.25s ease;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================
   CONTAINER
   ============================================ */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
  background: linear-gradient(135deg, #0050cc 0%, #0166fe 50%, #3d88fe 100%);
  padding: 72px 0 80px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 500px;
  height: 500px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -60px;
  width: 300px;
  height: 300px;
  background: rgba(254,114,1,0.15);
  border-radius: 50%;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255,255,255,0.2);
  margin-bottom: 20px;
}

.hero h1 {
  font-family: var(--font-main);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero h1 span {
  color: var(--secondary-light);
}

.hero p {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.85);
  max-width: 520px;
  margin: 0 auto 32px;
}

.hero-search {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  background: #fff;
  border-radius: var(--radius-full);
  padding: 6px 6px 6px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.hero-search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: transparent;
  color: var(--text-primary);
}

.hero-search input::placeholder { color: var(--text-muted); }

.hero-search button {
  background: var(--secondary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 10px 24px;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all var(--transition);
}

.hero-search button:hover {
  background: var(--secondary-dark);
  transform: scale(1.02);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat .num {
  font-family: var(--font-main);
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
}

.hero-stat .label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

/* ============================================
   SECTION STYLES
   ============================================ */
.section {
  padding: 60px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-family: var(--font-main);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .dot {
  width: 8px;
  height: 8px;
  background: var(--secondary);
  border-radius: 50%;
}

.section-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition);
}

.section-link:hover { gap: 8px; }

/* ============================================
   CATEGORY FILTER
   ============================================ */
.category-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-white);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.cat-btn:hover, .cat-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

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

/* ============================================
   APP CARD
   ============================================ */
.app-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.app-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.app-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.app-card:hover::before {
  transform: scaleX(1);
}

.app-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.app-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.app-icon-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
  font-family: var(--font-main);
}

.app-card-info {
  flex: 1;
  min-width: 0;
}

.app-card-name {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.app-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 14px;
}

.app-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.access-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.app-card-price {
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.app-card-price .price-free {
  color: var(--success);
}

.btn-card {
  padding: 6px 14px;
  background: var(--primary-bg);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  transition: all var(--transition);
}

.btn-card:hover {
  background: var(--primary);
  color: #fff;
}

/* Featured badge */
.badge-featured {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   LOAD MORE
   ============================================ */
.load-more-wrap {
  text-align: center;
  margin-top: 40px;
}

.btn-load-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  background: transparent;
  transition: all var(--transition);
}

.btn-load-more:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-blue);
}

.btn-load-more.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-main);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(1,102,254,0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(1,102,254,0.4);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(254,114,1,0.3);
}

.btn-secondary:hover {
  background: var(--secondary-dark);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff;
}

.btn-ghost {
  background: var(--border-light);
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover {
  background: var(--border);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover { opacity: 0.9; }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 16px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

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

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-family: var(--font-main);
}

.form-label span.req {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-white);
  transition: all var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1,102,254,0.1);
}

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

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

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

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 5px;
}

.input-group {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-group .form-control {
  padding-left: 40px;
}

/* OTP inputs */
.otp-group {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.otp-input {
  width: 52px;
  height: 60px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-main);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition);
  background: var(--bg-white);
}

.otp-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1,102,254,0.1);
}

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-wrap {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, var(--bg-main) 0%, #e8f0fe 100%);
}

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

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

.auth-logo .logo-mark {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 16px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-logo h2 {
  font-family: var(--font-main);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-divider {
  text-align: center;
  position: relative;
  margin: 20px 0;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  background: var(--bg-white);
  padding: 0 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  position: relative;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   DETAIL PAGE
   ============================================ */
.detail-hero {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 40px 0;
}

.detail-hero-inner {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  flex-wrap: wrap;
}

.detail-icon {
  width: 100px;
  height: 100px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.detail-info {
  flex: 1;
  min-width: 200px;
}

.detail-info h1 {
  font-family: var(--font-main);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.detail-meta .cat-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.detail-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 600px;
}

.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.detail-body {
  padding: 40px 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
}

.detail-section {
  margin-bottom: 32px;
}

.detail-section h3 {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.features-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.features-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.features-list li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Pricing card */
.pricing-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: sticky;
  top: calc(var(--nav-h) + 20px);
}

.pricing-card h3 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 16px;
  border: none;
  padding: 0;
}

.plan-option {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.plan-option:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.plan-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.plan-option .plan-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.plan-option .plan-price {
  font-family: var(--font-main);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.plan-option .plan-price small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.plan-option .plan-save {
  position: absolute;
  top: -8px;
  right: 10px;
  background: var(--secondary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.updated-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}

/* ============================================
   MEMBER DASHBOARD
   ============================================ */
.dashboard-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - var(--nav-h));
  gap: 0;
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.sidebar {
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 28px 0;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

.sidebar-user {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-user .avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  font-family: var(--font-main);
  margin-bottom: 10px;
}

.sidebar-user .user-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.sidebar-user .user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  list-style: none;
  padding: 0 12px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.sidebar-nav li a:hover, .sidebar-nav li a.active {
  background: var(--primary-bg);
  color: var(--primary);
}

.sidebar-nav li a .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.dashboard-main {
  padding: 28px 32px;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}

.page-title {
  font-family: var(--font-main);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================
   CARDS / PANELS
   ============================================ */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-title {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* ============================================
   ADMIN PANEL
   ============================================ */
.admin-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

/* ---- ADMIN SIDEBAR ---- */
.admin-sidebar {
  background: #111827;
  padding: 24px 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  z-index: 150;
  flex-shrink: 0;
  /* Desktop: sticky sidebar */
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.admin-sidebar .admin-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}

.admin-sidebar .admin-brand h3 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-sidebar .admin-brand p {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-nav {
  list-style: none;
  padding: 0 10px;
}

.admin-nav li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.admin-nav li a:hover,
.admin-nav li a.active {
  background: rgba(1,102,254,0.2);
  color: #93c5fd;
}

/* ---- ADMIN MAIN CONTENT ---- */
.admin-main {
  padding: 24px 28px;
  background: var(--bg-main);
  min-width: 0;           /* สำคัญ: ป้องกัน content กว้างเกิน grid column */
  overflow-x: hidden;     /* ป้องกัน horizontal scroll */
  width: 100%;
  box-sizing: border-box;
}

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

/* ---- HAMBURGER BUTTON ---- */
/* แสดงเสมอ — CSS จะซ่อนใน desktop ด้วย @media min-width */
.admin-menu-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 7px;
  transition: background 0.2s;
  font-size: 0;         /* ซ่อน text label */
  flex-shrink: 0;
}
.admin-menu-toggle:hover  { background: rgba(255,255,255,0.15); }
.admin-menu-toggle:active { background: rgba(255,255,255,0.2); }

/* ---- SIDEBAR OVERLAY ---- */
.admin-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55);
  z-index: 149;
  -webkit-tap-highlight-color: transparent;
}
.admin-sidebar-overlay.open { display: block; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-bg); color: var(--primary); }
.stat-icon.orange { background: var(--secondary-bg); color: var(--secondary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-info .num {
  font-family: var(--font-main);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-info .lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   TABLE
   ============================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

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

table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--border-light);
}

table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

table tr:hover td {
  background: var(--border-light);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--border-light); color: var(--text-muted); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-suspended { background: var(--danger-bg); color: var(--danger); }

.actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
}

.pagination a {
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination span.current {
  background: var(--primary);
  color: #fff;
  border: none;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  background: #111827;
  color: rgba(255,255,255,0.7);
  padding: 48px 0 24px;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 40px;
}

.footer-brand h3 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 10px;
}

.footer-brand p {
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer-col h4 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  margin-bottom: 14px;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-col ul a {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  transition: color var(--transition);
}

.footer-col ul a:hover { color: var(--primary-light); }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
}

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SKELETON LOADER
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* mobile-menu base: ซ่อนเสมอจนกว่าจะ open */
.mobile-menu {
  display: none;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* ---- DESKTOP ≥1025px ---- */
@media (min-width: 1025px) {
  /* navbar */
  .nav-toggle     { display: none !important; }
  .mobile-menu    { display: none !important; }
  .navbar-nav     { display: flex !important; }
  .navbar-actions { display: flex !important; }
  /* admin: ซ่อน hamburger บน desktop */
  .admin-menu-toggle       { display: none !important; }
  .admin-sidebar-overlay   { display: none !important; }
}

/* ---- TABLET 769-1024px ---- */
@media (max-width: 1024px) {
  /* page grid */
  .apps-grid    { grid-template-columns: repeat(3, 1fr); }
  .footer-grid  { grid-template-columns: repeat(2, 1fr); }
  .detail-grid  { grid-template-columns: 1fr; }
  .pricing-card { position: static; }

  /* navbar */
  .navbar-nav     { display: none; }
  .nav-toggle     { display: flex; }
  .navbar-actions { display: flex; }

  /* Member dashboard: ย่อ sidebar */
  .dashboard-wrap { grid-template-columns: 200px 1fr; }
  .dashboard-main { padding: 20px 16px; }

  /* admin: ซ่อน sidebar ใน grid, แสดง hamburger */
  .admin-wrap {
    grid-template-columns: 1fr;
    display: block;
  }
  .admin-sidebar {
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    width: 240px !important;
    height: calc(100vh - 56px) !important;
    transform: translateX(-100%) !important;
    z-index: 155 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.45);
  }
  .admin-sidebar.open {
    transform: translateX(0) !important;
  }
  .admin-main          { padding: 20px 16px; width: 100%; box-sizing: border-box; }
  .admin-menu-toggle   { display: flex !important; }
  .stats-grid          { grid-template-columns: repeat(2, 1fr); }

  /* mobile-menu สำหรับ tablet */
  .navbar .mobile-menu {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    z-index: 199;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
  }
  .navbar .mobile-menu.open { display: flex; }
  .navbar .mobile-menu a {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #6B7280;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
  }
  .navbar .mobile-menu a:hover {
    background: #e8f0fe;
    color: #0166fe;
  }
}

/* ---- MOBILE ≤768px ---- */
@media (max-width: 768px) {
  :root { --nav-h: 60px; }

  /* navbar */
  .navbar-nav     { display: none; }
  .nav-toggle     { display: flex; }
  .navbar-actions {
    display: flex;
    gap: 6px;
  }
  .btn-nav-login  { padding: 6px 12px; font-size: 0.78rem; }
  .btn-nav-signup { padding: 6px 12px; font-size: 0.78rem; }

  /* mobile dropdown */
  .navbar .mobile-menu {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    z-index: 199;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
  }
  .navbar .mobile-menu.open { display: flex; }
  .navbar .mobile-menu a {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
  }
  .navbar .mobile-menu a:hover {
    background: var(--primary-bg);
    color: var(--primary);
  }

  /* layouts */
  .apps-grid         { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stats-grid        { grid-template-columns: repeat(2, 1fr); }
  /* Member dashboard */
  .dashboard-wrap {
    grid-template-columns: 1fr;
    display: block;
    width: 100%;
    overflow-x: hidden;
  }
  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    /* แสดงเป็น horizontal nav bar บนมือถือ */
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 12px;
  }
  .sidebar-user .avatar {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
    margin-bottom: 0;
    flex-shrink: 0;
  }
  .sidebar-user .user-name { font-size: 0.85rem; }
  .sidebar-user .user-email { font-size: 0.72rem; }
  .sidebar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 8px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav li { flex-shrink: 0; }
  .sidebar-nav li a {
    padding: 7px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 99px;
  }
  .sidebar-nav li[style] { display: none; } /* ซ่อน divider */
  .dashboard-main {
    padding: 16px 14px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* admin — mobile (ถูก tablet block handle แล้ว) */
  .admin-main {
    padding: 14px 12px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .hero              { padding: 48px 0 56px; }
  .section           { padding: 40px 0; }
  .auth-card         { padding: 28px 20px; }
  .footer-grid       { grid-template-columns: 1fr; }
  .detail-hero-inner { flex-direction: column; }
  .features-list     { grid-template-columns: 1fr; }
}

/* ---- MOBILE SMALL ≤480px ---- */
@media (max-width: 480px) {
  /* ซ่อน Login เหลือแค่ Sign Up */
  .btn-nav-login  { display: none; }
  .btn-nav-signup { padding: 7px 14px; font-size: 0.8rem; }

  .apps-grid  { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .app-card   { padding: 14px; }
  .app-icon   { width: 48px; height: 48px; }

  /* admin mobile small */
  .admin-main          { padding: 12px 10px; }
  .admin-header        { margin-bottom: 14px; flex-direction: column; align-items: flex-start; }
  .stats-grid          { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card           { padding: 12px 14px; gap: 10px; }
  .stat-icon           { width: 38px; height: 38px; }
  .stat-info .num      { font-size: 1.25rem; }
  .stat-info .lbl      { font-size: 0.72rem; }
  table th, table td   { padding: 9px 8px; font-size: 0.75rem; }
  .table-wrap          { margin: 0 -10px; padding: 0 10px; }
  .card                { padding: 16px 14px; }
  .card-title          { font-size: 0.9rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .hero h1    { font-size: 1.7rem; }
}

/* ============================================
   ADMIN RESPONSIVE UTILITIES
   ============================================ */

/* Admin 2-column form layout */
.admin-form-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: start;
}

/* Admin 2-col field row (e.g. Host + Port) */
.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Table always scrollable on small screens */
/* table-wrap min-width */
.table-wrap table {
  min-width: 480px;
}

/* Admin responsive breakpoints */
@media (max-width: 860px) {
  .admin-form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 540px) {
  .admin-grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .admin-form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ============================================
   UTILITY
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 12px; }
.color-primary { color: var(--primary); }
.color-secondary { color: var(--secondary); }
.color-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(1,102,254,0.2);
  border-top-color: var(--primary);
}

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

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 24px;
  transition: color var(--transition);
}
.back-link:hover { color: var(--primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 60px; height: 60px;
  margin: 0 auto 16px;
  opacity: 0.3;
}
.empty-state h3 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
