/**
 * 天偌装修平台 - 统一设计系统 v2.0
 * Complete design tokens, reusable components, and utility classes
 */

/* =============================================
   CSS Custom Properties (Design Tokens)
   ============================================= */
:root {
  /* ----- Brand ----- */
  --primary: #e07b39;
  --primary-dark: #c96a2d;
  --primary-light: #ff9a56;
  --primary-bg: #fff5f0;

  /* ----- Surfaces ----- */
  --dark: #1a1a2e;
  --dark-secondary: #16213e;
  --dark-tertiary: #0f3460;
  --white: #ffffff;
  --bg-page: #f6f6f8;
  --bg-card: #ffffff;
  --bg-hover: #fafafa;

  /* ----- Text ----- */
  --text: #2d2a26;
  --text-secondary: #5e5a55;
  --text-muted: #9e9a95;
  --text-inverse: #ffffff;

  /* ----- Border ----- */
  --border: #e8e6e3;
  --border-light: #f0efed;
  --border-focus: var(--primary);

  /* ----- Semantic ----- */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --gold: #f59e0b;
  --gold-light: #fbbf24;

  /* ----- Spacing ----- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* ----- Border Radius ----- */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* ----- Shadows ----- */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.07), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);

  /* ----- Transitions ----- */
  --transition-fast: .15s ease;
  --transition: .25s ease;
  --transition-slow: .4s ease;

  /* ----- Layout ----- */
  --container-max: 1200px;
  --navbar-height: 64px;

  /* ----- Typography ----- */
  --font-sans: 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* =============================================
   Layout
   ============================================= */
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 800px; margin: 0 auto; padding: 0 20px; }

.section { padding: var(--space-3xl) 0; }
.section-sm { padding: var(--space-2xl) 0; }

/* =============================================
   Typography
   ============================================= */
h1, h2, h3, h4, h5, h6 { line-height: 1.3; color: var(--text); }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }

.section-title {
  text-align: center;
  margin-bottom: var(--space-xl);
}
.section-title h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: var(--space-sm);
}
.section-title h2 span { color: var(--primary); }
.section-title p {
  font-size: .95rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
}

.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-center { text-align: center; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* =============================================
   Buttons
   ============================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); font-size: .9rem;
  font-weight: 600; cursor: pointer; border: none; transition: var(--transition-fast);
  text-decoration: none; white-space: nowrap; line-height: 1;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white); box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-secondary {
  background: var(--bg-page); color: var(--text-secondary); border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

.btn-outline {
  border: 2px solid var(--primary); color: var(--primary); background: transparent;
}
.btn-outline:hover { background: var(--primary-bg); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--primary); background: var(--primary-bg); }

.btn-danger {
  background: var(--danger); color: var(--white);
}
.btn-danger:hover { background: #dc2626; }

.btn-success {
  background: var(--success); color: var(--white);
}
.btn-success:hover { background: #059669; }

.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* =============================================
   Cards
   ============================================= */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-body { padding: var(--space-lg); }
.card-header { padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-light); font-weight: 600; }
.card-footer { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border-light); }

/* =============================================
   Badges & Tags
   ============================================= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full); font-size: .75rem;
  font-weight: 600; white-space: nowrap;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gold { background: #fefce8; color: var(--gold); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: .75rem; background: var(--bg-page); color: var(--text-secondary);
  margin: 2px;
}

/* =============================================
   Stats
   ============================================= */
.stat-card {
  text-align: center; padding: var(--space-lg);
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* =============================================
   Forms
   ============================================= */
.form-group { margin-bottom: var(--space-md); }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .9rem; outline: none;
  background: var(--white); transition: var(--transition-fast);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224,123,57,.1); }
.form-control::placeholder { color: var(--text-muted); }
.form-control.error { border-color: var(--danger); }
textarea.form-control { min-height: 100px; resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239e9a95' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  padding-right: 40px;
}

.input-group {
  display: flex; border-radius: var(--radius); overflow: hidden; border: 1.5px solid var(--border);
}
.input-group:focus-within { border-color: var(--primary); }
.input-group .form-control { border: none; border-radius: 0; }
.input-group .btn { border-radius: 0; }

/* =============================================
   Toast / Alert
   ============================================= */
.alert {
  padding: 12px 16px; border-radius: var(--radius); font-size: .875rem;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }

.toast {
  position: fixed; top: 80px; right: 20px; z-index: 9999;
  padding: 14px 20px; border-radius: var(--radius); color: var(--white);
  font-size: .9rem; font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .3s ease;
  max-width: 380px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: var(--text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* =============================================
   Modal
   ============================================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--white); border-radius: var(--radius-xl); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-xl); animation: modalIn .3s ease; overflow: hidden;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  background: none; border: none; font-size: 1.2rem; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-page); }
.modal-body { padding: 24px; max-height: 60vh; overflow-y: auto; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 10px;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* =============================================
   Page Hero
   ============================================= */
.page-hero {
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-secondary) 50%, var(--dark-tertiary) 100%);
  padding: var(--space-3xl) 0; text-align: center; color: var(--white);
  position: relative; overflow: hidden;
}
.page-hero::after {
  content: ''; position: absolute; bottom: -40px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
}
.page-hero h1 { font-size: 2.2rem; font-weight: 800; color: var(--white); margin-bottom: var(--space-sm); }
.page-hero h1 span { color: var(--primary-light); }
.page-hero p { font-size: 1rem; opacity: .75; max-width: 500px; margin: 0 auto; }

/* =============================================
   Navbar
   ============================================= */
.navbar {
  background: var(--white); box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 100; height: var(--navbar-height);
}
.navbar .container {
  display: flex; align-items: center; height: 100%;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px; font-weight: 800;
  font-size: 1.15rem; color: var(--primary);
}
.navbar-brand .brand-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 1.1rem;
}
.navbar-nav {
  display: flex; align-items: center; gap: 4px; margin-left: auto;
}
.navbar-nav a {
  padding: 8px 16px; border-radius: var(--radius); font-size: .9rem;
  font-weight: 500; color: var(--text-secondary); transition: var(--transition-fast);
}
.navbar-nav a:hover, .navbar-nav a.active {
  color: var(--primary); background: var(--primary-bg);
}
.navbar-nav a.nav-cta {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white); font-weight: 600; margin-left: var(--space-sm);
}
.navbar-nav a.nav-cta:hover { opacity: .9; background: var(--primary-dark); }
.navbar .nav-toggle { display: none; }

/* =============================================
   Footer
   ============================================= */
.footer {
  background: var(--dark); color: rgba(255,255,255,.6);
  padding: var(--space-3xl) 0 var(--space-lg); margin-top: var(--space-3xl);
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--space-xl);
  padding-bottom: var(--space-xl); border-bottom: 1px solid rgba(255,255,255,.08);
}
.footer h3 { color: var(--white); font-size: .95rem; margin-bottom: var(--space-md); font-weight: 600; }
.footer ul li { margin-bottom: var(--space-sm); }
.footer ul li a { color: rgba(255,255,255,.5); font-size: .85rem; transition: var(--transition-fast); }
.footer ul li a:hover { color: var(--primary-light); }
.footer-bottom {
  padding-top: var(--space-lg); text-align: center; font-size: .8rem;
}

/* =============================================
   Tab Navigation
   ============================================= */
.tabs {
  display: flex; gap: 2px; border-bottom: 2px solid var(--border-light);
  margin-bottom: var(--space-lg); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 10px 20px; font-size: .9rem; font-weight: 600; color: var(--text-muted);
  border: none; background: none; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition-fast);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* =============================================
   Loading / Skeleton / Empty
   ============================================= */
.spinner {
  width: 20px; height: 20px; border: 2.5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: var(--space-3xl) 0; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--space-md); opacity: .4; }
.empty-state p { font-size: .9rem; max-width: 300px; margin: 0 auto; }

/* =============================================
   Grid Utilities
   ============================================= */
.grid { display: grid; gap: var(--space-lg); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.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); }

/* =============================================
   Spacing Utilities
   ============================================= */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.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); }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 968px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .section { padding: var(--space-2xl) 0; }
  .page-hero { padding: var(--space-2xl) 0; }
  .page-hero h1 { font-size: 1.6rem; }
  .section-title h2 { font-size: 1.35rem; }
  .navbar .nav-toggle { display: block; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text); }
  .navbar-nav { display: none; position: absolute; top: var(--navbar-height); left: 0; right: 0;
    background: var(--white); flex-direction: column; padding: var(--space-md); box-shadow: var(--shadow-lg); }
  .navbar-nav.open { display: flex; }
}
