// ========================================
// BASE STYLES - Modern UI Foundation
// ========================================

@import './design-tokens';


// CSS Reset & Base Styles
// ========================================

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: $font-primary;
  font-size: $text-base;
  font-weight: $font-normal;
  line-height: $leading-normal;
  color: $gray-900;
  background: linear-gradient(135deg, $gray-50 0%, $gray-100 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

// Typography
// ========================================

h1, h2, h3, h4, h5, h6 {
  font-family: $font-secondary;
  font-weight: $font-semibold;
  line-height: $leading-tight;
  color: $gray-900;
  margin: 0;
}

h1 { font-size: $text-4xl; }
h2 { font-size: $text-3xl; }
h3 { font-size: $text-2xl; }
h4 { font-size: $text-xl; }
h5 { font-size: $text-lg; }
h6 { font-size: $text-base; }

p {
  margin: 0 0 $space-4 0;
  color: $gray-700;
}

a {
  color: $primary-600;
  text-decoration: none;
  transition: color $duration-200 $ease-out;
  
  &:hover {
    color: $primary-700;
  }
  
  &:focus {
    outline: 2px solid $primary-500;
    outline-offset: 2px;
    border-radius: $radius-sm;
  }
}

// Lists
ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

// Images
img {
  max-width: 100%;
  height: auto;
  display: block;
}

// Form Elements
// ========================================

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}

button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  cursor: pointer;
  border: none;
  background: none;
}

// Focus Styles
// ========================================

:focus {
  outline: 2px solid $primary-500;
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid $primary-500;
  outline-offset: 2px;
}

// Selection Styles
// ========================================

::selection {
  background-color: $primary-100;
  color: $primary-900;
}

::-moz-selection {
  background-color: $primary-100;
  color: $primary-900;
}

// Scrollbar Styles
// ========================================

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: $gray-100;
  border-radius: $radius-full;
}

::-webkit-scrollbar-thumb {
  background: $gray-300;
  border-radius: $radius-full;
  transition: background-color $duration-200 $ease-out;
}

::-webkit-scrollbar-thumb:hover {
  background: $gray-400;
}

::-webkit-scrollbar-corner {
  background: $gray-100;
}

// Utility Classes
// ========================================

// Display
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }
.d-none { display: none; }

// Flexbox
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.flex-none { flex: none; }

// Spacing
.m-0 { margin: 0; }
.m-1 { margin: $space-1; }
.m-2 { margin: $space-2; }
.m-3 { margin: $space-3; }
.m-4 { margin: $space-4; }
.m-5 { margin: $space-5; }
.m-6 { margin: $space-6; }
.m-8 { margin: $space-8; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: $space-1; }
.mt-2 { margin-top: $space-2; }
.mt-3 { margin-top: $space-3; }
.mt-4 { margin-top: $space-4; }
.mt-5 { margin-top: $space-5; }
.mt-6 { margin-top: $space-6; }
.mt-8 { margin-top: $space-8; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: $space-1; }
.mb-2 { margin-bottom: $space-2; }
.mb-3 { margin-bottom: $space-3; }
.mb-4 { margin-bottom: $space-4; }
.mb-5 { margin-bottom: $space-5; }
.mb-6 { margin-bottom: $space-6; }
.mb-8 { margin-bottom: $space-8; }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: $space-1; }
.ml-2 { margin-left: $space-2; }
.ml-3 { margin-left: $space-3; }
.ml-4 { margin-left: $space-4; }
.ml-5 { margin-left: $space-5; }
.ml-6 { margin-left: $space-6; }
.ml-8 { margin-left: $space-8; }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: $space-1; }
.mr-2 { margin-right: $space-2; }
.mr-3 { margin-right: $space-3; }
.mr-4 { margin-right: $space-4; }
.mr-5 { margin-right: $space-5; }
.mr-6 { margin-right: $space-6; }
.mr-8 { margin-right: $space-8; }

.p-0 { padding: 0; }
.p-1 { padding: $space-1; }
.p-2 { padding: $space-2; }
.p-3 { padding: $space-3; }
.p-4 { padding: $space-4; }
.p-5 { padding: $space-5; }
.p-6 { padding: $space-6; }
.p-8 { padding: $space-8; }

.pt-0 { padding-top: 0; }
.pt-1 { padding-top: $space-1; }
.pt-2 { padding-top: $space-2; }
.pt-3 { padding-top: $space-3; }
.pt-4 { padding-top: $space-4; }
.pt-5 { padding-top: $space-5; }
.pt-6 { padding-top: $space-6; }
.pt-8 { padding-top: $space-8; }

.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: $space-1; }
.pb-2 { padding-bottom: $space-2; }
.pb-3 { padding-bottom: $space-3; }
.pb-4 { padding-bottom: $space-4; }
.pb-5 { padding-bottom: $space-5; }
.pb-6 { padding-bottom: $space-6; }
.pb-8 { padding-bottom: $space-8; }

.pl-0 { padding-left: 0; }
.pl-1 { padding-left: $space-1; }
.pl-2 { padding-left: $space-2; }
.pl-3 { padding-left: $space-3; }
.pl-4 { padding-left: $space-4; }
.pl-5 { padding-left: $space-5; }
.pl-6 { padding-left: $space-6; }
.pl-8 { padding-left: $space-8; }

.pr-0 { padding-right: 0; }
.pr-1 { padding-right: $space-1; }
.pr-2 { padding-right: $space-2; }
.pr-3 { padding-right: $space-3; }
.pr-4 { padding-right: $space-4; }
.pr-5 { padding-right: $space-5; }
.pr-6 { padding-right: $space-6; }
.pr-8 { padding-right: $space-8; }

// Text
.text-xs { font-size: $text-xs; }
.text-sm { font-size: $text-sm; }
.text-base { font-size: $text-base; }
.text-lg { font-size: $text-lg; }
.text-xl { font-size: $text-xl; }
.text-2xl { font-size: $text-2xl; }
.text-3xl { font-size: $text-3xl; }
.text-4xl { font-size: $text-4xl; }

.font-thin { font-weight: $font-thin; }
.font-light { font-weight: $font-light; }
.font-normal { font-weight: $font-normal; }
.font-medium { font-weight: $font-medium; }
.font-semibold { font-weight: $font-semibold; }
.font-bold { font-weight: $font-bold; }
.font-extrabold { font-weight: $font-extrabold; }
.font-black { font-weight: $font-black; }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.text-primary { color: $primary-600; }
.text-secondary { color: $secondary-600; }
.text-success { color: $success; }
.text-warning { color: $warning; }
.text-error { color: $error; }
.text-gray-500 { color: $gray-500; }
.text-gray-600 { color: $gray-600; }
.text-gray-700 { color: $gray-700; }
.text-gray-900 { color: $gray-900; }

// Border Radius
.rounded-none { border-radius: $radius-none; }
.rounded-sm { border-radius: $radius-sm; }
.rounded { border-radius: $radius-base; }
.rounded-md { border-radius: $radius-md; }
.rounded-lg { border-radius: $radius-lg; }
.rounded-xl { border-radius: $radius-xl; }
.rounded-2xl { border-radius: $radius-2xl; }
.rounded-3xl { border-radius: $radius-3xl; }
.rounded-full { border-radius: $radius-full; }

// Shadows
.shadow-sm { box-shadow: $shadow-sm; }
.shadow { box-shadow: $shadow-base; }
.shadow-md { box-shadow: $shadow-md; }
.shadow-lg { box-shadow: $shadow-lg; }
.shadow-xl { box-shadow: $shadow-xl; }
.shadow-2xl { box-shadow: $shadow-2xl; }
.shadow-inner { box-shadow: $shadow-inner; }

// Transitions
.transition { transition: all $duration-200 $ease-out; }
.transition-fast { transition: all $duration-150 $ease-out; }
.transition-slow { transition: all $duration-300 $ease-out; }

// Responsive Utilities
// ========================================

@media (max-width: $breakpoint-sm) {
  .sm\:hidden { display: none; }
  .sm\:block { display: block; }
  .sm\:flex { display: flex; }
  .sm\:text-sm { font-size: $text-sm; }
  .sm\:text-base { font-size: $text-base; }
  .sm\:p-2 { padding: $space-2; }
  .sm\:p-4 { padding: $space-4; }
}

@media (max-width: $breakpoint-md) {
  .md\:hidden { display: none; }
  .md\:block { display: block; }
  .md\:flex { display: flex; }
  .md\:text-sm { font-size: $text-sm; }
  .md\:text-base { font-size: $text-base; }
  .md\:p-2 { padding: $space-2; }
  .md\:p-4 { padding: $space-4; }
}

@media (max-width: $breakpoint-lg) {
  .lg\:hidden { display: none; }
  .lg\:block { display: block; }
  .lg\:flex { display: flex; }
  .lg\:text-sm { font-size: $text-sm; }
  .lg\:text-base { font-size: $text-base; }
  .lg\:p-2 { padding: $space-2; }
  .lg\:p-4 { padding: $space-4; }
}

// Accessibility
// ========================================

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

// Reduced Motion
@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;
  }
}
