:root {
  /* Colors */
  --bg-body: #F3F4F6;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  
  --primary: #4F46E5; /* Indigo 600 */
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  
  --text-main: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  
  --border-color: #E5E7EB;
  
  --status-pending-bg: #FEF3C7;
  --status-pending-text: #D97706;
  --status-progress-bg: #DBEAFE;
  --status-progress-text: #2563EB;
  --status-resolved-bg: #D1FAE5;
  --status-resolved-text: #059669;
  --status-rejected-bg: #FEE2E2;
  --status-rejected-text: #DC2626;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  padding: var(--spacing-lg);
  z-index: 10;
}

.main-content {
  flex: 1;
  margin-left: 260px; /* Sidebar width */
  display: flex;
  flex-direction: column;
}

.header {
  height: 70px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-xl);
  position: sticky;
  top: 0;
  z-index: 5;
}

.content-area {
  padding: var(--spacing-xl);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  color: var(--text-main);
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-weight: 600; }

p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* Components */
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-item:hover {
  background-color: var(--bg-body);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  gap: var(--spacing-sm);
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  background: var(--bg-body);
}

.btn-danger {
  background: #FEE2E2;
  color: #DC2626;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: var(--spacing-lg);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: var(--spacing-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 0.15s;
}

tbody tr:hover {
  background-color: rgba(249, 250, 251, 0.5);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge-progress { background: var(--status-progress-bg); color: var(--status-progress-text); }
.badge-resolved { background: var(--status-resolved-bg); color: var(--status-resolved-text); }
.badge-rejected { background: var(--status-rejected-bg); color: var(--status-rejected-text); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-body);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  width: 300px;
}

.search-bar:focus-within {
  border-color: var(--primary);
  background: white;
}

.search-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  margin-left: 8px;
  font-size: 14px;
}

/* Icons placeholder */
.icon {
  width: 20px;
  height: 20px;
  background-color: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  display: inline-block;
}

/* Progress Bars */
.progress-container {
  height: 6px; 
  background: #E5E7EB; 
  border-radius: 3px; 
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
}

/* Charts & Analytics */
.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.chart-container {
  height: 200px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 20px;
  gap: 12px;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  gap: 8px;
}

.bar {
  width: 100%;
  background-color: var(--primary-light);
  border-radius: 4px 4px 0 0;
  transition: all 0.3s ease;
  position: relative;
  min-height: 4px;
}

.bar:hover {
  background-color: var(--primary);
  transform: scaleY(1.05);
  transform-origin: bottom;
}

.bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.bar-tooltip {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

.bar:hover .bar-tooltip {
  opacity: 1;
}

.pie-chart-container {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
  justify-content: center;
}

.pie-chart {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(
    var(--status-resolved-text) 0% 65%,
    var(--status-pending-text) 65% 80%,
    var(--status-progress-text) 80% 90%,
    var(--status-rejected-text) 90% 100%
  );
  position: relative;
}

.pie-chart::after {
  content: "";
  position: absolute;
  inset: 50px; /* Creates the donut hole */
  background: var(--bg-card);
  border-radius: 50%;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

@media (max-width: 1024px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Pro Tip Card */
.card-gradient {
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: white;
  border: none;
}

.card-gradient p {
  color: rgba(255, 255, 255, 0.9);
}

.btn-white {
  background: white; 
  color: var(--primary); 
  border: none; 
}

.btn-white:hover {
  background: #F3F4F6;
}

/* Detail View Specifics */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--spacing-lg);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  margin-top: var(--spacing-lg);
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  display: flex;
  gap: var(--spacing-lg);
  position: relative;
}

.timeline-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--primary);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-content {
  background: var(--bg-body);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  flex: 1;
}

.chat-input-area {
  margin-top: var(--spacing-lg);
  display: flex;
  gap: var(--spacing-md);
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none; /* In a real app this would be a drawer */
  }
  .main-content {
    margin-left: 0;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Desktop Optimization (1200px+) */
@media (min-width: 1200px) {
  :root {
    --spacing-lg: 32px; /* Increased spacing */
    --spacing-xl: 40px;
  }

  body {
    font-size: 16px; /* Slightly larger base text */
  }

  /* Layout Adjustments */
  .sidebar {
    width: 300px; /* Wider sidebar */
  }

  .main-content {
    margin-left: 300px;
  }

  .content-area {
    max-width: 1600px; /* Allow wider content */
    padding: 40px;
  }

  /* Typography Scaling */
  h1 { font-size: 32px; }
  h2 { font-size: 26px; }
  h3 { font-size: 20px; }
  
  .stat-value {
    font-size: 36px; /* Impactful numbers */
  }

  .nav-item {
    font-size: 16px;
    padding: 16px 20px; /* More clickable area */
  }

  /* Optimize Detail Grid - Side by Side */
  .detail-grid {
    display: grid;
    grid-template-columns: 3fr 1fr; /* Table gets more space */
    gap: 32px;
    align-items: start;
  }

  /* Override the inline style in HTML that forces full width */
  .detail-grid > .card:first-child {
    grid-column: auto !important; 
  }

  /* Ensure the side panel (performance/pro tip) fills height if needed or stays compact */
  .detail-grid > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 32px;
  }
  
  /* Better table spacing */
  td, th {
    padding: 20px;
  }

  /* Larger Charts */
  .chart-container {
    height: 300px; /* Taller charts */
  }
  
  .pie-chart {
    width: 200px;
    height: 200px;
  }
  
  .pie-chart::after {
    inset: 60px;
  }
}
