/* ============================================
   PharmaERP Layout Styles v4.0
   Vibrant Modern SaaS Design
   ============================================ */

/* APP SHELL */
.app-wrapper { display: flex; min-height: 100vh; }

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left var(--transition-slow);
}

/* ═══════════════════════════════════════
   SIDEBAR - Fresh Lemon & Green
   ═══════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--gradient-sidebar);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-slow);
  overflow: hidden;
  border-right: 1px solid rgba(250,204,21,0.25);
  box-shadow: 2px 0 20px rgba(250,204,21,0.1);
}
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(163,230,53,0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(250,204,21,0.1) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 80%, rgba(34,197,94,0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.sidebar > * { position: relative; z-index: 1; }

/* Brand */
.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(250,204,21,0.2);
  min-height: var(--header-height);
  background: rgba(255,255,240,0.6);
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 40%, #a3e635 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(22,163,74,0.3), 0 0 20px rgba(163,230,53,0.15);
  animation: glowPulse 3s ease-in-out infinite;
}
.sidebar-brand-text { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-brand-text h1 {
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: 0.3px;
  margin: 0;
  line-height: 1.3;
}
.sidebar-brand-text h1 span {
  background: linear-gradient(135deg, #16a34a 0%, #65a30d 50%, #ca8a04 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: var(--font-extrabold);
}
.sidebar-brand-text > span {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* Company Switcher */
.company-switcher {
  margin: 12px 14px 4px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-base);
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.company-switcher:hover {
  background: rgba(22,163,74,0.07);
  border-color: rgba(22,163,74,0.2);
}
.company-switcher i { color: #16a34a; }
.company-switcher .chevron { margin-left: auto; font-size: 0.7rem; opacity: 0.4; color: var(--text-muted); }
.company-switcher .company-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(22,163,74,0.1), rgba(163,230,53,0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #16a34a;
}
.company-switcher .company-info { flex: 1; min-width: 0; }
.company-switcher .company-info .label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  line-height: 1.2;
}
.company-switcher .company-info .name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Sidebar Search */
.sidebar-search { padding: 8px 14px 12px; position: relative; }
.sidebar-search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  transition: var(--transition-base);
}
.sidebar-search-input::placeholder { color: var(--text-muted); }
.sidebar-search-input:focus {
  background: #fffff8;
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12), 0 0 16px rgba(163,230,53,0.08);
}
.sidebar-search-icon {
  position: absolute;
  left: 26px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}
.sidebar-search-shortcut {
  position: absolute;
  right: 24px; top: 50%;
  transform: translateY(-50%);
  background: var(--gray-100);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-family: var(--font-mono);
  border: 1px solid var(--border-light);
}
.sidebar-search .search-clear {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.8rem;
  line-height: 1;
  display: none;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}
.sidebar-search .search-clear:hover { color: var(--text-primary); background: var(--gray-100); }
.sidebar-search.has-value .search-clear { display: flex; }

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }

/* Nav Section */
.nav-section { margin-bottom: 2px; }
.nav-section-header {
  display: flex;
  align-items: center;
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: var(--transition-base);
  user-select: none;
  gap: 10px;
}
.nav-section-header:hover { color: #15803d; }
.nav-section-header i.section-icon {
  font-size: 1rem;
  width: 22px;
  text-align: center;
  background: linear-gradient(135deg, #16a34a, #65a30d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-section-header .section-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.nav-section-header .section-icon i {
  font-size: inherit;
  color: inherit;
}
.nav-section-header .section-label { flex: 1; }
.nav-section-header .section-chevron {
  font-size: 0.8rem;
  opacity: 0.7;
  transition: transform var(--transition-normal), color 0.25s ease, opacity 0.25s ease;
  color: var(--text-muted);
}
.nav-section:not(.open) .section-chevron { transform: rotate(0deg); }
.nav-section.open .section-chevron { transform: rotate(90deg); color: #16a34a; opacity: 1; }
.nav-section-header:hover .section-chevron { opacity: 1; color: #15803d; }
.nav-section-body { display: none; }
.nav-section.open .nav-section-body { display: block; }
.nav-section-header .section-count {
  background: linear-gradient(135deg, rgba(22,163,74,0.1), rgba(163,230,53,0.12));
  color: #15803d;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  font-weight: var(--font-bold);
}

/* Subgroups */
.nav-subgroup-header {
  display: flex;
  align-items: center;
  padding: 7px 18px 7px 44px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.3px;
  transition: var(--transition-base);
  gap: 8px;
}
.nav-subgroup-header:hover { color: #15803d; }
.nav-subgroup-header .subgroup-label { flex: 1; }
.nav-subgroup-header .subgroup-count {
  font-size: 0.6rem;
  background: var(--gray-100);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}
.nav-subgroup-header .subgroup-chevron {
  font-size: 0.7rem;
  opacity: 0.6;
  color: var(--text-muted);
  transition: transform var(--transition-normal), color 0.25s ease, opacity 0.25s ease;
  flex-shrink: 0;
}
.nav-subgroup:not(.open) .subgroup-chevron { transform: rotate(0deg); }
.nav-subgroup.open .subgroup-chevron { transform: rotate(90deg); color: #16a34a; opacity: 1; }
.nav-subgroup-header:hover .subgroup-chevron { opacity: 1; color: #15803d; }
.nav-subgroup-body { display: none; }
.nav-subgroup.open .nav-subgroup-body { display: block; }

/* Nav Items */
.nav-item-link {
  display: flex;
  align-items: center;
  padding: 8px 18px 8px 28px;
  color: var(--text-sidebar);
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  transition: all var(--transition-normal);
  gap: 12px;
  position: relative;
  text-decoration: none;
  margin: 1px 10px;
  border-radius: var(--radius-md);
}
.nav-item-link:hover {
  background: var(--bg-sidebar-hover);
  color: #15803d;
  transform: translateX(2px);
}
.nav-item-link i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  opacity: 0.6;
  color: var(--text-muted);
  transition: var(--transition-base);
}
.nav-item-link:hover i { opacity: 1; color: #22c55e; }
.nav-item-link .nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Active */
.nav-item-link.active {
  background: linear-gradient(135deg, rgba(22,163,74,0.1), rgba(163,230,53,0.08));
  color: #15803d;
  font-weight: var(--font-semibold);
}
.nav-item-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: linear-gradient(180deg, #16a34a, #a3e635);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(22,163,74,0.3);
}
.nav-item-link.active i { opacity: 1; color: #22c55e; }

/* Nav badges */
.nav-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: var(--font-bold);
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}
.nav-badge.bg-primary { background: var(--primary-gradient); }
.nav-badge.bg-danger { background: var(--danger-gradient); }
.nav-badge.bg-success { background: var(--success-gradient); }

/* Search highlight */
.sidebar .search-highlight {
  background: rgba(22,163,74,0.15);
  color: #15803d;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: var(--font-semibold);
}

/* Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(250,204,21,0.2);
  background: rgba(254,249,195,0.4);
  position: relative;
}
.sidebar-footer .dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 14px;
  right: 14px;
  top: auto;
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  border-radius: var(--radius-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all var(--transition-normal);
}
.sidebar-footer .dropdown-menu.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.sidebar-footer .dropdown-item {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-base);
}
.sidebar-footer .dropdown-item:hover { background: rgba(22,163,74,0.07); color: #15803d; }
.sidebar-footer .dropdown-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* No-results styling */
.sidebar-nav .no-results {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.sidebar-nav .no-results i {
  display: block;
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.4;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-base);
}
.sidebar-user:hover { background: rgba(22,163,74,0.07); }
.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 50%, #a3e635 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(22,163,74,0.3);
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name { color: var(--text-primary); font-size: var(--text-sm); font-weight: var(--font-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--text-muted); font-size: var(--text-xs); }
.sidebar-user-dropdown { color: var(--text-muted); font-size: 0.7rem; transition: var(--transition-base); }

/* ═══════════════════════════════════════
   HEADER - Vibrant Glass
   ═══════════════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 var(--page-padding);
  gap: 16px;
  z-index: var(--z-header);
  transition: var(--transition-base);
  box-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 4px 12px rgba(0,0,0,0.03);
}
.header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    #facc15 0%,
    #a3e635 20%,
    #22c55e 40%,
    #16a34a 55%,
    #14b8a6 70%,
    #fbbf24 85%,
    #fde047 100%
  );
  background-size: 200% 100%;
  animation: gradientShift 8s ease infinite;
  opacity: 0.7;
}

.header-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-lg);
  background: var(--gray-100);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-base);
  border: 1px solid var(--border-light);
}
.header-toggle:hover {
  background: var(--primary-50);
  color: var(--primary);
  border-color: var(--primary-200);
  box-shadow: var(--shadow-primary);
  transform: scale(1.05);
}
.header-toggle i { font-size: 1.2rem; }

.header-search { flex: 1; max-width: 400px; position: relative; }
.header-search-input {
  width: 100%; height: 40px;
  padding: 0 16px 0 40px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  transition: var(--transition-base);
}
.header-search-input::placeholder { color: var(--text-muted); }
.header-search-input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.1), var(--shadow-primary);
}
.header-search-input:focus + .header-search-kbd { display: none; }
.header-search-kbd {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  color: var(--text-muted);
  pointer-events: none;
  font-family: var(--font-mono);
}
.header-search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.header-icons { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.header-icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
  border: 1px solid transparent;
}
.header-icon-btn:hover {
  background: var(--primary-50);
  color: var(--primary);
  border-color: var(--primary-100);
  transform: translateY(-1px);
}
.header-icon-btn i { font-size: 1.2rem; }
.header-icon-btn .notif-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger-gradient);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(239,68,68,0.4);
  animation: pulse 2s infinite;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-base);
  border: 1px solid transparent;
  margin-left: 4px;
}
.header-user:hover { background: var(--primary-50); border-color: var(--primary-100); }
.header-user .avatar { width: 34px; height: 34px; font-size: var(--text-xs); }
.header-user-name { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-primary); }

.header-user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-left: 6px;
  transition: var(--transition-base);
  box-shadow: 0 3px 10px rgba(22,163,74,0.3);
  border: 2px solid rgba(255,255,255,0.8);
}
.header-user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 16px rgba(22,163,74,0.4);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  padding: var(--page-padding);
  max-width: var(--container-max);
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

/* COLLAPSED STATE */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-collapsed); }
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .company-switcher,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .nav-section-header .section-label,
body.sidebar-collapsed .nav-section-header .section-chevron,
body.sidebar-collapsed .nav-section-header .section-count,
body.sidebar-collapsed .nav-item-link .nav-text,
body.sidebar-collapsed .nav-item-link .nav-badge,
body.sidebar-collapsed .nav-subgroup-header .subgroup-label,
body.sidebar-collapsed .nav-subgroup-header .subgroup-chevron,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-user-dropdown { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 18px 12px; }
body.sidebar-collapsed .nav-section-header { justify-content: center; padding: 10px; }
body.sidebar-collapsed .nav-section-header .section-icon { width: 22px; height: 22px; font-size: 0.85rem; }
body.sidebar-collapsed .nav-item-link { justify-content: center; padding: 10px 0; margin: 1px 8px; }
body.sidebar-collapsed .nav-subgroup-header { justify-content: center; padding: 7px 0; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }
body.sidebar-collapsed .nav-item-link.active::before { display: none; }

/* Tooltip on collapsed */
body.sidebar-collapsed .nav-item-link { position: relative; }
body.sidebar-collapsed .nav-item-link::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 12px); top: 50%;
  transform: translateY(-50%);
  background: var(--gray-900);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-lg);
}
body.sidebar-collapsed .nav-item-link:hover::after { opacity: 1; }

/* MOBILE */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--transition-slow);
}
body.sidebar-mobile-open .sidebar-overlay { display: block; opacity: 1; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-mobile-open .sidebar { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,0.3); }
  .main-wrapper { margin-left: 0 !important; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-width); transform: translateX(-100%); }
  body.sidebar-mobile-open.sidebar-collapsed .sidebar { transform: translateX(0); }
}
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .header { padding: 0 16px; }
  .header-search { display: none; }
  .header-user-name { display: none; }
}
@media (max-width: 640px) {
  .main-content { padding: 12px; }
}
