/* ===========================
   Inventory System - Main CSS
   Design ref: clean dashboard UI
   =========================== */

:root {
  --bg:          #F0EBFA;
  --surface:     #FFFFFF;
  --sidebar-w:   240px;
  --header-h:    64px;

  --primary:     #7C3AED;
  --primary-hover:#6D28D9;
  --primary-light:#EDE9FE;

  --dark:        #1A1A2E;
  --text:        #1F2937;
  --text-muted:  #6B7280;
  --text-light:  #9CA3AF;

  --border:      #E5E7EB;
  --border-focus:#7C3AED;
  --focus-ring:  rgba(124,58,237,.12);

  --success:     #10B981;
  --success-bg:  #D1FAE5;
  --warning:     #F59E0B;
  --warning-bg:  #FEF3C7;
  --danger:      #EF4444;
  --danger-bg:   #FEE2E2;
  --info:        #3B82F6;
  --info-bg:     #DBEAFE;

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:      0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);

  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --transition:  .2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

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

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: 1.375rem; font-weight: 600; letter-spacing: -.02em; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-muted); }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  width: 100%;
}

/* ── Sidebar ── */
.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  width: var(--sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img { width: 32px; height: 32px; border-radius: var(--radius-sm); object-fit: contain; }
.sidebar-logo-text { font-size: 1.1rem; font-weight: 700; color: var(--dark); }

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-light);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg); }
.sidebar-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
  cursor: pointer;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .72rem; color: var(--text-muted); text-transform: capitalize; }

/* ── Top Header ── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.page-title-area { flex: 1; }
.page-title-area h1 { font-size: 1.2rem; font-weight: 700; }
.page-breadcrumb { font-size: .8rem; color: var(--text-muted); }

.header-search {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  gap: 8px;
  width: 280px;
  transition: border-color var(--transition);
}
.header-search:focus-within { border-color: var(--border-focus); }
.header-search input { background: none; border: none; outline: none; font-size: .875rem; width: 100%; color: var(--text); }
.header-search svg { color: var(--text-muted); width: 16px; height: 16px; flex-shrink: 0; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-body { padding: 20px 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .18s, transform .18s, border-color .18s;
  cursor: pointer;
}
.stat-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
  transform: translateY(-2px);
  border-color: var(--primary);
}
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-primary:hover { background: #2d2d4e; color: #fff; }

.btn-purple { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-purple:hover { background: var(--primary-hover); color: #fff; }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }

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

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 9px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-sm  { max-width: 420px; }
.modal-lg  { max-width: 820px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: none;
  font-size: 1.4rem; cursor: pointer;
  color: var(--text-muted); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }

/* ── Page header (no subtitle) ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

/* ── intl-tel-input overrides ── */
.iti { width: 100%; }
.iti__flag-container { z-index: 10; }

/* ── Mobile ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  #sidebar-overlay.active { display: block !important; }
}
