/* ============================================
   PostPro Nexus - Deep Obsidian Dark Theme
   Overlay for the Command Center dashboard
   Matches the Finance module's dark design language
   ============================================ */

/* ── Design Tokens ── */
:root {
  /* Surface hierarchy */
  --bg-color: #080C14;
  --bg-primary: #080C14;
  --bg-secondary: #111827;
  --bg-tertiary: #1A2236;
  --bg-hover: rgba(255, 255, 255, 0.04);

  --card-bg: #111827;

  /* Text hierarchy */
  --text-main: #F1F5F9;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Sidebar — darker than before */
  --sidebar-bg: #0B1120;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.04);
  --sidebar-bg-active: rgba(79, 195, 202, 0.12);
  --sidebar-text: #64748B;
  --sidebar-text-bright: #F1F5F9;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* Borders — ultra-subtle */
  --border-light: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-color: rgba(255, 255, 255, 0.06);

  /* Accent — stays teal */
  --accent-primary: #4FC3CA;
  --accent-secondary: #3BA8AE;
  --accent-light: rgba(79, 195, 202, 0.1);
  --accent-gradient: linear-gradient(135deg, #4FC3CA 0%, #3BA8AE 100%);

  /* Department colors — vibrant on dark */
  --dept-technical: #4FC3CA;
  --dept-operations: #34D399;
  --dept-sales: #FBBF24;
  --dept-finance: #4FC3CA;
  --dept-customer: #60A5FA;
  --dept-logistics: #A78BFA;
  --dept-hr: #34D399;

  /* Status colors */
  --status-success: #34D399;
  --status-warning: #FBBF24;
  --status-error: #F87171;
  --status-info: #4FC3CA;

  /* Shadows — deeper */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 60px rgba(79, 195, 202, 0.04);

  /* Grid pattern — subtle */
  --grid-line: rgba(255, 255, 255, 0.015);
  --grid-color: rgba(255, 255, 255, 0.02);

  /* Radius — slightly larger for modern feel */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* ── Base Override ── */

body {
  background-color: var(--bg-color);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text-main);
  font-family: 'Outfit', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', 'Roboto', sans-serif;
  color: var(--text-primary);
}

/* ── Sidebar ── */

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
}

/* Sidebar nav section titles */
.nav-section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--sidebar-text);
}

.nav-item {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  background: var(--sidebar-bg-active);
  color: var(--accent-primary);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 3px 0 0 3px;
}

.nav-item {
  position: relative;
}

.search-input-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
}

.search-input-wrapper:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-search .search-placeholder {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
}

/* ── Topbar ── */

.topbar {
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  backdrop-filter: blur(12px);
}

.page-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-bright);
}

.topbar .system-status {
  background: rgba(52, 211, 153, 0.08);
  color: var(--status-success);
  border: 1px solid rgba(52, 211, 153, 0.12);
  border-radius: var(--radius-lg);
  padding: 6px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 500;
}

.status-text {
  color: var(--status-success);
  font-family: 'Outfit', sans-serif;
}

.topbar-btn {
  color: var(--sidebar-text);
  border-radius: var(--radius-md);
}

.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.topbar-btn.logout-btn:hover {
  background: rgba(248, 113, 113, 0.1);
  color: var(--status-error);
}

/* ── Dashboard Content ── */

.dashboard {
  padding: 36px;
}

/* ── Welcome Section ── */

.welcome-section {
  background: linear-gradient(135deg, #111827 0%, #1A2236 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  padding: 32px 36px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

/* Ambient glow effect */
.welcome-section::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(79, 195, 202, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.welcome-section::after {
  content: '';
  position: absolute;
  bottom: -50%;
  left: 15%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.welcome-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  position: relative;
  z-index: 1;
}

.welcome-subtitle {
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  position: relative;
  z-index: 1;
}

/* ── Recently Used Section ── */

.recently-used-section {
  margin-bottom: 28px;
}

.recently-used-section .section-title {
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.recently-used-grid .module-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  min-width: 170px;
  padding: 16px 18px;
}

.recently-used-grid .module-card:hover {
  background: var(--bg-tertiary);
  border-color: rgba(79, 195, 202, 0.2);
  box-shadow: var(--shadow-md);
}

/* ── Dashboard Sections ── */

.dashboard-section {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.section-title svg {
  color: var(--accent-primary);
  opacity: 0.7;
}

/* ── Module Cards ── */

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.module-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

/* Subtle top accent line on hover */
.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.module-card:hover {
  background: var(--bg-tertiary);
  border-color: rgba(79, 195, 202, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 40px rgba(79, 195, 202, 0.03);
  transform: translateY(-3px);
}

.module-card:hover::before {
  opacity: 1;
}

.module-card:active:not(.locked) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Locked state */
.module-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.module-card.locked:hover {
  background: var(--bg-secondary);
  border-color: var(--border-light);
  box-shadow: none;
  transform: none;
}

.module-card.locked::before {
  display: none;
}

/* Module icon — glass pill */
.module-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  transition: transform 0.2s ease;
}

.module-card:hover .module-icon {
  transform: scale(1.05);
}

/* Department colors on dark — vivid glass */
.module-icon.technical { background: rgba(79, 195, 202, 0.12); color: #4FC3CA; }
.module-icon.operations { background: rgba(52, 211, 153, 0.12); color: #34D399; }
.module-icon.sales { background: rgba(251, 191, 36, 0.12); color: #FBBF24; }
.module-icon.finance { background: rgba(79, 195, 202, 0.12); color: #4FC3CA; }
.module-icon.customer { background: rgba(96, 165, 250, 0.12); color: #60A5FA; }
.module-icon.logistics { background: rgba(167, 139, 250, 0.12); color: #A78BFA; }
.module-icon.hr { background: rgba(52, 211, 153, 0.12); color: #34D399; }

.module-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.module-count {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
}

/* Access badges — glass style */
.module-access-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
}

.module-access-badge.admin {
  background: rgba(248, 113, 113, 0.12);
  color: #F87171;
}

.module-access-badge.editor {
  background: rgba(79, 195, 202, 0.12);
  color: #4FC3CA;
}

.module-access-badge.viewer {
  background: rgba(52, 211, 153, 0.12);
  color: #34D399;
}

.module-access-badge.locked {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

/* ── Command Palette — Dark ── */

.command-palette {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.command-palette::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.command-search {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 18px 22px;
}

.command-search svg {
  color: var(--text-muted);
}

.command-search input {
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
}

.command-search input::placeholder {
  color: #475569;
}

.command-search kbd {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
}

.command-results {
  padding: 10px;
}

.command-group-title {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #475569;
  padding: 10px 14px 6px;
}

.command-item {
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: all 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.command-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.command-item.command-item-active {
  background: rgba(79, 195, 202, 0.08);
  outline: 1px solid rgba(79, 195, 202, 0.2);
}

.command-item-icon {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.command-item-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
}

.command-item-desc {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  color: #475569;
}

.command-no-results {
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  padding: 24px;
  text-align: center;
  font-size: 14px;
}

/* ── Skeleton Loaders — Dark ── */

.skeleton-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmerDark 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.skeleton-text {
  height: 14px;
  width: 80%;
  margin-bottom: 8px;
}

.skeleton-text-sm {
  height: 10px;
  width: 50%;
}

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

/* ── Entrance Animations ── */

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-section,
.recently-used-section,
.dashboard-section {
  animation: fadeSlideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.welcome-section { animation-delay: 0.05s; }
.recently-used-section { animation-delay: 0.1s; }
.dashboard-section { animation-delay: 0.15s; }

/* Stagger module cards */
.module-card {
  animation: fadeSlideUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.modules-grid .module-card:nth-child(1) { animation-delay: 0.08s; }
.modules-grid .module-card:nth-child(2) { animation-delay: 0.12s; }
.modules-grid .module-card:nth-child(3) { animation-delay: 0.16s; }
.modules-grid .module-card:nth-child(4) { animation-delay: 0.20s; }
.modules-grid .module-card:nth-child(5) { animation-delay: 0.24s; }
.modules-grid .module-card:nth-child(6) { animation-delay: 0.28s; }
.modules-grid .module-card:nth-child(7) { animation-delay: 0.32s; }
.modules-grid .module-card:nth-child(8) { animation-delay: 0.36s; }
.modules-grid .module-card:nth-child(9) { animation-delay: 0.40s; }
.modules-grid .module-card:nth-child(10) { animation-delay: 0.44s; }

/* ── Sidebar Backdrop — Darker ── */

.sidebar-backdrop {
  background: rgba(8, 12, 20, 0.75);
  backdrop-filter: blur(8px);
}

/* ── User Info ── */

.user-name {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
}

.user-avatar {
  background: linear-gradient(135deg, rgba(79, 195, 202, 0.2), rgba(59, 168, 174, 0.3));
  border: 1.5px solid rgba(79, 195, 202, 0.15);
}

/* ── Scrollbar — Dark ── */

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ── Collapsed Sidebar — Clean icon-only ── */

.sidebar.collapsed .search-placeholder {
  display: none;
}

.sidebar.collapsed .search-input-wrapper {
  justify-content: center;
  padding: 10px;
  width: 44px;
  margin: 0 auto;
  border-radius: 50%;
}

.sidebar.collapsed .sidebar-search {
  display: flex;
  justify-content: center;
  padding: 12px 0 8px;
}

/* ── Responsive — Mobile ── */

@media (max-width: 768px) {
  /* CRITICAL: prevent collapsed state on mobile — full sidebar or hidden */
  .sidebar {
    width: var(--sidebar-width);
    background: #080C14;
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  /* When sidebar is open on mobile, show everything normally */
  .sidebar.open {
    transform: translateX(0);
    width: var(--sidebar-width);
  }

  /* Restore all text that collapsed state hides */
  .sidebar.collapsed .sidebar-brand,
  .sidebar.collapsed .search-placeholder,
  .sidebar.collapsed .nav-item-text,
  .sidebar.collapsed .nav-item-badge,
  .sidebar.collapsed .user-details,
  .sidebar.collapsed .nav-section-title,
  .sidebar.collapsed .nav-label {
    display: revert;
  }

  .sidebar.collapsed .sidebar-header {
    justify-content: flex-start;
    padding: 24px 20px 20px;
  }

  .sidebar.collapsed .sidebar-collapse-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
  }

  .sidebar.collapsed .sidebar-search {
    display: block;
    padding: 16px 16px 8px;
  }

  .sidebar.collapsed .search-input-wrapper {
    justify-content: flex-start;
    padding: 10px 14px;
    width: 100%;
    border-radius: var(--radius-md);
  }

  .sidebar.collapsed .nav-section-header {
    justify-content: space-between;
    padding: 10px 8px 6px;
  }

  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 11px 14px;
    gap: 12px;
  }

  .sidebar.collapsed .nav-item-icon {
    margin-right: 0;
  }

  .sidebar.collapsed .sidebar-footer {
    padding: 16px;
  }

  .sidebar.collapsed .user-info {
    justify-content: flex-start;
  }

  .sidebar.collapsed .user-avatar {
    margin: 0;
  }

  .sidebar.collapsed .sidebar-logo,
  .sidebar.collapsed .sidebar-logo-icon {
    display: none;
  }

  /* Main content always full width on mobile */
  .main-content {
    margin-left: 0;
  }

  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
  }

  .dashboard {
    padding: 20px;
  }

  .topbar {
    padding: 0 16px;
  }

  .welcome-section {
    padding: 24px;
    margin-bottom: 24px;
  }

  .welcome-title {
    font-size: 1.4rem;
  }

  /* Force 2-column grid on mobile */
  .modules-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .module-card {
    padding: 16px;
    min-width: 0;
  }

  .module-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
  }

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

  .module-name {
    font-size: 13px;
  }

  .module-count {
    font-size: 11px;
  }

  .module-access-badge {
    font-size: 8px;
    padding: 2px 7px;
    top: 10px;
    right: 10px;
  }

  /* Recently used — horizontal scroll, equal sizing */
  .recently-used-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
  }

  .recently-used-grid .module-card {
    min-width: 140px;
    max-width: 160px;
    flex-shrink: 0;
    padding: 14px 16px;
    scroll-snap-align: start;
  }

  .recently-used-grid .module-card .module-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
  }

  .recently-used-grid .module-card .module-icon svg {
    width: 18px;
    height: 18px;
  }

  .recently-used-grid .module-card .module-name {
    font-size: 12px;
  }

  /* Hide sidebar collapse button on mobile */
  .sidebar-collapse-btn {
    display: none;
  }
}

@media (max-width: 480px) {
  .modules-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .module-card {
    padding: 14px;
  }

  .dashboard {
    padding: 16px;
  }

  .welcome-section {
    padding: 20px;
    margin-bottom: 20px;
  }

  .welcome-title {
    font-size: 1.2rem;
  }

  .welcome-subtitle {
    font-size: 13px;
  }

  .recently-used-grid .module-card {
    min-width: 120px;
    max-width: 140px;
  }
}

/* ── Prefers Reduced Motion ── */

@media (prefers-reduced-motion: reduce) {
  .welcome-section,
  .recently-used-section,
  .dashboard-section,
  .module-card {
    animation: none;
  }

  .module-card:hover {
    transform: none;
  }

  .module-card:hover .module-icon {
    transform: none;
  }
}
