/* ============================================================
   CHIEF - App Styles
   Toast POS → NetSuite Integration Platform
   ============================================================ */

/* ----- CSS Custom Properties ----- */
:root {
  --navy-950: #020617;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --navy-600: #475569;
  --navy-500: #64748b;
  --navy-400: #94a3b8;
  --navy-300: #cbd5e1;
  --navy-200: #e2e8f0;
  --navy-100: #f1f5f9;

  --brand-50: #fffbeb;
  --brand-100: #fef3c7;
  --brand-200: #fde68a;
  --brand-300: #fcd34d;
  --brand-400: #fbbf24;
  --brand-500: #f59e0b;
  --brand-600: #d97706;
  --brand-700: #b45309;
  --brand-800: #92400e;

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  --warning: #f59e0b;

  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --topbar-height: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.15);

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}


/* ----- Base / Reset ----- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--navy-900);
}


/* ----- Custom Scrollbar ----- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--navy-600);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--navy-500);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--navy-600) transparent;
}


/* ----- Page Transitions ----- */
.page-enter {
  animation: pageEnter 0.35s ease forwards;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-fade {
  animation: pageFade 0.3s ease forwards;
}

@keyframes pageFade {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* ----- Glass-morphism Cards ----- */
.glass-card {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: var(--radius-lg);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.glass-card-static {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: var(--radius-lg);
}


/* ----- Animated Gradient Background (Login) ----- */
.gradient-bg {
  background: linear-gradient(-45deg, #0f172a, #1e293b, #0f172a, #1a1a3e, #0f172a);
  background-size: 400% 400%;
  animation: gradientShift 12s ease infinite;
  min-height: 100vh;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}


/* ----- Pulse Animation (Live Indicators) ----- */
.pulse-live {
  animation: pulseLive 2s ease-in-out infinite;
}

@keyframes pulseLive {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pulse-dot {
  position: relative;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  transform: translate(-50%, -50%);
  animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}


/* ----- Table Styles ----- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  background: rgba(15, 23, 42, 0.6);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--navy-400);
  border-bottom: 1px solid var(--navy-700);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.data-table thead th.sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.data-table thead th.sortable:hover {
  color: var(--brand-400);
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(245, 158, 11, 0.04);
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
  font-size: 0.875rem;
  color: var(--navy-200);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr.clickable {
  cursor: pointer;
}

/* Compact table variant — tighter row heights */
.data-table.compact-table thead th {
  padding: 8px 12px;
}
.data-table.compact-table tbody td {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

/* ----- KPI Counter Animation ----- */
.kpi-value {
  font-variant-numeric: tabular-nums;
  transition: color var(--transition-base);
}

.counter-animate {
  animation: counterPop 0.3s ease;
}

@keyframes counterPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}


/* ----- Skeleton Loading ----- */
.skeleton {
  background: linear-gradient(90deg,
    var(--navy-800) 25%,
    var(--navy-700) 50%,
    var(--navy-800) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-title {
  height: 24px;
  margin-bottom: 12px;
  width: 50%;
}

.skeleton-card {
  height: 120px;
}

.skeleton-chart {
  height: 300px;
}


/* ----- Toast Notifications ----- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(71, 85, 105, 0.3);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  animation: toastIn 0.35s ease forwards;
  min-width: 300px;
  max-width: 420px;
}

.toast-item.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast-success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.toast-info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(60px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(60px) scale(0.95);
  }
}


/* ----- Modal ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalBgIn 0.25s ease forwards;
}

.modal-backdrop.removing {
  animation: modalBgOut 0.2s ease forwards;
}

@keyframes modalBgIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalBgOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.modal-content {
  background: var(--navy-800);
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease forwards;
}

.modal-backdrop.removing .modal-content {
  animation: modalOut 0.2s ease forwards;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
}


/* ----- Slide-over Panel ----- */
.slideover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.5);
  backdrop-filter: blur(2px);
  z-index: 50;
  animation: modalBgIn 0.2s ease forwards;
}

.slideover-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 90vw;
  background: var(--navy-800);
  border-left: 1px solid var(--navy-700);
  box-shadow: var(--shadow-xl);
  z-index: 51;
  overflow-y: auto;
  animation: slideIn 0.3s ease forwards;
}

.slideover-panel.removing {
  animation: slideOut 0.25s ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes slideOut {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}


/* ----- Input Focus Glow ----- */
.input-field {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: white;
  font-size: 0.875rem;
  font-family: inherit;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input-field::placeholder {
  color: var(--navy-500);
}

.input-field:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1), 0 0 12px rgba(245, 158, 11, 0.08);
}

.input-field:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: white;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-400), var(--brand-500));
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

.btn-secondary {
  background: var(--navy-700);
  color: var(--navy-200);
  border: 1px solid var(--navy-600);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--navy-600);
  border-color: var(--navy-500);
}

.btn-ghost {
  background: transparent;
  color: var(--navy-400);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--navy-200);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}


/* ----- Status Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--success-bg);
  color: #86efac;
}

.badge-error {
  background: var(--error-bg);
  color: #fca5a5;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.badge-info {
  background: var(--info-bg);
  color: #93c5fd;
}

.badge-neutral {
  background: rgba(100, 116, 139, 0.2);
  color: var(--navy-400);
}


/* ----- Sidebar ----- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--navy-950);
  border-right: 1px solid rgba(51, 65, 85, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar .nav-label {
  opacity: 1;
  transition: opacity var(--transition-fast);
  white-space: nowrap;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-md);
  color: var(--navy-400);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar .nav-item:hover {
  background: rgba(245, 158, 11, 0.05);
  color: var(--navy-200);
}

.sidebar .nav-item.active {
  background: rgba(245, 158, 11, 0.08);
  color: var(--brand-400);
  border-left-color: var(--brand-500);
}

.sidebar .nav-item .nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}


/* ----- Top Bar ----- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 30;
  transition: left var(--transition-base);
}

.sidebar.collapsed ~ .main-area .topbar,
.sidebar.collapsed + .topbar {
  left: var(--sidebar-collapsed);
}


/* ----- Main Content Area ----- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left var(--transition-base);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}


/* ----- Chart Containers ----- */
.chart-container {
  position: relative;
  width: 100%;
  padding: 16px;
}

.chart-container canvas {
  max-height: 350px;
}


/* ----- Shake Animation (Login Error) ----- */
.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}


/* ----- Loading Spinner (inline) ----- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ----- Dropdown ----- */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--navy-800);
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px;
  z-index: 60;
  animation: dropIn 0.15s ease forwards;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--navy-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.dropdown-divider {
  height: 1px;
  background: var(--navy-700);
  margin: 4px 0;
}


/* ----- Pagination ----- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-700);
  background: transparent;
  color: var(--navy-400);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination button:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--brand-500);
  color: var(--brand-400);
}

.pagination button.active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: white;
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}


/* ----- Toggle Switch ----- */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--navy-700);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-switch.active {
  background: var(--brand-500);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-switch.active::after {
  transform: translateX(20px);
}


/* ----- Responsive ----- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    width: var(--sidebar-width);
  }

  .topbar {
    left: 0 !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
  }
}


/* ----- Print Styles ----- */
@media print {
  .sidebar,
  .topbar,
  .toast-container,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .glass-card,
  .glass-card-static {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
}


/* ----- Utility Classes ----- */
.text-gradient {
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.border-glow {
  box-shadow: var(--shadow-glow);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-select {
  user-select: none;
}
