:root {
  /* SaaS Modern Dark Theme (Default) */
  --bg-main: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #334155;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --accent: #38bdf8; /* Sky Blue */
  --accent-hover: #0ea5e9;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --border: rgba(148, 163, 184, 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
  --topbar-height: 64px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --border: rgba(148, 163, 184, 0.2);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

p {
  color: var(--text-muted);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Grid Utilities */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.setup-product-grid {
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .setup-product-grid {
    grid-template-columns: 1fr;
  }
}
.shop-details-grid {
  grid-template-columns: 300px 1fr;
  gap: 2rem;
}

@media (max-width: 1024px) {
  .shop-details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Flex Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }

@media (max-width: 768px) {
  .mobile-flex-col {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  .mobile-w-full {
    width: 100% !important;
  }

  .mobile-text-left {
    text-align: left !important;
  }
}

/* Desktop App Shell Components */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: fixed;
  height: 100vh;
  z-index: 1000;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  
  .sidebar.active {
    transform: translateX(0);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
    backdrop-filter: blur(2px);
  }

  .sidebar-backdrop.active {
    display: block;
  }
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 800;
  white-space: nowrap;
  opacity: 1;
  transition: var(--transition);
}

.sidebar.collapsed .sidebar-title {
  opacity: 0;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  gap: 1rem;
  white-space: nowrap;
}

.nav-item i {
  font-size: 1.25rem;
  width: 20px;
  text-align: center;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent);
}

.nav-item.active {
  background-color: var(--accent);
  color: var(--text-inverse);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

@media (max-width: 1024px) {
  .main-wrapper {
    margin-left: 0 !important;
  }
}

.sidebar.collapsed + .main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 900;
  -webkit-app-region: drag; /* For Electron custom title bar */
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 1rem;
    height: auto;
    min-height: var(--topbar-height);
    flex-wrap: wrap;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    gap: 1rem;
  }
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 1rem;
}

@media (max-width: 1024px) {
  .menu-toggle {
    display: flex;
  }
}

.topbar-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  -webkit-app-region: no-drag;
}

@media (max-width: 480px) {
  .topbar-content h2 {
    font-size: 1rem !important;
  }
  
  #userNameDisplay {
    display: none;
  }
}

.main-content {
  padding: 2rem;
  flex: 1;
}

@media (max-width: 768px) {
  .main-content {
    padding: 1.25rem;
  }
}

/* Card Styling */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  overflow: hidden;
}

@media (max-width: 768px) {
  .card {
    padding: 1.25rem;
  }
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(56, 189, 248, 0.3);
}

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

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  flex-shrink: 0;
}

.stat-info h3 {
  font-size: 1.75rem;
  margin-bottom: 0;
}

.stat-info p {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

.chart-container {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* Table Styling */
.table-container {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-x: auto;
  box-shadow: var(--shadow-md);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

/* Bottom Navigation for Mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.5rem calc(0.5rem + var(--safe-area-bottom));
  z-index: 1100;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }
  
  .main-content {
    padding-bottom: calc(80px + var(--safe-area-bottom));
  }
  
  .sidebar {
    display: none; /* Hide sidebar completely on very small screens, use bottom nav */
  }
  
  .sidebar.active {
    display: flex;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  transition: var(--transition);
  flex: 1;
}

.bottom-nav-item i {
  font-size: 1.25rem;
}

.bottom-nav-item.active {
  color: var(--accent);
}

/* Hide menu toggle if using bottom nav */
@media (max-width: 768px) {
  .menu-toggle {
    display: none;
  }
}

/* Professional Card-based lists for Mobile */
@media (max-width: 768px) {
  .table-container table {
    min-width: unset;
  }
  
  .table-container thead {
    display: none; /* Hide headers on mobile */
  }
  
  .table-container tbody tr {
    display: block;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  
  .table-container tbody td {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border: none;
    font-size: 0.9rem;
  }
  
  .table-container tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
  }
  
  .table-container tbody td:first-child {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
  }
  
  .table-container tbody td:first-child::before {
    display: none;
  }

  .table-container tbody td.actions-cell {
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
  }
  
  .table-container tbody td.actions-cell::before {
    display: none;
  }
}

th {
  background-color: rgba(148, 163, 184, 0.05);
  padding: 1rem 1.5rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

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

tr:hover td {
  background-color: rgba(148, 163, 184, 0.02);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  gap: 0.5rem;
  outline: none;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(148, 163, 184, 0.1);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  background-color: rgba(148, 163, 184, 0.1);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: var(--bg-card);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transform: scale(0.9);
  transition: var(--transition);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  padding: 1rem 1.5rem;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  transform: translateX(120%);
  transition: var(--transition);
}

.toast.active {
  transform: translateX(0);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade { animation: fadeIn 0.5s ease-out; }
.animate-slide-up { animation: slideUp 0.5s ease-out; }

/* Status Badges */
.badge {
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success { background-color: rgba(34, 197, 94, 0.1); color: var(--success); }
.badge-warning { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Desktop-specific tweaks */
.no-select { user-select: none; }
.cursor-pointer { cursor: pointer; }

/* Print Utilities */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}
