// ========================================
// Global Reset & Base Styles
// ========================================

@use './variables' as *;

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

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

body {
  font-family: $font-family-body;
  font-size: $font-size-base;
  line-height: $line-height-normal;
  color: $fg-primary;
  background-color: $bg-secondary;
  transition: background-color $transition-base;
}

// ========================================
// Typography Elements
// ========================================

h1, h2, h3, h4, h5, h6 {
  font-family: $font-family-heading;
  font-weight: $font-weight-bold;
  line-height: $line-height-tight;
  margin-bottom: $space-4;
}

h1 {
  font-size: $font-size-5xl;
}

h2 {
  font-size: $font-size-4xl;
}

h3 {
  font-size: $font-size-3xl;
}

h4 {
  font-size: $font-size-2xl;
}

h5 {
  font-size: $font-size-xl;
}

h6 {
  font-size: $font-size-lg;
}

p {
  margin-bottom: $space-4;

  &:last-child {
    margin-bottom: 0;
  }
}

a {
  color: $color-primary;
  text-decoration: none;
  transition: color $transition-base;

  &:hover {
    color: $color-primary-dark;
    text-decoration: underline;
  }

  &:focus-visible {
    outline: 2px solid $color-primary;
    outline-offset: 2px;
    border-radius: $radius-sm;
  }
}

strong, b {
  font-weight: $font-weight-bold;
}

em, i {
  font-style: italic;
}

code {
  font-family: $font-family-mono;
  font-size: 0.9em;
  background-color: $color-neutral-100;
  padding: $space-1 $space-2;
  border-radius: $radius-sm;
  color: $color-error;
}

pre {
  font-family: $font-family-mono;
  font-size: $font-size-sm;
  background-color: $color-neutral-900;
  color: #ffffff;
  padding: $space-4;
  border-radius: $radius-lg;
  overflow-x: auto;
  margin-bottom: $space-4;

  code {
    background-color: transparent;
    color: inherit;
    padding: 0;
  }
}

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

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='search'],
textarea,
select {
  width: 100%;
  padding: $space-2 $space-3;
  border-radius: $radius-md;
  border: 1px solid $color-neutral-300;
  background-color: $bg-primary;
  transition: all $transition-base;

  &:focus {
    outline: none;
    border-color: $color-primary;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
  }

  &:disabled {
    background-color: $color-neutral-100;
    cursor: not-allowed;
    opacity: 0.6;
  }

  &::placeholder {
    color: $fg-tertiary;
  }
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: $radius-md;
  padding: $space-2 $space-4;
  font-weight: $font-weight-medium;
  transition: all $transition-base;

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

  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
}

// ========================================
// List Elements
// ========================================

ul, ol {
  margin-bottom: $space-4;
  padding-left: $space-8;

  li {
    margin-bottom: $space-2;
  }

  &:last-child {
    margin-bottom: 0;
  }
}

dl {
  margin-bottom: $space-4;

  dt {
    font-weight: $font-weight-semibold;
    margin-bottom: $space-1;
  }

  dd {
    margin-bottom: $space-4;
    margin-left: $space-4;
  }
}

// ========================================
// Table Elements
// ========================================

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: $space-4;

  th {
    background-color: $color-neutral-100;
    padding: $space-3;
    text-align: left;
    font-weight: $font-weight-semibold;
    border-bottom: 2px solid $color-neutral-300;
  }

  td {
    padding: $space-3;
    border-bottom: 1px solid $color-neutral-200;
  }

  tr:hover {
    background-color: $bg-secondary;
  }
}

// ========================================
// Image & Media
// ========================================

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

svg {
  max-width: 100%;
  height: auto;
}

// ========================================
// Scrollbar Styling
// ========================================

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

::-webkit-scrollbar-track {
  background-color: $color-neutral-100;
}

::-webkit-scrollbar-thumb {
  background-color: $color-neutral-400;
  border-radius: $radius-full;

  &:hover {
    background-color: $color-neutral-500;
  }
}

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

::selection {
  background-color: $color-primary;
  color: #ffffff;
}

::-moz-selection {
  background-color: $color-primary;
  color: #ffffff;
}
