/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #030712;
  --surface: #0f172a;
  --surface2: #1e293b;
  --surface-glass: rgba(15, 23, 42, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(16, 185, 129, 0.2);
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #10b981;
  --green-glow: #34d399;
  --red: #ef4444;
  --blue: #3b82f6;
  --yellow: #f59e0b;
  --sidebar-w: 260px;
  --accent: #4f46e5;
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}
html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════
   AUTH & CHECKOUT KIOSK SCREENS
═══════════════════════════════════════════════ */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at top right, #1e1b4b, #030712); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 48px; width: 100%; max-width: 440px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); }
.auth-logo { font-size: 3.5rem; text-align: center; filter: drop-shadow(0 0 15px var(--green-glow)); margin-bottom: 20px; }
.auth-title { font-size: 1.75rem; font-weight: 800; text-align: center; background: linear-gradient(to bottom right, #fff, #94a3b8); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-sub { color: var(--muted); font-size: 0.95rem; text-align: center; margin-bottom: 32px; font-weight: 500; }
.auth-form label, .form-group label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; margin-top: 16px; text-transform: uppercase; letter-spacing: 0.05em; }
.auth-error { background: rgba(127, 29, 29, 0.2); border: 1px solid var(--red); color: #fecaca; border-radius: 12px; padding: 12px; font-size: 0.85rem; margin-top: 16px; display: flex; align-items: center; gap: 8px; }

/* ═══════════════════════════════════════════════
   INPUTS & BUTTONS
═══════════════════════════════════════════════ */
input, select, textarea { width: 100%; padding: 13px 16px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font-size: 0.95rem; font-family: inherit; margin-bottom: 12px; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); background: rgba(255, 255, 255, 0.05); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1); }
.btn-primary { background: linear-gradient(135deg, var(--green), #059669); color: #064e3b; font-weight: 700; border: none; border-radius: 12px; padding: 14px 24px; cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3); opacity: 0.95; }
.btn-primary:active { transform: translateY(0); }
.btn-primary.full-width { width: 100%; margin-top: 24px; font-size: 1rem; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 12px 20px; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.btn-secondary:hover { background: #2d3748; }
.btn-danger { background: rgba(69, 10, 10, 0.3); color: #fca5a5; border: 1px solid rgba(127, 29, 29, 0.5); border-radius: 12px; padding: 12px 20px; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.btn-danger:hover { background: rgba(69, 10, 10, 0.5); }
.sm { padding: 8px 14px; font-size: 0.85rem; }

.tbtn { border: none; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 0.78rem; font-weight: 700; transition: opacity .2s; margin-right: 4px; }
.tbtn-pay { background: var(--yellow); color: #451a03; }
.tbtn-attend { background: #1e3a5f; color: var(--blue); }
.tbtn-edit { background: var(--surface2); color: var(--text); }
.tbtn-delete { background: #450a0a; color: #fca5a5; }

/* WhatsApp Button */
.wa-btn { background: #065f46; color: #34d399; text-decoration: none; padding: 3px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; margin-left: 6px; cursor: pointer; border: 1px solid #059669; }
.wa-btn:hover { background: #047857; color: #fff; }

/* ═══════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════ */
#screen-app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 24px 16px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 100; }
.sidebar-logo { display:flex; align-items:center; gap:12px; padding: 0 8px 24px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.sidebar-title { font-weight: 800; color: #fff; font-size: 1.2rem; letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.nav-item { display:flex; align-items:center; gap:12px; padding: 12px 16px; border-radius: 12px; border: none; background: transparent; color: var(--muted); cursor: pointer; text-align: left; transition: all 0.2s; font-weight: 500; }
.nav-item:hover { background: rgba(255, 255, 255, 0.03); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05)); color: var(--green); font-weight: 700; border: 1px solid rgba(16, 185, 129, 0.2); }
.scanner-btn { background: var(--accent); color: #fff; font-weight: 700; margin-top: 12px; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); }
.scanner-btn:hover { background: #4338ca; box-shadow: 0 8px 16px rgba(79, 70, 229, 0.3); }
.logout-btn { padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); color: var(--muted); cursor: pointer; font-weight: 600; transition: all 0.2s; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--red); border-color: rgba(239, 68, 68, 0.2); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; }
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; margin-right:15px; }
.topbar-title { font-weight: 700; flex: 1; }
.topbar-user { display:flex; align-items:center; gap:10px; color:var(--muted); font-size: 0.88rem; }
.avatar { width: 34px; height: 34px; background: var(--green); color: #000; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; }

.page { flex: 1; overflow-y: auto; padding: 28px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 1.3rem; font-weight: 700; }

/* ═══════════════════════════════════════════════
   CARDS & STATS
═══════════════════════════════════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow-lg); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px 24px; transition: transform 0.2s; position: relative; overflow: hidden; }
.stat-card:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, 0.15); }
.stat-card.green { border-left: 4px solid var(--green); }
.stat-card.red { border-left: 4px solid var(--red); }
.stat-card.yellow { border-left: 4px solid var(--yellow); }
.stat-card.blue { border-left: 4px solid var(--blue); }
.stat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 2rem; font-weight: 900; letter-spacing: -0.02em; }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.blue .stat-value { color: var(--blue); }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 24px; }
.chart-container { position: relative; height: 300px; width: 100%; margin-top: 16px; }

/* ═══════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: #000000cc; display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px; backdrop-filter: blur(4px); }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 80px #000c; }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 22px; }
.modal-close { background: var(--surface2); border: none; color: var(--muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display:flex; align-items:center; justify-content:center; }

.modal-body-split { display: flex; gap: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }

/* Scanner Modal */
.scanner-card { max-width: 480px; text-align: center; }
#reader-container { width: 100%; background: #000; border-radius: 16px; overflow: hidden; min-height: 300px; margin-bottom: 16px; }
.scan-result { padding: 20px; background: #064e3b; border-radius: 12px; border: 1px solid #10b981; animation: popIn 0.3s ease-out; }
.scan-result h4 { color: #fff; font-size: 1.3rem; margin-top:5px; }
@keyframes popIn { 0% { transform: scale(0.9); opacity:0; } 100% { transform: scale(1); opacity:1; } }

/* ═══════════════════════════════════════════════
   TABLES & UTILS
═══════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { padding: 11px 10px; text-align: left; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 0.78rem; text-transform: uppercase; }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.search-row { display: flex; gap: 10px; align-items: center; overflow-x:auto; padding-bottom:5px;}
.search-row input { flex: 1; min-width: 150px;}
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--green); color: #000; padding: 13px 22px; border-radius: 12px; font-weight: 700; opacity: 0; pointer-events: none; transition: .3s; transform: translateY(10px); z-index: 1000; }
.toast.show { opacity: 1; transform: translateY(0); }

/* Badges */
.badge { padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.badge.active { background: #064e3b; color: #34d399; }
.badge.expired { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
.badge.trial { background: #451a03; color: #fbbf24; border: 1px solid #b45309; }
.badge.pending { background: #1e3a8a; color: #93c5fd; border: 1px dashed #3b82f6; cursor: pointer; }

/* ═══════════════════════════════════════════════
   PORTAL & KIOSK UI
═══════════════════════════════════════════════ */
.portal-card { max-width: 400px; width: 100%; text-align: center; border-color: var(--green) !important; padding: 40px 24px !important; }
.status-badge { padding: 16px; border-radius: 16px; margin-bottom: 24px; font-weight: 800; font-size: 1.1rem; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.success-box { text-align: center; margin-top: 24px; padding: 32px; background: rgba(6, 78, 59, 0.4); border: 1px solid var(--green); border-radius: 20px; backdrop-filter: blur(4px); }
.member-id-display { background: #000; padding: 14px; border-radius: 12px; font-size: 1.6rem; font-weight: 900; color: var(--green); letter-spacing: 3px; margin: 16px 0; border: 1px solid rgba(16, 185, 129, 0.3); }

/* ═══════════════════════════════════════════════
   PRINT STYLES FOR DIET PLAN
═══════════════════════════════════════════════ */
@media print {
  body * { visibility: hidden; }
  #print-container, #print-container * { visibility: visible; }
  #print-container { 
    position: absolute; left: 0; top: 0; width: 100%; 
    background: white; color: black; padding: 40px; 
    font-family: 'Inter', sans-serif;
  }
  .print-head { text-align: center; border-bottom: 2px solid #000; padding-bottom: 20px; margin-bottom: 20px; }
  .print-title { font-size: 24px; font-weight: 800; margin-bottom: 5px; }
  .print-meta { font-size: 14px; color: #555; }
  .print-notes { white-space: pre-wrap; font-size: 16px; line-height: 1.6; }
}

@media (max-width: 768px) {
  #sidebar { position: fixed; transform: translateX(-100%); bottom:0; top:0; }
  #sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px #000a; }
  .menu-toggle { display: block; }
  .modal-body-split { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr !important; }
  .qr-col { width: 100%; flex-direction: row; justify-content: space-between; text-align: left; display: none !important;} /* Hide QR on mobile modal to save space */
  .charts-grid { grid-template-columns: 1fr; }
}
