/* Base element styles */

/* Typography */
h1 {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-3);
}

h4 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-2);
}

h5 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-2);
}

h6 {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-2);
}

p {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast) var(--ease-in-out);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

strong, b {
  font-weight: var(--font-semibold);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
}

/* Lists */
ul, ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

ul li, ol li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-relaxed);
}

ul:not([role='list']) {
  list-style-type: disc;
}

ol:not([role='list']) {
  list-style-type: decimal;
}

/* Code */
code {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
}

pre {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

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

/* Forms */
label {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

input, textarea, select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast) var(--ease-in-out);
}

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

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

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: var(--leading-relaxed);
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 20px;
  padding-right: var(--space-10);
}

/* Checkbox and Radio */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  width: 18px;
  height: 18px;
  margin-right: var(--space-2);
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  background-color: var(--bg-primary);
  border: 2px solid var(--border);
  transition: all var(--transition-fast) var(--ease-in-out);
}

input[type="checkbox"] {
  border-radius: var(--radius-sm);
}

input[type="radio"] {
  border-radius: var(--radius-full);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}

input[type="radio"]:checked {
  background-image: radial-gradient(circle, white 30%, transparent 30%);
}

/* Tables */
table {
  width: 100%;
  margin-bottom: var(--space-4);
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

thead {
  background-color: var(--bg-secondary);
}

th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-align: left;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
  background-color: var(--bg-secondary);
}

/* Definition List */
dl {
  margin-bottom: var(--space-4);
}

dt {
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
}

dd {
  margin-left: var(--space-6);
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
}

/* Fieldset and Legend */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

legend {
  padding: 0 var(--space-2);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Figure and Figcaption */
figure {
  margin-bottom: var(--space-4);
}

figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
}

/* Abbr */
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* Details and Summary */
details {
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

summary {
  cursor: pointer;
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
}

details[open] summary {
  margin-bottom: var(--space-3);
}

/* Address */
address {
  font-style: normal;
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}