/* NexusGroup Dashboard - Purple/Cyan gradient theme matching landing page */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
  --purple: #A855F7;
  --magenta: #D946EF;
  --cyan: #06B6D4;
  --blue: #3B82F6;
  --navy: #1E1B4B;
  --navy-light: #2E2960;
  --navy-mid: #252252;
  --white: #FFFFFF;
  --off-white: #F8FAFC;
  --gray-50: #F1F5F9;
  --gray-100: #E2E8F0;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gradient: linear-gradient(135deg, #A855F7, #D946EF, #3B82F6, #06B6D4);
  --gradient-btn: linear-gradient(135deg, #A855F7, #D946EF, #06B6D4);
  --gradient-text: linear-gradient(135deg, #A855F7, #D946EF, #3B82F6);
  --purple-glow: rgba(168, 85, 247, 0.15);
  --cyan-glow: rgba(6, 182, 212, 0.15);
  --red: #dc2626;
  --red-light: #fef2f2;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --yellow: #ca8a04;
  --yellow-light: #fefce8;
  --sidebar-w: 260px;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--navy);
  background: var(--off-white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { font-family: 'Space Grotesk', sans-serif; line-height: 1.2; }

/* LAYOUT */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.25rem;
  color: var(--white);
}
.sidebar-logo span { color: var(--cyan); }

.sidebar-role {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.25rem;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { color: rgba(255,255,255,0.85); background: rgba(168, 85, 247, 0.08); }
.nav-item.active {
  color: var(--white);
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.15), rgba(6, 182, 212, 0.08));
  border-right: 3px solid var(--purple);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex; align-items: center; gap: 0.75rem;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gradient-btn); display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: white;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.7rem; color: rgba(255,255,255,0.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  background: none; border: none; color: rgba(255,255,255,0.35);
  cursor: pointer; font-size: 0.8rem; padding: 0.5rem 0; margin-top: 0.5rem;
  width: 100%; text-align: left; font-family: 'Inter', sans-serif;
}
.btn-logout:hover { color: var(--magenta); }

/* MAIN */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  background: var(--white);
}
.page-header h1 {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; color: var(--navy);
}
.page-header p {
  font-size: 0.9rem; color: var(--gray-500); margin-top: 0.25rem;
}

.page-body {
  padding: 1.5rem 2rem 3rem;
}

/* CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.purple::before { background: var(--gradient-btn); }
.stat-card.sage::before { background: var(--gradient-btn); }
.stat-card.cyan::before { background: linear-gradient(135deg, var(--cyan), var(--blue)); }
.stat-card.warm::before { background: linear-gradient(135deg, var(--magenta), var(--purple)); }
.stat-card.green::before { background: linear-gradient(135deg, #16a34a, #22c55e); }
.stat-card.red::before { background: linear-gradient(135deg, #dc2626, #f87171); }

.stat-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--gray-500); margin-bottom: 0.35rem;
}
.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem; font-weight: 700; color: var(--navy);
}
.stat-sub {
  font-size: 0.8rem; margin-top: 0.15rem; font-weight: 500;
}
.stat-sub.positive { color: var(--green); }
.stat-sub.negative { color: var(--red); }
.stat-sub.neutral { color: var(--gray-500); }

/* TABLES */
.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 {
  font-size: 1rem; font-weight: 600; color: var(--navy);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 0.75rem 1.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}
td {
  padding: 0.85rem 1.25rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--navy);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(168, 85, 247, 0.02); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-sage {
  background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(6,182,212,0.08));
  color: var(--purple);
  border: 1px solid rgba(168,85,247,0.1);
}
.badge-purple {
  background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(6,182,212,0.08));
  color: var(--purple);
  border: 1px solid rgba(168,85,247,0.1);
}

.text-right { text-align: right; }
.text-sage { color: var(--purple); }
.text-purple { color: var(--purple); }
.text-warm { color: var(--magenta); }
.text-cyan { color: var(--cyan); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-slate { color: var(--gray-500); }
.font-mono { font-family: 'Space Grotesk', sans-serif; font-weight: 600; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-btn);
  color: white;
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(168, 85, 247, 0.35); }

.btn-warm {
  background: var(--cyan);
  color: white;
}
.btn-warm:hover { opacity: 0.9; }

.btn-outline {
  background: transparent;
  color: var(--purple);
  border: 1.5px solid rgba(168, 85, 247, 0.3);
}
.btn-outline:hover { background: rgba(168, 85, 247, 0.06); border-color: var(--purple); }

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  padding: 0.4rem 0.75rem;
}
.btn-ghost:hover { color: var(--navy); background: var(--gray-50); }

.btn-secondary {
  background: var(--gray-50);
  color: var(--navy);
  border: 1.5px solid var(--gray-100);
}
.btn-secondary:hover { background: var(--gray-100); }

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; border-radius: 8px; }

/* FORMS */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.35rem;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--gray-100);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  background: var(--white);
  color: var(--navy);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--gray-100);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  background: var(--white);
  color: var(--navy);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 75, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 80px rgba(30, 27, 75, 0.2);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; color: var(--navy); }
.modal-close {
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--gray-400); line-height: 1;
}

.modal-body { padding: 1.5rem; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--navy); }
.empty-state p { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* VARIANTS */
.variant-list {
  display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem;
}
.variant-row {
  display: grid; grid-template-columns: 1fr 80px 80px 40px; gap: 0.5rem; align-items: center;
}
.variant-row input {
  padding: 0.5rem 0.65rem;
  border: 1.5px solid var(--gray-100);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: var(--navy);
}
.variant-row input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1); }
.btn-remove-variant {
  background: none; border: none; color: var(--red);
  cursor: pointer; font-size: 1.2rem; padding: 0.25rem;
}

/* LOGIN */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--off-white);
  padding: 1rem;
  position: relative;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -30%; right: -10%;
  width: 50%; height: 160%;
  background: radial-gradient(ellipse, rgba(168, 85, 247, 0.06), transparent 70%);
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -10%;
  width: 50%; height: 160%;
  background: radial-gradient(ellipse, rgba(6, 182, 212, 0.05), transparent 70%);
  pointer-events: none;
}
.login-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(30, 27, 75, 0.08);
  position: relative;
  z-index: 1;
}
.login-card .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.5rem;
  color: var(--navy); text-align: center;
  margin-bottom: 0.25rem;
}
.login-card .logo span { color: var(--cyan); }
.login-subtitle {
  text-align: center; color: var(--gray-500);
  font-size: 0.9rem; margin-bottom: 2rem;
}
.login-card .btn-primary { width: 100%; justify-content: center; padding: 0.75rem; }
.login-toggle {
  text-align: center; margin-top: 1.25rem;
  font-size: 0.85rem; color: var(--gray-500);
}
.login-toggle a {
  color: var(--purple); font-weight: 600; cursor: pointer; text-decoration: none;
}
.error-msg {
  background: var(--red-light); color: var(--red);
  padding: 0.65rem 1rem; border-radius: 10px;
  font-size: 0.85rem; margin-bottom: 1rem;
}
.back-link {
  display: block; text-align: center; margin-top: 1.25rem;
  color: var(--gray-500); font-size: 0.85rem; text-decoration: none;
}
.back-link:hover { color: var(--purple); }

/* LOADING */
.loading { text-align: center; padding: 3rem; color: var(--gray-500); }
.spinner {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--gray-100); border-top-color: var(--purple);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SALE FORM */
.sale-item-row {
  display: grid; grid-template-columns: 1fr 1fr 80px 80px 40px; gap: 0.5rem;
  align-items: end; margin-bottom: 0.75rem;
}
.sale-item-row select, .sale-item-row input {
  padding: 0.5rem 0.65rem;
  border: 1.5px solid var(--gray-100);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
}

/* PNL */
.pnl-table { width: 100%; }
.pnl-table td { padding: 0.6rem 0; border: none; color: var(--navy); }
.pnl-table tr.total td { border-top: 2px solid var(--navy); font-weight: 700; padding-top: 0.85rem; }
.pnl-table .label { color: var(--gray-500); }
.pnl-table .value { text-align: right; font-family: 'Space Grotesk', sans-serif; font-weight: 600; }

/* MOBILE */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  padding: 1rem 1.25rem;
  background: var(--navy);
  color: white; z-index: 55;
  align-items: center; justify-content: space-between;
}
.mobile-header .logo { font-size: 1.15rem; }
.mobile-toggle {
  background: none; border: none; color: white;
  font-size: 1.5rem; cursor: pointer;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30, 27, 75, 0.4);
  z-index: 45;
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; padding-top: 60px; }
  .page-header { padding: 1.25rem 1rem 1rem; }
  .page-body { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .sale-item-row { grid-template-columns: 1fr 1fr; }
  .variant-row { grid-template-columns: 1fr 70px 70px 30px; }
}

/* TOAST */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--navy); color: white;
  padding: 0.85rem 1.25rem; border-radius: 12px;
  font-size: 0.9rem; z-index: 300;
  box-shadow: 0 8px 25px rgba(30, 27, 75, 0.2);
  animation: slideUp 0.3s ease;
  font-family: 'Inter', sans-serif;
}
.toast.success { background: linear-gradient(135deg, var(--purple), var(--cyan)); }
.toast.error { background: var(--red); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-100); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
