/* Trade Union SaaS - Master Design System & Core Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand Color Palette */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  /* Neutral Slate Scale */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Semantic State Colors */
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-subtle: rgba(16, 185, 129, 0.12);
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-subtle: rgba(245, 158, 11, 0.12);
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-subtle: rgba(244, 63, 94, 0.12);
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;
  --purple-subtle: rgba(139, 92, 246, 0.12);
  --blue-subtle: rgba(59, 130, 246, 0.12);

  /* Light Theme Variables */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-topbar: rgba(255, 255, 255, 0.88);
  
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: #3b82f6;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.25);
  --shadow-glow-purple: 0 0 25px rgba(139, 92, 246, 0.25);
  --shadow-glow-emerald: 0 0 25px rgba(16, 185, 129, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 68px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  min-height: 100%;
  width: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--slate-700);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--slate-600);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* App Shell Structure */
.app-shell-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--bg-app);
  position: relative;
  overflow-x: hidden;
}

/* Sidebar Styling */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--slate-300);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
  transition: width var(--transition-smooth), transform var(--transition-smooth);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.brand-crest {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563EB, #4F46E5);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.sidebar-brand:hover .brand-crest {
  transform: scale(1.05) rotate(2deg);
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.badge-pro {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.brand-sub {
  font-size: 11px;
  color: var(--slate-400);
  display: block;
  white-space: nowrap;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--slate-400);
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-close-btn {
  background: transparent;
  border: none;
  color: var(--slate-400);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.sidebar-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 12px;
}

.sidebar-nav-section {
  margin-bottom: 22px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-400);
  padding: 0 10px;
  margin-bottom: 8px;
  display: block;
  white-space: nowrap;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--slate-300);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.nav-item-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(3px);
}

.nav-item-btn.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(79, 70, 229, 0.28));
  color: #ffffff;
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.nav-item-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background: #3b82f6;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 8px #3b82f6;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-400);
  transition: color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.nav-item-btn:hover .nav-icon {
  color: #60a5fa;
  transform: scale(1.1);
}

.nav-item-btn.active .nav-icon {
  color: #60a5fa;
}

.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  color: var(--slate-300);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.nav-item-btn.active .nav-badge {
  background: #3b82f6;
  color: #ffffff;
}

/* Sidebar User Footer */
.sidebar-user-footer {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-user-avatar img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1.5px solid #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.sidebar-user-meta {
  flex: 1;
  min-width: 0;
}

.user-fullname {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 11px;
  color: var(--slate-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collapsed Sidebar Mode */
.app-sidebar.sidebar-collapsed {
  width: var(--sidebar-collapsed-width);
}
.app-sidebar.sidebar-collapsed .sidebar-brand-text,
.app-sidebar.sidebar-collapsed .nav-section-label,
.app-sidebar.sidebar-collapsed .nav-item-btn span,
.app-sidebar.sidebar-collapsed .nav-badge,
.app-sidebar.sidebar-collapsed .sidebar-user-meta {
  display: none;
}
.app-sidebar.sidebar-collapsed .nav-item-btn {
  justify-content: center;
  padding: 12px 0;
}
.app-sidebar.sidebar-collapsed .sidebar-user-footer {
  justify-content: center;
  padding: 12px 0;
}

/* App Main Wrapper */
.app-main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  min-width: 0; /* CRITICAL: Prevents flex children from overflowing viewport */
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-smooth);
}

.app-shell-layout.collapsed-sidebar .app-main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

/* Topbar Header */
.app-topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 clamp(14px, 2vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.mobile-menu-trigger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.mobile-menu-trigger:hover {
  background: var(--bg-surface-hover);
}

.topbar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.topbar-collapse-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--primary-600);
  border-color: var(--primary-400);
}

.topbar-search-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: clamp(160px, 26vw, 320px);
  max-width: 320px;
  overflow: hidden;
  white-space: nowrap;
}

.topbar-search-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-search-btn:hover {
  background: var(--bg-surface);
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.topbar-search-btn kbd {
  margin-left: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1vw, 12px);
  flex-shrink: 0;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.topbar-icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--primary-400);
  transform: translateY(-1px);
}

.notification-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--rose-500);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
  animation: pulseNotif 2s infinite;
}

@keyframes pulseNotif {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 2px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.topbar-user:hover {
  background: var(--bg-surface-hover);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1.5px solid var(--primary-500);
}

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

.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.topbar-user-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary-600);
}

/* Theme Icon Visibility */
[data-theme="light"] .moon-icon { display: block; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }

/* Main Dynamic View Area */
.app-main-content {
  flex: 1;
  padding: clamp(18px, 2.5vw, 32px) clamp(16px, 3vw, 36px);
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  min-width: 0; /* CRITICAL */
  box-sizing: border-box;
}

.view-content-wrapper {
  width: 100%;
  min-width: 0;
}

/* ==========================================
   ANIMATIONS & ENGAGEMENT LIBRARY
   ========================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.animate-scale-up {
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
.animate-slide-in {
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes floatOrb {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); }
}
.animate-float {
  animation: floatOrb 6s ease-in-out infinite;
}

@keyframes shimmerEffect {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulseLive {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pulse-live-emerald {
  animation: pulseLive 2.2s infinite;
}

/* Stagger Animation Delays */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }

/* Skeleton Loading Pulse */
.view-loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px 0;
  width: 100%;
}
.skeleton-bar {
  height: 36px;
  width: min(320px, 80%);
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-surface-hover) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s infinite;
  border-radius: var(--radius-md);
}
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.skeleton-card {
  height: 140px;
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-surface-hover) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s infinite;
  border-radius: var(--radius-lg);
}
@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Responsive Media Queries */
@media (max-width: 1080px) {
  .topbar-user-badge {
    display: none;
  }
}

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.mobile-open {
    transform: translateX(0);
  }
  .app-main-wrapper {
    margin-left: 0 !important;
  }
  .mobile-menu-trigger {
    display: block;
  }
  .topbar-collapse-btn {
    display: none;
  }
  .app-main-content {
    padding: 18px 14px;
  }
  .topbar-user-info {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar-search-btn kbd {
    display: none;
  }
  .topbar-search-btn {
    width: 140px;
  }
  .topbar-divider {
    display: none;
  }
}
