/* ============================================================
   Ipo-iPOS Theme — Teal/Dark Sidebar Premium Aesthetic
   Redesigned 2026-06-23: premium refinements, modern color
   palette, dark sidebar layout, animation system, responsive
   breakpoints, consistent component styling.
   ============================================================ */

:root {
  /* Primary — Soft Teal */
  --primary: #0d9488;
  --primary-light: #14b8a6;
  --primary-dark: #0f766e;
  --primary-glow: rgba(13, 148, 136, 0.1);

  /* Status */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  /* Backgrounds — lighter with subtle color */
  --bg: #f0f4f8;
  --bg-sidebar: #f7fafc;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --bg-content: #ffffff;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #eef2f6;

  /* Text */
  --text: #334155;
  --text-content: #1e293b;
  --text-muted: #94a3b8;
  --text-muted-content: #64748b;

  /* Radii */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 10px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 20px rgba(0,0,0,0.07), 0 4px 6px rgba(0,0,0,0.04);
}

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

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Body */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

body.page-dashboard .main {
  background: linear-gradient(135deg, #f0f7fa 0%, #f5fafc 50%, #f0f4f8 100%);
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
}

.sidebar-brand .icon {
  font-size: 1.5rem;
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.sidebar-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--primary);
}

.sidebar-brand small {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 1rem 0 0.4rem 0.5rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--primary-light);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--primary-glow);
  color: var(--primary);
}

.nav-item:hover svg {
  stroke: var(--primary-light);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  transition: stroke 0.15s;
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

/* Embedded SVG icon in nav */
.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  transition: stroke 0.15s;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}

.sidebar-footer .info { font-size: 0.8rem; }
.sidebar-footer .info .name { font-weight: 600; color: var(--text-content); }
.sidebar-footer .info .role { color: var(--text-muted); font-size: 0.7rem; }

/* ========== MAIN CONTENT AREA ========== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 260px;
  min-height: 100vh;
  background: #f8fafc;
}

/* Top header bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-left h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-content);
}

.topbar-left .breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted-content);
}

.topbar-left .breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.topbar-left .breadcrumb a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.topbar-left .breadcrumb .sep {
  color: #cbd5e1;
}

/* Hamburger for mobile */
.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-muted-content);
  flex-shrink: 0;
}

.hamburger:hover {
  background: #f1f5f9;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* Content area */
.content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  color: var(--text-content);
}

/* ========== COMPONENTS ========== */

/* Cards */
.card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.stats-grid .card {
  border-top: 3px solid var(--primary-light);
}

.stats-grid .card:nth-child(2) {
  border-top-color: var(--info);
}

.stats-grid .card:nth-child(3) {
  border-top-color: var(--warning);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #d1d5db;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-content);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-content);
  border-color: var(--border-light);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

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

.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text-content);
}

.btn-lg {
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.7rem 0.75rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted-content);
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
  background: #f8fafc;
}

td {
  padding: 0.7rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-content);
}

tr:hover td {
  background: #f8fafc;
}

/* Form inputs */
input, select, textarea {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  padding: 0.5rem 0.75rem;
  color: var(--text-content);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Badges */
.badge {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,0.1); color: #16a34a; }
.badge-warning { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-info { background: rgba(6,182,212,0.1); color: #0891b2; }
.badge-primary { background: rgba(13,148,136,0.1); color: var(--primary); }
.badge-neutral { background: #f1f5f9; color: var(--text-muted-content); }

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted-content);
}

.empty .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

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

/* Table action buttons — small pill buttons for inline edit/delete */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-action:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}
.btn-action-edit {
  background: var(--primary);
  color: #fff;
}
.btn-action-delete {
  background: var(--danger);
  color: #fff;
}

/* Action links (deprecated — use btn-action instead) */
.action-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.8rem;
  cursor: pointer;
}

.action-link:hover {
  text-decoration: underline;
}

/* Stats grid (used on dashboards and customer stats) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats-grid .stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted-content);
  margin-bottom: 0.4rem;
}

.stats-grid .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* Utility classes */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted-content); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mono { font-family: 'Courier New', monospace; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* Glass card variant */
.card-glass {
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.3);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

/* Notification animation */
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  animation: slideInDown 0.3s ease-out;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* Product grid (from products.html) */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.product-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.product-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.product-card .emoji {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.product-card .name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-content);
}

.product-card .category {
  font-size: 0.75rem;
  color: var(--text-muted-content);
  margin-top: 0.2rem;
}

.product-card .price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.4rem;
}

.product-card .stock {
  font-size: 0.75rem;
  color: var(--text-muted-content);
  margin-top: 0.2rem;
}

/* Report-specific */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.filter-bar label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted-content);
  margin-bottom: 0.25rem;
  display: block;
}

.filter-bar input,
.filter-bar select {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  padding: 0.5rem 0.75rem;
  color: var(--text-content);
  font-size: 0.85rem;
  outline: none;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

.filter-bar .field {
  display: flex;
  flex-direction: column;
}

.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.report-tab {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  border: 1px solid var(--border-light);
  color: var(--text-muted-content);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.report-tab:hover {
  border-color: var(--primary);
  color: var(--text-content);
}

.report-tab.active {
  background: rgba(13,148,136,0.08);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.peak-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  height: 120px;
  padding: 0.5rem 0;
}

.peak-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.peak-bar .label {
  font-size: 0.6rem;
  color: var(--text-muted-content);
  white-space: nowrap;
  position: absolute;
  bottom: -18px;
}

.peak-bar .count {
  font-size: 0.65rem;
  font-weight: 600;
  color: white;
  margin-bottom: 2px;
}

.cat-header td {
  font-size: 1rem;
  font-weight: 700;
  padding-top: 1rem;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
}

.cat-sub td {
  font-size: 0.75rem;
  color: var(--text-muted-content);
  font-style: italic;
  border-bottom: 1px solid rgba(51,65,85,0.15);
}

.grand-total td {
  border-bottom: none;
  padding-top: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted-content);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
}

/* Card grid layout */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Form groups */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-content);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

/* Error list */
.errorlist {
  list-style: none;
  margin-top: 0.25rem;
}

.errorlist li {
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ========== RESPONSIVE ========== */

/* Tablet */
@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }
  .main {
    margin-left: 220px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  }
}

/* Small tablet / landscape phone */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .topbar-right { width: 100%; order: 2; }
  .filter-bar { flex-direction: column; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem 0.5rem; }
}

/* Mobile */
@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr !important;
  }
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .topbar {
    padding: 0.7rem 1rem;
  }

  .content {
    padding: 1rem;
  }

  /* Dashboard: stack products + cart on mobile */
  div[style*="1fr 380px"] {
    grid-template-columns: 1fr !important;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
  }
}
