/* ============================================
   BidIQ Main CSS File
   Import all CSS modules in the correct order
   ============================================ */

/* 1. CSS Variables & Design System */
@import url('variables.css');

/* 2. Base Styles & CSS Reset */
@import url('reset.css');
@import url('base.css');

/* 3. Layout Components */
@import url('layout.css');

/* 4. UI Components */
@import url('components.css');
@import url('modals.css');

/* 5. Animations */
@import url('animations.css');

/* 6. Responsive Design */
@import url('responsive.css');

/* 7. Page-specific Styles (if needed) */
/* @import url('pages/dashboard.css'); */
/* @import url('pages/projects.css'); */
/* @import url('pages/quotes.css'); */

/* ============================================
   Global Application Styles
   ============================================ */

/* Ensure smooth theme transitions */
* {
  transition-property: background-color, border-color, color;
  transition-duration: 0ms;
}

/* When theme is changing */
html[data-theme-transitioning] * {
  transition-duration: 300ms !important;
}

/* Dashboard Layout Grid */
.dashboard-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--navbar-height) 1fr;
  grid-template-areas: 
    "sidebar navbar"
    "sidebar main";
  min-height: 100vh;
}

.dashboard-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-normal);
}

/* Navbar */
.navbar {
  grid-area: navbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--navbar-height);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
}

/* Main Content Area */
.main-content {
  grid-area: main;
  background: var(--background);
  min-height: calc(100vh - var(--navbar-height));
  padding: var(--space-6);
  overflow-x: hidden;
}

/* ============================================
   Utility Overrides
   ============================================ */

/* Focus styles for better accessibility */
:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Prevent text selection on UI elements */
.btn,
.nav-link,
.sidebar-link,
.tab {
  user-select: none;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  /* Hide UI elements when printing */
  .sidebar,
  .navbar,
  .no-print,
  .btn-group,
  .dropdown,
  .modal {
    display: none !important;
  }
  
  /* Adjust main content for print */
  .main-content {
    padding: 0;
    margin: 0;
  }
  
  /* Reset colors for print */
  * {
    color: black !important;
    background: white !important;
  }
  
  /* Show URLs for links */
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* ============================================
   Custom Scrollbar Styles
   ============================================ */

/* Webkit browsers */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: var(--radius-lg);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: var(--radius-lg);
  border: 2px solid var(--gray-100);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-400) var(--gray-100);
}

/* ============================================
   Loading States
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--gray-200) 25%,
    var(--gray-100) 50%,
    var(--gray-200) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* ============================================
   Accessibility Improvements
   ============================================ */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-500);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  text-decoration: none;
  z-index: var(--z-tooltip);
}

.skip-link:focus {
  top: var(--space-2);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  * {
    border-width: 2px !important;
  }
  
  .btn {
    border: 2px solid currentColor !important;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   Custom BidIQ Styles
   ============================================ */

/* Dashboard Stats Cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-normal);
}

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

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
}

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.stat-card-trend.positive {
  color: var(--success-600);
}

.stat-card-trend.negative {
  color: var(--danger-600);
}

/* Project Cards */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.project-card:hover {
  border-color: var(--primary-200);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.project-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.project-card-client {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.project-card-meta {
  display: flex;
  gap: var(--space-6);
  margin-bottom: var(--space-4);
}

.project-card-meta-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.project-card-meta-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.project-card-meta-value {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.project-card-progress {
  margin-top: var(--space-4);
}

.project-card-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* Quote Builder Styles */
.quote-builder {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: var(--space-6);
  height: calc(100vh - var(--navbar-height) - var(--space-12));
}

.quote-builder-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.quote-builder-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  overflow-y: auto;
}

.quote-line-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.quote-line-item:hover {
  background: var(--gray-50);
}

/* AI Assistant Chat */
.ai-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.ai-message {
  display: flex;
  gap: var(--space-3);
  max-width: 70%;
}

.ai-message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.ai-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-500);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.ai-message.assistant .ai-message-avatar {
  background: var(--info-500);
}

.ai-message-content {
  background: var(--gray-100);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.ai-message.user .ai-message-content {
  background: var(--primary-500);
  color: white;
}

.ai-chat-input {
  border-top: 1px solid var(--border);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
}

/* ============================================
   Dark Mode Specific Styles
   ============================================ */

[data-theme="dark"] {
  /* Adjust component colors for dark mode */
  .stat-card-icon {
    background: var(--gray-800);
  }
  
  .skeleton {
    background: linear-gradient(
      90deg,
      var(--gray-700) 25%,
      var(--gray-600) 50%,
      var(--gray-700) 75%
    );
  }
  
  /* Code blocks in dark mode */
  code {
    background: var(--gray-800);
    color: var(--primary-300);
  }
  
  /* Adjust shadows for dark mode */
  .card-hover:hover,
  .project-card:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }
}

/* ============================================
   End of Main CSS
   ============================================ */