/* ============================================================
   StockMaster Pro - Main CSS
   Only universally supported CSS properties used
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #e0e7ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --purple: #8b5cf6;
  --sidebar-bg: #1e1b4b;
  --sidebar-bg2: #312e81;
  --text-dark: #0f172a;
  --text-mid: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-soft: #f8fafc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-page);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* Global scrollbar - webkit only (Chrome/Edge/Safari) */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--bg-soft);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============================================================
   SHELL
   ============================================================ */
.im-shell {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.im-sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  -webkit-transition: width 0.3s ease, min-width 0.3s ease;
  transition: width 0.3s ease, min-width 0.3s ease;
  position: relative;
  z-index: 200;
  overflow: hidden;
}

.im-sidebar.collapsed {
  width: 62px;
  min-width: 62px;
}

/* Logo */
.im-sidebar-logo {
  padding: 18px 16px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 64px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.im-logo-icon {
  font-size: 1.4rem;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.im-logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  -webkit-transition: opacity 0.2s;
  transition: opacity 0.2s;
}

.im-sidebar.collapsed .im-logo-text {
  opacity: 0;
  width: 0;
}

/* Collapse toggle */
.im-sidebar-toggle {
  position: absolute;
  top: 20px;
  right: -11px;
  width: 22px;
  height: 22px;
  background: #4f46e5;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  color: #fff;
  font-size: 0.6rem;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  line-height: 1;
}

/* ============================================================
   SIDEBAR NAV - Scrollable (THE KEY FIX)
   ============================================================ */
.im-sidebar-nav {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0px;
  flex: 1 1 0px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
  -webkit-overflow-scrolling: touch;
}

/* Sidebar nav scrollbar - webkit */
.im-sidebar-nav::-webkit-scrollbar {
  width: 3px;
}
.im-sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.im-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
}
.im-sidebar-nav:hover::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.4);
}

/* Section labels */
.im-nav-section {
  padding: 10px 16px 4px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.im-sidebar.collapsed .im-nav-section {
  display: none;
}

/* Nav links */
.im-nav-item {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-transition: background 0.2s ease, color 0.2s ease;
  transition: background 0.2s ease, color 0.2s ease;
  color: rgba(255,255,255,0.65);
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  border-left: 3px solid transparent;
  text-decoration: none;
  position: relative;
}

.im-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.im-nav-item.active {
  background: rgba(99,102,241,0.28);
  color: #fff;
  border-left-color: #818cf8;
}

.im-nav-icon {
  font-size: 1rem;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  display: inline-block;
}

.im-nav-label {
  -webkit-transition: opacity 0.2s;
  transition: opacity 0.2s;
  overflow: hidden;
}

.im-sidebar.collapsed .im-nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.im-sidebar.collapsed .im-nav-item {
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  padding: 12px 0;
}

/* Tooltip on collapsed hover */
.im-sidebar.collapsed .im-nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 68px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
  background: #1e1b4b;
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.76rem;
  padding: 5px 12px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  -webkit-transition: opacity 0.18s ease;
  transition: opacity 0.18s ease;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.im-sidebar.collapsed .im-nav-item:hover::after {
  opacity: 1;
}

/* Sidebar footer */
.im-sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.im-user-pill {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
}

.im-user-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #4f46e5;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-size: 0.9rem;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.im-user-info {
  overflow: hidden;
  min-width: 0;
}

.im-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.im-user-role {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
}

.im-sidebar.collapsed .im-user-info {
  display: none;
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.im-main {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  height: 100vh;
}

/* ---- TOPBAR ---- */
.im-topbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  height: 60px;
  padding: 0 24px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  gap: 16px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.im-topbar-left {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.im-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.im-topbar-right {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.im-topbar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  color: #64748b;
  font-size: 1rem;
  -webkit-transition: background 0.2s ease;
  transition: background 0.2s ease;
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.im-topbar-btn:hover {
  background: #f8fafc;
  color: #0f172a;
}

.im-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 0.58rem;
  color: #fff;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-weight: 700;
}

.im-role-wrap {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 8px;
  background: #eef2ff;
  border-radius: 8px;
  padding: 6px 12px;
}

.im-role-label {
  font-size: 0.73rem;
  color: #4f46e5;
  font-weight: 600;
  white-space: nowrap;
}

.im-role-select {
  background: transparent;
  border: none;
  font-size: 0.78rem;
  color: #3730a3;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  max-width: 160px;
}

/* ---- PAGE CONTENT - scrollable ---- */
.im-content {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0px;
  flex: 1 1 0px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
}

/* ============================================================
   NOTIFICATION PANEL
   ============================================================ */
.im-notif-panel {
  position: fixed;
  top: 60px;
  right: 0;
  width: 320px;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  height: calc(100vh - 60px);
  overflow-y: auto;
  z-index: 9998;
  -webkit-transform: translateX(100%);
  transform: translateX(100%);
  -webkit-transition: -webkit-transform 0.3s ease;
  transition: transform 0.3s ease;
}

.im-notif-panel.open {
  -webkit-transform: translateX(0);
  transform: translateX(0);
}

.im-notif-head {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
}

.im-notif-head h4 {
  font-size: 0.9rem;
  font-weight: 700;
}

.im-notif-item {
  padding: 13px 20px;
  border-bottom: 1px solid #f8fafc;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 12px;
  -webkit-box-align: start;
  -ms-flex-align: start;
  align-items: flex-start;
}

.im-notif-item.unread {
  background: #fafbff;
}

.im-notif-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-size: 0.95rem;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.im-notif-txt {
  font-size: 0.8rem;
  color: #334155;
  line-height: 1.4;
}

.im-notif-time {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 3px;
}

/* ============================================================
   TOAST
   ============================================================ */
.im-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border-left: 4px solid #4f46e5;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 0.85rem;
  color: #0f172a;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
  z-index: 99999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  -webkit-transform: translateY(80px);
  transform: translateY(80px);
  opacity: 0;
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
  max-width: 320px;
  font-weight: 500;
  pointer-events: none;
}

.im-toast.show {
  -webkit-transform: translateY(0);
  transform: translateY(0);
  opacity: 1;
}

/* ============================================================
   MOBILE BACKDROP
   ============================================================ */
.im-sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15,23,42,0.5);
  z-index: 299;
}

.im-sidebar-backdrop.show {
  display: block;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .im-sidebar {
    width: 200px;
    min-width: 200px;
  }
  .im-sidebar.collapsed {
    width: 56px;
    min-width: 56px;
  }
  .im-content {
    padding: 18px;
  }
}

@media (max-width: 768px) {
  .im-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 240px;
    min-width: 240px;
    z-index: 300;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
    -webkit-transition: -webkit-transform 0.3s ease;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .im-sidebar.mobile-open {
    -webkit-transform: translateX(0);
    transform: translateX(0);
  }
  .im-content {
    padding: 14px;
  }
  .im-topbar {
    padding: 0 14px;
  }
  .im-role-label {
    display: none;
  }
  .im-page-title {
    font-size: 0.92rem;
  }
}

@media (max-width: 480px) {
  .im-role-wrap {
    padding: 5px 8px;
  }
  .im-role-select {
    max-width: 110px;
    font-size: 0.72rem;
  }
  .im-notif-panel {
    width: 100%;
  }
  .im-content {
    padding: 12px;
  }
}
