/* ============================================
   AutoTechPro.Ai Global Styles
   Pure CSS with Light/Dark Theme System
   ============================================ */

/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */
:root {
  /* Light Theme Colors */
  --color-bg: #ffffff;
  --color-bg-secondary: #f5f5f5;
  --color-bg-elevated: #ffffff;
  --color-text: #000000;
  --color-text-secondary: #666666;
  --color-text-tertiary: #999999;
  --color-border: #e0e0e0;
  --color-border-hover: #cccccc;

  /* Accent Colors (minimal use) */
  --color-accent: #000000;
  --color-accent-hover: #333333;
  --color-focus: #0066cc;

  /* Semantic Colors */
  --color-success: #00cc00;
  --color-warning: #ff9900;
  --color-error: #cc0000;
  --color-info: #0099cc;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --font-family-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono",
    Consolas, "Courier New", monospace;

  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
  --font-size-5xl: 3rem;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-fixed: 1200;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-popover: 1500;
  --z-tooltip: 1600;

  /* Layout */
  --container-max-width: 1280px;
  --header-height: 64px;
}

/* Dark Theme */
[data-theme="dark"] {
  --color-bg: #000000;
  --color-bg-secondary: #1a1a1a;
  --color-bg-elevated: #2a2a2a;
  --color-text: #ffffff;
  --color-text-secondary: #b0b0b0;
  --color-text-tertiary: #808080;
  --color-border: #333333;
  --color-border-hover: #4d4d4d;

  --color-accent: #ffffff;
  --color-accent-hover: #e0e0e0;

  --shadow-sm: 0 1px 2px rgba(255, 255, 255, 0.05);
  --shadow-md: 0 4px 6px rgba(255, 255, 255, 0.1);
  --shadow-lg: 0 10px 15px rgba(255, 255, 255, 0.1);
  --shadow-xl: 0 20px 25px rgba(255, 255, 255, 0.15);
}

/* ============================================
   Base Reset & Typography
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-base),
    color var(--transition-base);
  min-height: 100vh;
}

/* ============================================
   Typography
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: var(--font-size-5xl);
}
h2 {
  font-size: var(--font-size-4xl);
}
h3 {
  font-size: var(--font-size-3xl);
}
h4 {
  font-size: var(--font-size-2xl);
}
h5 {
  font-size: var(--font-size-xl);
}
h6 {
  font-size: var(--font-size-lg);
}

p {
  margin-bottom: var(--space-md);
}

a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

a:hover {
  opacity: 0.8;
}

a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================
   Layout Components
   ============================================ */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

@media (max-width: 768px) {
  .container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

/* ============================================
   Navigation
   ============================================ */
.main-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: var(--space-lg);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.logo svg {
  flex-shrink: 0;
}

/* .accent class moved to accessibility section with purple color */

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex: 1;
  justify-content: center;
}

.nav-link {
  position: relative;
  padding: var(--space-sm) var(--space-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-text);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--space-md);
  right: var(--space-md);
  height: 2px;
  background-color: var(--color-text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  color: var(--color-text);
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background-color: currentColor;
  position: relative;
  transition: background-color var(--transition-fast);
}

.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  left: 0;
  transition: transform var(--transition-base);
}

.hamburger::before {
  top: -8px;
}

.hamburger::after {
  bottom: -8px;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md);
    gap: var(--space-sm);
    display: none;
  }

  .nav-links.active {
    display: flex;
  }

  .nav-link {
    width: 100%;
    text-align: center;
  }
}

/* ============================================
   Theme Toggle
   ============================================ */
.theme-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast),
    background-color var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--color-border-hover);
  background-color: var(--color-bg-secondary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.theme-toggle svg {
  position: absolute;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sun-icon {
  opacity: 1;
  transform: rotate(0deg);
}

.moon-icon {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="dark"] .sun-icon {
  opacity: 0;
  transform: rotate(-90deg);
}

[data-theme="dark"] .moon-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: var(--shadow-sm);
  /* Removed transform for uniformity */
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

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

.btn-ghost {
  background-color: transparent;
  color: var(--color-text);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--color-bg-secondary);
}

.btn-sm {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-sm);
}

.btn-block {
  display: flex;
  width: 100%;
}

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

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Dark mode button overrides */
[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border: none;
}

[data-theme="dark"] .btn-primary:hover {
  background: linear-gradient(135deg, #7c8ef0 0%, #8b5cb8 100%);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================
   Forms
   ============================================ */
input,
textarea,
select {
  width: 100%;
  padding: var(--space-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--color-border-hover);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-tertiary);
}

/* ============================================
   Cards
   ============================================ */
.card {
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
}

/* ============================================
   Utility Classes
   ============================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.gradient-text {
  background: linear-gradient(
    135deg,
    var(--color-text) 0%,
    var(--color-text-secondary) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block; /* Prevent clipping issues */
  padding-bottom: 0.1em; /* Extra space for descenders */
}

/* ============================================
   Section Styles
   ============================================ */
.section-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  text-align: center;
  margin-bottom: var(--space-xl);
}

.section-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: var(--space-2xl);
}

/* ============================================
   Authentication UI
   ============================================ */
.auth-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.btn-sm {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-sm);
}

/* ============================================
   Enhanced User Menu
   ============================================ */
.user-menu {
  position: relative;
}

.user-button {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.user-button:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.user-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.user-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  border: 2px solid var(--color-bg-elevated);
  object-fit: cover;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.premium-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.premium-badge svg {
  width: 10px;
  height: 10px;
  color: white;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-error);
  color: white;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-bg);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.user-dropdown {
  position: absolute;
  top: calc(100% + var(--space-sm));
  right: 0;
  min-width: 280px;
  max-width: 320px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.user-dropdown:not(.hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: all;
}

.user-dropdown.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  pointer-events: none;
}

.user-dropdown-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-dropdown-header .user-avatar {
  width: 48px;
  height: 48px;
}

.user-dropdown-info {
  flex: 1;
  min-width: 0;
}

.user-dropdown-name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-email {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.stat-item {
  text-align: center;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
}

.stat-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  display: block;
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
  display: block;
}

.dropdown-section {
  padding: var(--space-xs) 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  position: relative;
}

.dropdown-item:hover {
  background: var(--color-bg-secondary);
  color: var(--color-primary);
}

.dropdown-item:focus-visible {
  background: var(--color-bg-secondary);
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.dropdown-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.dropdown-item:hover svg {
  opacity: 1;
}

.dropdown-item-badge {
  margin-left: auto;
  background: var(--color-error);
  color: white;
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropdown-item.danger {
  color: var(--color-error);
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

@media (max-width: 768px) {
  .user-dropdown {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    min-width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
  }
  
  .user-dropdown:not(.hidden) {
    transform: translateX(-50%) translateY(0);
  }
  
  .user-info {
    display: none;
  }
}

/* ============================================
   Responsive Typography
   ============================================ */
@media (max-width: 768px) {
  :root {
    --font-size-5xl: 2rem;
    --font-size-4xl: 1.75rem;
    --font-size-3xl: 1.5rem;
    --font-size-2xl: 1.25rem;
  }
}

/* ============================================
   Accessibility
   ============================================ */
/* Utility class for hiding elements */
.hidden {
  display: none !important;
}

/* ============================================
   Brand Accent Color - Pale Purple for .Ai
   ============================================ */
.accent {
  color: #8b7fc7 !important; /* Pale purple/lavender */
  font-weight: var(--font-weight-semibold);
}

/* Dark theme adjustment */
[data-theme="dark"] .accent {
  color: #a89fd9 !important; /* Lighter lavender for dark mode */
}

@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;
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  pre {
    white-space: pre-wrap !important;
  }

  .main-nav,
  .main-footer,
  .theme-toggle,
  .mobile-menu-toggle {
    display: none;
  }
}
