/* ==============================================================================
   CAT ENTERPRISE PLATFORM - PREMIUM DESIGN SYSTEM
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Brand Palette - Deep Royal Blue */
  --brand-primary:   hsl(226, 71%, 40%);   /* Premium deep blue */
  --brand-primary-hover: hsl(226, 71%, 32%);
  --brand-secondary: hsl(215, 16%, 47%);   
  --brand-surface:   hsl(226, 71%, 95%);
  
  /* Semantic */
  --color-success:   hsl(152, 69%, 31%);   /* Refined emerald */
  --color-danger:    hsl(348, 83%, 47%);   /* Refined crimson */
  --color-warning:   hsl(38, 92%, 50%);    
  --color-info:      hsl(199, 89%, 48%);   

  /* Light Theme */
  --bg-app: #F4F7F9; /* Very soft cool gray */
  --bg-card: #FFFFFF;
  --bg-sidebar: #090E17; /* Vantablack/Midnight */
  --text-main: #111827; /* Near black */
  --text-muted: #6B7280;
  --border-color: rgba(17, 24, 39, 0.08);
  
  /* Precision Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 20px -10px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  --shadow-hover: 0 12px 24px -10px rgba(0, 0, 0, 0.1), 0 4px 8px -4px rgba(0, 0, 0, 0.05);

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
}

[data-bs-theme="dark"] {
  --bg-app: #0B0F19;
  --bg-card: #131C2F;
  --bg-sidebar: #060913;
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --border-color: rgba(255, 255, 255, 0.06);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 20px -10px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 12px 24px -10px rgba(0, 0, 0, 0.5);
  --brand-surface: rgba(255,255,255,0.05);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-main);
}

code, pre, .font-monospace {
  font-family: var(--font-mono) !important;
}

/* Layout Elements */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: #F8FAFC;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.03);
  box-shadow: 2px 0 20px rgba(0,0,0,0.15);
}

.app-sidebar .sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.app-sidebar .sidebar-brand h5 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #ffffff, #9CA3AF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-menu {
  list-style: none;
  padding: 20px 14px;
  margin: 0;
  flex-grow: 1;
}

.sidebar-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #4B5563;
  padding: 16px 14px 8px;
  font-weight: 700;
}

.sidebar-item {
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #9CA3AF;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-link i {
  width: 20px;
  font-size: 1.1rem;
  text-align: center;
  transition: transform 0.2s ease;
}

.sidebar-link:hover {
  color: #FFFFFF;
  background-color: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.sidebar-item.active .sidebar-link {
  color: #FFFFFF;
  background-color: var(--brand-primary);
  background-image: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* App Main Content */
.app-main {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Topbar */
.app-topbar {
  height: 72px;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 999;
}

[data-bs-theme="dark"] .app-topbar {
  background-color: rgba(19, 28, 47, 0.85);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Content Container */
.app-content {
  padding: 32px;
  flex-grow: 1;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 20px 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 24px;
}

/* Metric / Stat Card */
.stat-card {
  display: flex;
  align-items: center;
  padding: 24px;
  border-radius: 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-right: 20px;
  background: var(--brand-surface);
  color: var(--brand-primary);
  transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
  background: var(--brand-primary);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.stat-val {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Tables */
.table-responsive {
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.table {
  color: var(--text-main);
  border-color: var(--border-color);
  vertical-align: middle;
  margin-bottom: 0;
}

.table thead th {
  background-color: var(--bg-app);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  border-top: none;
}

.table tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.table tbody tr {
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background-color: var(--bg-app);
}

/* Buttons */
.btn {
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.9rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.01em;
}

.btn-primary {
  background-color: var(--brand-primary);
  border: none;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Inputs & Forms */
.form-control, .form-select {
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px var(--brand-surface);
  outline: none;
}

/* Badges */
.badge {
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* Utilities */
.text-brand { color: var(--brand-primary) !important; }
.bg-brand { background-color: var(--brand-primary) !important; }

/* Responsive adjustments */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}
