﻿/*
 * TrainexAI — Global Stylesheet
 * World-class startup design — Inter font, clean dark system
 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --accent-color:     #8b5cf6;
  --accent-hover:     #7c3aed;
  --accent-secondary: #8b5cf6;
  --accent-light:     rgba(139, 92, 246, 0.1);
  --bg-dark:          #09090b;
  --bg-darker:        #050507;
  --bg-widget:        #111113;
  --bg-card:          #18181b;
  --border-color:     rgba(255, 255, 255, 0.08);
  --border-accent:    rgba(139, 92, 246, 0.25);
  --text-light:       #fafafa;
  --text-muted:       #a1a1aa;
  --text-dim:         #71717a;
  --shadow-sm:        0 1px 3px rgba(0,0,0,.4);
  --shadow-md:        0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:        0 12px 40px rgba(0,0,0,.4);
  --transition:       0.2s ease;
  --gradient:         linear-gradient(135deg, #8b5cf6, #7c3aed);
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        12px;
  --radius-xl:        16px;
}

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

@font-face {
  font-family: 'Poppins';
  font-display: swap;
}

/* ── Body — clean near-black background ─────────────────────────────────────── */
body {
  font-family: 'Inter', 'Poppins', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Gradient text helper (kept for compatibility) ──────────────────────────── */
.gradient-text {
  color: var(--accent-color);
}

/* ── Nav ────────────────────────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0;
  width: 100%;
  background: rgba(9, 9, 11, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  height: 56px;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.logo {
  height: 36px;
  width: auto;
  border-radius: 8px;
  transition: opacity var(--transition);
}
.logo:hover { opacity: 0.85; }

.logo-text {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-light);
  letter-spacing: 0.5px;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

nav ul li a,
nav ul li button {
  color: #a1a1aa;
  font-weight: 500;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: 'Inter', 'Poppins', sans-serif;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

nav ul li a:hover,
nav ul li a:focus,
nav ul li button:hover,
nav ul li button:focus {
  color: #fafafa;
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 5px;
  background: none;
  border: none;
  padding: 4px;
}
.hamburger span {
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: var(--transition);
  display: block;
}

@media (max-width: 900px) {
  nav ul {
    position: fixed;
    top: 56px;
    right: -100%;
    background: rgba(9, 9, 11, 0.99);
    border-left: 1px solid var(--border-color);
    height: calc(100vh - 56px);
    width: 220px;
    flex-direction: column;
    padding: 1.5rem 1rem;
    gap: 0.25rem;
    transition: right 0.3s ease;
    z-index: 9999;
  }
  nav ul.active { right: 0; }
  .hamburger { display: flex; }
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
aside {
  width: 220px;
  background: #09090b;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: fixed;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  transition: transform var(--transition);
  z-index: 900;
}

/* Sidebar section label */
aside .nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #3f3f46;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1rem 0.75rem 0.4rem;
  margin-top: 0.25rem;
}

aside h2 {
  color: var(--text-light);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

aside button {
  background: transparent;
  color: #71717a;
  padding: 0.6rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.85rem;
  font-family: 'Inter', 'Poppins', sans-serif;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  line-height: 1.4;
}

aside button i {
  width: 16px;
  text-align: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  opacity: 0.7;
}

aside button:hover,
aside button:focus {
  background: rgba(255, 255, 255, 0.04);
  color: #fafafa;
  outline: none;
}

aside button:hover i { opacity: 1; }

aside button.support-btn {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  border: 1px solid rgba(139, 92, 246, 0.2);
}
aside button.support-btn:hover {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
}

@media (max-width: 992px) {
  aside { transform: translateX(-100%); }
  aside.active { transform: translateX(0); }
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
footer {
  background: var(--bg-darker);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.875rem;
  user-select: none;
}

.app-footer {
  margin-left: 220px;
  background: var(--bg-darker);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  text-align: center;
  padding: 1.25rem 1rem;
  font-size: 0.8rem;
  user-select: none;
}
@media (max-width: 992px) {
  .app-footer { margin-left: 0; }
}

.footer-content {
  display: flex;
  justify-content: space-around;
  max-width: 1100px;
  margin: 0 auto 1.5rem;
  flex-wrap: wrap;
  gap: 2rem;
}

.footer-links h3 {
  color: var(--text-light);
  margin-bottom: 0.8rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 0.5rem; }
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  font-size: 0.85rem;
}
.footer-links a:hover { color: var(--text-light); }

.footer-social {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.footer-social a {
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: color var(--transition);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-color);
}
.footer-social a:hover { color: var(--text-light); background: rgba(255,255,255,.08); }

.footer-copyright {
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ── Modals ─────────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1600;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 1rem;
}
.modal-bg.active { display: flex; }

.modal {
  background: var(--modal-bg, #111113);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease forwards;
  color: var(--text-light);
  position: relative;
  margin: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-light);
}

.modal label {
  font-weight: 600;
  display: block;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal input[type="text"],
.modal input[type="password"],
.modal input[type="email"],
.modal input[type="tel"],
.modal input[type="number"],
.modal input[type="date"] {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: 'Inter', 'Poppins', sans-serif;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.modal input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

.modal .submit-btn {
  margin-top: 1.5rem;
  width: 100%;
  background: var(--accent-color);
  border: none;
  padding: 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'Inter', 'Poppins', sans-serif;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #fff;
  transition: background var(--transition);
}
.modal .submit-btn:hover { background: var(--accent-hover); }
.modal .submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.modal button.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border-color);
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: all var(--transition);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal button.close-btn:hover { background: rgba(255,255,255,.1); color: var(--text-light); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #8b5cf6;
  color: #fff;
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  font-family: 'Inter', 'Poppins', sans-serif;
  font-size: 0.875rem;
  transition: background var(--transition);
}
.btn:hover { background: #7c3aed; }
.btn:focus { outline: 2px solid var(--accent-color); outline-offset: 3px; }

/* Secondary / outline button */
.btn-secondary {
  background: transparent;
  color: #a1a1aa;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.05); color: #fafafa; border-color: rgba(255, 255, 255, 0.15); }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ── Mobile modal fix ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .modal {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius-md);
  }
  .modal h3 { font-size: 1.3rem; }
  .modal-bg { padding: .75rem; align-items: flex-start; }
}

/* ── Toast position fix on mobile ────────────────────────────────────────────── */
@media (max-width: 480px) {
  #toast-container {
    bottom: 1rem !important;
    right: 1rem !important;
    left: 1rem !important;
  }
  #toast-container > div {
    max-width: 100% !important;
  }
}

/* ── Scroll-to-top button ────────────────────────────────────────────────────── */
#scroll-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  background: #111113;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  transition: all var(--transition);
}
#scroll-top-btn:hover { color: var(--text-light); border-color: rgba(255,255,255,.15); }
#scroll-top-btn.visible { display: flex; }

/* ── Page load skeleton ──────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.08) 50%, rgba(255,255,255,.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Focus visible — accessibility ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 3px;
}

/* ── Skip to content link — accessibility ────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent-color);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: 0 0 8px 8px;
  font-weight: 700;
  z-index: 99999;
  text-decoration: none;
  transition: top .2s;
}
.skip-link:focus { top: 0; }

/* ── Input validation states ─────────────────────────────────────────────────── */
input.valid   { border-color: #22c55e !important; }
input.invalid { border-color: #ef4444 !important; }
.field-error  { color: #ef4444; font-size: .75rem; margin-top: .25rem; display: block; min-height: 1rem; }

/* ── Plan badge on sidebar ────────────────────────────────────────────────────── */
.plan-required-badge {
  margin-left: auto;
  font-size: .6rem;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: .1rem .45rem;
  border-radius: 4px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Dark / Light mode ───────────────────────────────────────────────────────── */
:root {
  --mode-transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

body.light-mode {
  --modal-bg:     #f0eeff;
  --bg-dark:      #eeeaf8;
  --bg-darker:    #e6e1f5;
  --bg-widget:    #f5f2ff;
  --bg-card:      #f5f2ff;
  --border-color: rgba(124, 58, 237, 0.12);
  --border-accent: rgba(124, 58, 237, 0.28);
  --text-light:   #1a1035;
  --text-muted:   #5b4d7a;
  --text-dim:     #8b7aaa;
  --shadow-sm:    0 1px 3px rgba(100,60,200,.1);
  --shadow-md:    0 4px 16px rgba(100,60,200,.08);
  --shadow-lg:    0 12px 40px rgba(100,60,200,.1);
  background-color: var(--bg-dark);
  color: var(--text-light);
  transition: var(--mode-transition);
}

body.light-mode nav {
  background: rgba(238, 234, 248, 0.97);
  border-bottom-color: rgba(124, 58, 237, 0.12);
}

body.light-mode aside {
  background: rgba(230, 225, 245, 0.99);
  border-right-color: rgba(124, 58, 237, 0.12);
}

body.light-mode aside button { color: #3b2d5e; }
body.light-mode aside button:hover { background: rgba(124, 58, 237, 0.08); color: #1a1035; }
body.light-mode aside .nav-section-label { color: #8b7aaa; }

body.light-mode logo-text { color: #1a1035; }
body.light-mode .logo-text { color: #1a1035; }

/* Dark mode toggle — sidebar pill style */
#dark-mode-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  padding: .6rem .75rem;
  border-radius: 8px;
  text-align: left;
  border-top: 1px solid var(--border-color);
  padding-top: .75rem;
  margin-top: .5rem;
  transition: background var(--transition);
}
#dark-mode-toggle:hover { background: rgba(255,255,255,.04); }

body.light-mode #dark-mode-toggle {
  border-top-color: rgba(0,0,0,.08);
}

/* ── Light mode — fix hardcoded colors across all pages ─────────────────────── */

body.light-mode main { background: var(--bg-darker) !important; }

body.light-mode .stat-card,
body.light-mode .widget,
body.light-mode .activity-section,
body.light-mode .settings-card,
body.light-mode .table-card,
body.light-mode .panel,
body.light-mode .log-card,
body.light-mode .chart-card,
body.light-mode .best-card,
body.light-mode .order-card,
body.light-mode .plan-card,
body.light-mode .feature-card,
body.light-mode .founder-card,
body.light-mode .pricing-card,
body.light-mode .sport-card,
body.light-mode .meal-card,
body.light-mode .meal-section,
body.light-mode .macro-card {
  background: #f5f2ff !important;
  border-color: rgba(124, 58, 237, 0.12) !important;
  color: #1a1035 !important;
}

body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4 { color: #1a1035 !important; }

body.light-mode p,
body.light-mode td,
body.light-mode th,
body.light-mode label,
body.light-mode span:not(.badge):not(.b):not(.plan-pill):not(.lock-badge):not(.feature-new-badge) {
  color: #3b2d5e;
}

body.light-mode [style*="color:#fff"],
body.light-mode [style*="color: #fff"],
body.light-mode [style*="color:#eee"],
body.light-mode [style*="color: #eee"],
body.light-mode [style*="color:#bbb"],
body.light-mode [style*="color: #bbb"] {
  color: #1a1035 !important;
}

body.light-mode [style*="background:#0"],
body.light-mode [style*="background:#1"],
body.light-mode [style*="background: #0"],
body.light-mode [style*="background: #1"],
body.light-mode [style*="background:rgba(255,255,255,.03)"],
body.light-mode [style*="background:rgba(255,255,255,.04)"],
body.light-mode [style*="background:rgba(255,255,255,.05)"],
body.light-mode [style*="background:rgba(255,255,255,.06)"],
body.light-mode [style*="background:rgba(255,255,255,.07)"],
body.light-mode [style*="background:rgba(255,255,255,.08)"] {
  background: rgba(124, 58, 237, 0.05) !important;
}

body.light-mode input,
body.light-mode select,
body.light-mode textarea {
  background: #ede8ff !important;
  border-color: rgba(124, 58, 237, 0.2) !important;
  color: #1a1035 !important;
}
body.light-mode input::placeholder,
body.light-mode textarea::placeholder { color: #8b7aaa !important; }

body.light-mode nav ul li a,
body.light-mode nav ul li button:not(#dark-mode-toggle):not(#btn-signin):not(#btn-signup) {
  color: #3b2d5e !important;
}
body.light-mode nav ul li a:hover,
body.light-mode nav ul li button:hover { color: #1a1035 !important; }

body.light-mode footer,
body.light-mode .app-footer {
  background: #ddd8f0 !important;
  border-top-color: rgba(124, 58, 237, 0.12) !important;
  color: #5b4d7a !important;
}
body.light-mode .footer-links a,
body.light-mode .footer-copyright { color: #8b7aaa !important; }

body.light-mode .modal {
  background: #f0eeff !important;
  border-color: rgba(124, 58, 237, 0.2) !important;
  color: #1a1035 !important;
  box-shadow: 0 20px 60px rgba(100, 60, 200, 0.15) !important;
}
body.light-mode .modal h3 { color: #1a1035 !important; }
body.light-mode .modal label { color: #3b2d5e !important; }
body.light-mode .modal h4 { color: #1a1035 !important; }
body.light-mode .modal p { color: #5b4d7a !important; }
body.light-mode .modal input[type="text"],
body.light-mode .modal input[type="password"],
body.light-mode .modal input[type="email"],
body.light-mode .modal input[type="tel"],
body.light-mode .modal input[type="number"] {
  background: #ede8ff !important;
  border-color: rgba(124, 58, 237, 0.2) !important;
  color: #1a1035 !important;
}
body.light-mode .modal-bg { background: rgba(20, 10, 50, 0.6) !important; }
body.light-mode #otp-modal-bg > div {
  background: #f0eeff !important;
  color: #1a1035 !important;
  border-color: rgba(124, 58, 237, 0.2) !important;
}
body.light-mode #otp-modal-bg input {
  background: #ede8ff !important;
  border-color: rgba(124, 58, 237, 0.2) !important;
  color: #1a1035 !important;
}
body.light-mode #otp-modal-bg p,
body.light-mode #otp-modal-bg span { color: #3b2d5e !important; }
body.light-mode #otp-modal-bg h3 { color: #1a1035 !important; }

body.light-mode .summary-bar { background: #ffffff !important; }
body.light-mode .bar-label { color: #6b7280 !important; }
body.light-mode #retention-bar > div { border-color: rgba(124, 58, 237, 0.12) !important; }
body.light-mode nav[aria-label="Breadcrumb"] a { color: #5b4d7a !important; }
body.light-mode nav[aria-label="Breadcrumb"] span { color: #1a1035 !important; }
body.light-mode #scroll-top-btn { background: #f0eeff; border-color: rgba(124,58,237,.2); color: #5b4d7a; }
body.light-mode aside button[style*="background:rgba(255,92,158"] { color: var(--accent-color) !important; }
body.light-mode tr:hover td { background: rgba(124, 58, 237, 0.04) !important; }
body.light-mode td { border-bottom-color: rgba(124, 58, 237, 0.08) !important; }
body.light-mode th { color: #5b4d7a !important; background: #e6e1f5 !important; }

/* ── Page load skeleton ──────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.03) 25%, rgba(255,255,255,.06) 50%, rgba(255,255,255,.03) 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; } }

/* ── Toast position fix on mobile ────────────────────────────────────────────── */
@media (max-width: 480px) {
  #toast-container {
    bottom: 1rem !important;
    right: 1rem !important;
    left: 1rem !important;
  }
  #toast-container > div {
    max-width: 100% !important;
  }
}

/* ── Date display ────────────────────────────────────────────────────────────── */
.date-display { font-size: .8rem; color: var(--text-muted); }




/* ── Animations (gym-themed micro-interactions) ──────────────────────────────── */
/* Loaded via <link> in each page — see /client/css/animations.css */
