:root {
  --bg-color: #f8fafc;
  --panel-bg: #ffffff;
  --panel-border: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --sidebar-width: 260px;
}

[data-theme='dark'] {
  --bg-color: #0b0f19;
  --panel-bg: #111827;
  --panel-border: #1f2937;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-light: rgba(59, 130, 246, 0.2);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-geist-sans), system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

/* Typography */
h1 { font-size: 1.875rem; font-weight: 700; margin-bottom: 0.5rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
p { color: var(--text-muted); }

/* Buttons */
button {
  cursor: pointer;
  border: none;
  background: var(--panel-bg);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--panel-border);
}
button:hover { background: var(--panel-border); }
button.primary { background: var(--accent); color: #fff; border: none; }
button.primary:hover { background: var(--accent-hover); }

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 50;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar.closed {
  width: 80px;
}

.sidebar.closed .brand-text,
.sidebar.closed .sidebar-section-title,
.sidebar.closed .menu-text {
  display: none;
}

.sidebar-brand {
  padding: 1.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar.closed .sidebar-brand {
  padding: 1.5rem 0;
  justify-content: center;
}

.sidebar-brand-icon {
  background: var(--accent);
  color: #fff;
  border-radius: 0.5rem;
  padding: 0.35rem;
  display: flex;
}

.sidebar-section-title {
  padding: 1.5rem 1.5rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
}
.sidebar.closed .sidebar-section-title {
  padding: 1.5rem 0 0.5rem;
  text-align: center;
  color: transparent; /* Hide text but keep height */
}

.nav-links { list-style: none; padding: 0 1rem; }
.sidebar.closed .nav-links { padding: 0 0.5rem; }
.nav-links li { margin-bottom: 0.25rem; }

.nav-links a {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.sidebar.closed .nav-links a {
  justify-content: center;
  padding: 0.75rem 0;
}

.nav-links a:hover {
  background: var(--bg-color);
  color: var(--text-main);
}
.nav-links a.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Main Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg-color);
}
.hamburger-btn {
  background: transparent;
  border: none;
  padding: 0.5rem;
}
.hamburger-btn:hover { background: var(--panel-border); }
.content-inner {
  flex: 1;
  overflow-y: auto;
  padding: 0 2rem 2rem;
}

/* Panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

/* Utility Grids */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* POS Responsive Layout */
.pos-layout {
  display: flex;
  gap: 2rem;
  height: 100%;
}
.pos-products { flex: 1; }
.pos-cart {
  width: 380px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  position: sticky;
  top: 1rem;
}

@media (max-width: 1024px) {
  .pos-layout { flex-direction: column; }
  .pos-products { padding-right: 0; }
  .pos-cart {
    width: 100%;
    position: static;
    height: auto;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    height: 100vh;
    left: 0;
    width: var(--sidebar-width);
  }
  .sidebar.closed {
    transform: translateX(-100%);
    width: var(--sidebar-width); /* Don't shrink, just slide out */
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
  }
}

/* Inputs */
input, select {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--panel-border);
  background: var(--bg-color);
  color: var(--text-main);
  border-radius: 0.5rem;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* DataTable Customization */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--panel-border);
}
.data-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
}
.data-table td { font-size: 0.95rem; }
.data-table tbody tr:hover { background: var(--bg-color); }

/* Toasts */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease-out forwards;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Print */
@media print {
  .sidebar, .topbar, .print-hide, .pos-layout { display: none !important; }
  .print-receipt { display: block !important; }
  .main-wrapper { flex: 1; overflow: visible !important; }
  .content-inner { padding: 0; margin: 0; overflow: visible !important; }
  body { background: #fff; color: #000; }
}
