/* ===== Design Tokens — Warm Light Theme ===== */
:root {
  /* Backgrounds */
  --bg-primary: #f5efe6;
  --bg-secondary: #ece5d9;
  --bg-card: #ffffff;
  --bg-card-hover: #faf7f2;
  --bg-sidebar: #1a1a1a;
  --bg-input: #ece5d9;

  /* Borders */
  --border-color: rgba(0, 0, 0, 0.06);
  --border-color-hover: rgba(0, 0, 0, 0.12);

  /* Text — main content (dark on light) */
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #9a9a9a;

  /* Text — sidebar (light on dark) */
  --sidebar-text: #ffffff;
  --sidebar-text-muted: rgba(255, 255, 255, 0.4);
  --sidebar-text-secondary: rgba(255, 255, 255, 0.7);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: #e8c4c8;
  --sidebar-active-text: #1a1a1a;

  /* Accent palette */
  --accent-primary: #d4a0a8;
  --accent-primary-glow: rgba(212, 160, 168, 0.3);
  --accent-secondary: #c48b94;
  --accent-gradient: linear-gradient(135deg, #d4a0a8 0%, #e8c4c8 100%);

  /* Pastel card colors */
  --pastel-pink: #f5d5cb;
  --pastel-pink-dark: #e8bfb3;
  --pastel-green: #d5e8c0;
  --pastel-green-dark: #c2d9a8;
  --pastel-lavender: #c8c6e0;
  --pastel-lavender-dark: #b3b0d1;
  --pastel-yellow: #f5e6a3;
  --pastel-yellow-dark: #e8d88a;
  --pastel-rose: #f0c4d0;
  --pastel-rose-dark: #e0aabb;

  /* Semantic colors */
  --success: #3d9970;
  --success-bg: rgba(61, 153, 112, 0.12);
  --warning: #d4930d;
  --warning-bg: rgba(212, 147, 13, 0.12);
  --danger: #cc4455;
  --danger-bg: rgba(204, 68, 85, 0.10);
  --info: #4a7fb5;
  --info-bg: rgba(74, 127, 181, 0.12);

  /* Stat card accent */
  --revenue-bg: var(--pastel-pink);
  --revenue-color: #8a4a50;
  --users-bg: var(--pastel-green);
  --users-color: #4a6a30;
  --orders-bg: var(--pastel-lavender);
  --orders-color: #5a5580;
  --conversion-bg: var(--pastel-yellow);
  --conversion-color: #7a6a20;

  /* Layout */
  --sidebar-width: 230px;
  --sidebar-collapsed-width: 72px;
  --header-height: 60px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 16px var(--accent-primary-glow);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

input, select {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 100px;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow), transform var(--transition-slow);
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  overflow: hidden;
}

.sidebar-header {
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}

.logo {
  display: flex;
  align-items: center;
}

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-muted);
  transition: all var(--transition-fast);
}

.sidebar-close:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}

.sidebar-close svg {
  width: 18px;
  height: 18px;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--sidebar-text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section {
  display: flex;
  flex-direction: column;
}

.nav-section-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text-muted);
  padding: 18px 12px 8px;
  user-select: none;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link i,
.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}

/* Active state — warm pink pill like the reference */
.nav-item.active .nav-link {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  font-weight: 600;
}

.nav-item.active .nav-link::before {
  display: none;
}

.badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  line-height: 1.4;
}

.nav-bottom {
  margin-top: auto;
  padding-top: 4px;
}

.nav-divider {
  margin: 4px 0;
  height: 1px;
  background: var(--sidebar-border);
}

.nav-link-logout {
  color: var(--sidebar-text-muted);
}

.nav-link-logout:hover {
  color: #ff8a8a;
  background: rgba(255, 100, 100, 0.1);
}

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

/* ===== Sidebar Backdrop (Mobile/Tablet) ===== */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 18, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.sidebar-open {
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 50;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle {
  display: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.sidebar-toggle svg {
  width: 22px;
  height: 22px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  padding: 8px 16px;
  min-width: 300px;
  transition: all var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--accent-secondary);
  box-shadow: var(--shadow-glow);
  background: #fff;
}

.search-bar svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  font-size: 0.8125rem;
  width: 100%;
  color: var(--text-primary);
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-profile:hover {
  background: var(--bg-secondary);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.user-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ===== Page Content ===== */
.page-content {
  padding: 28px 32px 40px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 10px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--bg-sidebar);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: #333;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-color-hover);
  background: var(--bg-card-hover);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  border: none;
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all var(--transition-base);
  color: var(--text-primary);
}

.stat-card:nth-child(1) { background: var(--pastel-pink); }
.stat-card:nth-child(2) { background: var(--pastel-green); }
.stat-card:nth-child(3) { background: var(--pastel-lavender); }
.stat-card:nth-child(4) { background: var(--pastel-yellow); }

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

/* Override individual icon classes since we use card bg colors now */
.stat-icon.revenue,
.stat-icon.users,
.stat-icon.orders,
.stat-icon.conversion {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.stat-change svg {
  width: 14px;
  height: 14px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
}

.card-body {
  padding: 22px;
}

/* ===== Charts Grid ===== */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 28px;
}

.chart-card .card-body {
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-card canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== Select ===== */
.select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.select-sm:hover {
  border-color: var(--border-color-hover);
  color: var(--text-primary);
}

.icon-btn-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.icon-btn-sm:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.icon-btn-sm svg {
  width: 16px;
  height: 16px;
}

/* ===== Table ===== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 16px;
}

.table td {
  padding: 14px 16px;
  font-size: 0.8125rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-card-hover);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== Status Badges ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
}

.status-badge.success { background: var(--success-bg); color: var(--success); }
.status-badge.warning { background: var(--warning-bg); color: var(--warning); }
.status-badge.danger { background: var(--danger-bg); color: var(--danger); }
.status-badge.info { background: var(--info-bg); color: var(--info); }

/* ===== Link ===== */
.link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-secondary);
  transition: color var(--transition-fast);
}

.link:hover {
  color: var(--accent-primary);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card {
  animation: fadeInUp 0.5s ease backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

.card {
  animation: fadeInUp 0.5s ease 0.25s backwards;
}

/* ===== Responsive Design System ===== */

/* Large Tablets & Medium Laptops (<= 1200px) */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .chart-card .card-body {
    height: 260px;
  }
}

/* Tablets (<= 1024px) — Convert sidebar to smooth off-canvas drawer */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 14px 0 40px rgba(0, 0, 0, 0.28);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    z-index: 200;
  }

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

  .sidebar-close {
    display: flex;
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .header {
    padding: 0 20px;
  }

  .page-content {
    padding: 24px 20px 36px;
  }
}

/* Small Tablets & Large Phones (<= 768px) */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
    height: 58px;
  }

  .search-bar {
    min-width: 0;
    flex: 1;
    padding: 7px 14px;
  }

  .user-info,
  .user-chevron {
    display: none;
  }

  .user-profile {
    padding: 0;
  }

  .page-content {
    padding: 20px 16px 32px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 22px;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }

  .page-actions {
    display: flex;
    width: 100%;
    gap: 10px;
  }

  .page-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 22px;
  }

  .stat-card {
    padding: 16px 14px;
    gap: 12px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .charts-grid {
    gap: 16px;
    margin-bottom: 22px;
  }

  .chart-card .card-body {
    height: 230px;
    padding: 16px;
  }

  .card-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .card-body {
    padding: 16px;
  }

  #recent-activity .card-body {
    padding: 0;
  }

  .table th,
  .table td {
    padding: 12px 14px;
    font-size: 0.78rem;
  }
}

/* Compact Mobile Devices (<= 480px) */
@media (max-width: 480px) {
  .header {
    padding: 0 12px;
    gap: 8px;
  }

  .header-left,
  .header-right {
    gap: 6px;
  }

  .search-bar {
    padding: 6px 12px;
  }

  /* 16px prevents iOS Safari from automatically zooming in on input focus */
  .search-bar input {
    font-size: 16px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }

  .page-content {
    padding: 16px 12px 28px;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  .page-subtitle {
    font-size: 0.8rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .sidebar {
    width: min(84vw, 260px);
  }
}
