/**
 * 基础样式 - Base Styles
 * 重置和基本元素样式
 */

/* ==========================================
   CSS Reset / Normalize
   ========================================== */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: var(--leading-relaxed);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body,
.navbar,
.navbar-mobile,
.dropdown-menu,
.modal,
.card,
.card-footer,
.btn,
.nav-link,
.dropdown-item,
.form-input,
.form-textarea,
.form-select,
th,
td,
pre,
code,
blockquote {
    transition:
        background-color var(--transition-base),
        color var(--transition-base),
        border-color var(--transition-base),
        box-shadow var(--transition-base);
}

/* ==========================================
   Typography
   ========================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--color-text);
    margin-bottom: var(--space-4);
}

h1 {
    font-size: var(--text-4xl);
    letter-spacing: -0.02em;
}

h2 {
    font-size: var(--text-3xl);
    letter-spacing: -0.01em;
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
}

h5 {
    font-size: var(--text-lg);
}

h6 {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
}

p {
    margin-bottom: var(--space-4);
    color: var(--color-text);
}

.lead {
    font-size: var(--text-lg);
    line-height: var(--leading-loose);
    color: var(--color-text-secondary);
}

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

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

/* ==========================================
   Links
   ========================================== */

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--color-accent-hover);
}

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

/* ==========================================
   Lists
   ========================================== */

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

li {
    margin-bottom: var(--space-2);
}

li::marker {
    color: var(--color-primary);
}

/* ==========================================
   Images
   ========================================== */

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

figure {
    margin: var(--space-8) 0;
}

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

/* ==========================================
   Code
   ========================================== */

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background-color: var(--color-bg-subtle);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--color-primary-dark);
}

pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background-color: var(--color-bg-subtle);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin-bottom: var(--space-4);
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

/* ==========================================
   Blockquote
   ========================================== */

blockquote {
    border-left: 4px solid var(--color-primary);
    background-color: var(--color-bg-subtle);
    padding: var(--space-4) var(--space-6);
    margin: var(--space-6) 0;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    font-style: italic;
    color: var(--color-text-secondary);
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ==========================================
   Horizontal Rule
   ========================================== */

hr {
    border: none;
    border-top: 1px solid var(--color-bg-muted);
    margin: var(--space-8) 0;
}

/* ==========================================
   Tables
   ========================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-6);
    font-size: var(--text-sm);
}

th, td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-bg-muted);
}

th {
    font-family: var(--font-heading);
    font-weight: var(--font-semibold);
    background-color: var(--color-bg-subtle);
}

tr:hover td {
    background-color: var(--color-bg-subtle);
}

/* ==========================================
   Forms - Basic
   ========================================== */

input,
textarea,
select {
    font-family: inherit;
    font-size: var(--text-base);
}

/* ==========================================
   Selection
   ========================================== */

::selection {
    background-color: var(--color-selection-bg);
    color: var(--color-text);
}

/* ==========================================
   Focus States
   ========================================== */

:focus {
    outline: none;
}

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

/* ==========================================
   Scrollbar Styling (WebKit)
   ========================================== */

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

::-webkit-scrollbar-track {
    background: var(--color-bg-subtle);
}

::-webkit-scrollbar-thumb {
    background: var(--color-bg-muted);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

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

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text colors */
.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

/* Background colors */
.bg-primary { background-color: var(--color-primary); }
.bg-subtle { background-color: var(--color-bg-subtle); }
.bg-muted { background-color: var(--color-bg-muted); }

/* Font weights */
.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

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

/* Flexbox utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Spacing - Margin */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }
.my-8 { margin-top: var(--space-8); margin-bottom: var(--space-8); }

/* Spacing - Padding */
.p-0 { padding: 0; }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.py-12 { padding-top: var(--space-12); padding-bottom: var(--space-12); }
.py-16 { padding-top: var(--space-16); padding-bottom: var(--space-16); }

/* Width/Height */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Border radius */
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadows */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

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