/* ============================================
   Aurora Toolbox - Unified Design System v2.0
   统一设计规范 · 共享组件库 · 响应式系统
   ============================================ */

/* --- Design Tokens (设计令牌) --- */
:root {
    /* Brand Colors */
    --primary: #00d4ff;
    --primary-rgb: 0, 212, 255;
    --primary-light: rgba(0, 212, 255, 0.15);
    --primary-dark: #0099cc;
    --secondary: #7c3aed;
    --secondary-rgb: 124, 58, 237;
    
    /* Semantic Colors */
    --success: #10b981;
    --success-rgb: 16, 185, 129;
    --success-light: rgba(16, 185, 129, 0.12);
    --warn: #f59e0b;
    --warn-rgb: 245, 158, 11;
    --warn-light: rgba(245, 158, 11, 0.12);
    --error: #ef4444;
    --error-rgb: 239, 68, 68;
    --error-light: rgba(239, 68, 68, 0.12);
    --info: #38bdf8;
    
    /* Neutral Colors */
    --bg: #0a0a0f;
    --bg-rgb: 10, 10, 15;
    --bg-card: #111118;
    --bg-card-rgb: 17, 17, 24;
    --bg-elevated: #16161f;
    --text: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.35);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    
    /* Code/Text Colors (for syntax highlighting) */
    --code-keyword: #c084fc;
    --code-string: #a5f3c4;
    --code-number: #93c5fd;
    --code-comment: #64748b;
    --code-function: #60a5fa;
    --code-tag: #f472b6;
    --code-attr: #fcd34d;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--secondary));
    --gradient-success: linear-gradient(135deg, var(--success), #059669);
    --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-cool: linear-gradient(135deg, var(--primary), #06b6d4);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow-primary: 0 0 24px rgba(var(--primary-rgb), 0.3);
    --shadow-glow-success: 0 0 20px rgba(var(--success-rgb), 0.3);
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
    --font-size-xs: 0.72rem;     /* 11.5px */
    --font-size-sm: 0.82rem;     /* 13px */
    --font-size-base: 0.92rem;   /* 14.7px */
    --font-size-md: 1rem;       /* 16px */
    --font-size-lg: 1.15rem;     /* 18.4px */
    --font-size-xl: 1.35rem;     /* 21.6px */
    --font-size-2xl: 1.75rem;   /* 28px */
    --line-height-tight: 1.45;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.75;
    
    /* Spacing Scale */
    --space-xs: 0.25rem;     /* 4px */
    --space-sm: 0.5rem;      /* 8px */
    --space-md: 0.75rem;     /* 12px */
    --space-lg: 1rem;        /* 16px */
    --space-xl: 1.5rem;      /* 24px */
    --space-2xl: 2rem;      /* 32px */
    --space-3xl: 3rem;      /* 48px */
    
    /* Border Radius */
    --radius-sm: 0.375rem;    /* 6px */
    --radius-md: 0.5rem;      /* 8px */
    --radius-lg: 0.75rem;     /* 12px */
    --radius-xl: 1rem;       /* 16px */
    --radius-2xl: 1.5rem;    /* 24px */
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Z-index Scale */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 300;
    --z-modal: 500;
    --z-toast: 9999;
}

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

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: var(--line-height-normal);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: env(safe-area-inset-top) var(--space-lg) env(safe-area-inset-bottom);
}

img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-light); }

/* --- Typography System --- */
h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight);
    font-weight: 700;
    letter-spacing: -0.02em;
}
h1 { font-size: var(--font-size-2xl); margin-bottom: var(--space-sm); }
h2 { font-size: var(--font-size-xl); margin-bottom: var(--space-md); }
h3 { font-size: var(--font-size-lg); margin-bottom: var(--space-sm); }

.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.text-error { color: var(--error); }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }

/* --- Layout Utilities --- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--space-lg); }
.container-fluid { width: 100%; padding: 0 var(--space-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.grid { display: grid; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* --- Component: Card --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: rgba(0, 0, 0, 0.18);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--primary);
    font-size: var(--font-size-base);
}
.card-body { padding: var(--space-lg); }
.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* --- Component: Button System --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-primary);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-sm);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-success);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm { padding: var(--space-xs) var(--space-md); font-size: var(--font-size-xs); }
.btn-lg { padding: var(--space-md) var(--space-xl); font-size: var(--font-size-base); }
.btn-block { width: 100%; }
.btn-icon { padding: var(--space-sm); aspect-ratio: 1; border-radius: var(--radius-md); }

/* --- Component: Input/Form Elements --- */
.input-group { display: flex; flex-direction: column; gap: var(--space-xs); }
.input-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}
.input-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
select,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: var(--font-size-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}
textarea { resize: vertical; min-height: 80px; line-height: var(--line-height-normal); }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.65rem center; background-size: 1em; padding-right: 2em; }

input[type="color"] {
    padding: 2px;
    height: 36px;
    cursor: pointer;
    accent-color: var(--primary);
}
input[type="range"] {
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
}
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* --- Component: Badge/Tag --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}
.badge-primary { background: rgba(var(--primary-rgb), 0.15); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warn { background: var(--warn-light); color: var(--warn); }
.badge-error { background: var(--error-light); color: var(--error); }

/* --- Component: Tabs --- */
.tabs { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.tab {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

/* --- Component: Toast Notification --- */
.toast-container {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - var(--space-2xl));
}

.toast {
    position: relative;
    padding: var(--space-sm) var(--space-xl);
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: var(--font-size-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: toastIn 0.35s ease forwards;
    pointer-events: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.toast.toast-success { background: rgba(16, 185, 129, 0.95); color: white; }
.toast.toast-error { background: rgba(239, 68, 68, 0.95); color: white; }
.toast.toast-info { background: rgba(56, 189, 248, 0.95); color: white; }
.toast.toast-warn { background: rgba(245, 158, 11, 0.95); color: white; }
.toast-exit {
    cursor: pointer;
    opacity: 0.6;
    font-size: 1.1em;
    padding: 0 0.2rem;
    margin-left: var(--space-sm);
}
.toast-exit:hover { opacity: 1; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* --- Component: Loading Spinner --- */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
.spinner-lg { width: 48px; height: 48px; border-width: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-dots { display: flex; gap: var(--space-sm); justify-content: center; }
.loading-dots span {
    width: 8px; height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotPulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 37%,
        rgba(255, 255, 255, 0.04) 63%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Component: Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-secondary);
}
.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
    opacity: 0.35;
}
.empty-title { font-size: var(--font-size-lg); margin-bottom: var(--space-sm); color: var(--text); }
.empty-desc { font-size: var(--font-size-sm); opacity: 0.7; }

/* --- Component: Code Block / Preformatted --- */
.code-block {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    overflow-x: auto;
    tab-size: 2;
    white-space: pre;
}
.code-inline {
    background: rgba(0, 212, 255, 0.08);
    color: var(--primary);
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.88em;
}

/* --- Utility Classes --- */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }

/* --- Responsive Breakpoints --- */

/* Tablet & below */
@media (max-width: 1024px) {
    :root { --container-max: 960px; }
    .hide-tablet { display: none !important; }
}

/* Mobile landscape */
@media (max-width: 768px) {
    body { padding: var(--space-sm); }
    :root { --container-max: 100%; }
    .hide-mobile { display: none !important; }
    h1 { font-size: var(--font-size-xl); }
    .card-header { padding: var(--space-sm) var(--space-md); }
    .card-body { padding: var(--space-md); }
    .btn { padding: var(--space-sm) var(--space-md); }
    .tabs { gap: var(--space-xs); }
    .tab { padding: var(--space-xs) var(--space-md); font-size: var(--font-size-xs); }
}

/* Mobile portrait */
@media (max-width: 480px) {
    body { padding: var(--space-xs); }
    h1 { font-size: var(--font-size-lg); }
    .btn { width: 100%; }
    .flex-mobile-col { flex-direction: column; }
    .grid-mobile-1 { grid-template-columns: 1fr !important; }
    .grid-mobile-2 { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    body { background: white; color: black; }
    .no-print { display: none !important; }
    .card { break-inside: avoid; border: 1px solid #ddd; }
}