/* ==========================================================================
   Life Management Hub (人生管理 App) - Global Styles
   Design System: Modern Apple-inspired Minimalist, Responsive & Dual Theme
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Color Palette - Clean & Warm Neutral */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-elevated: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #0284c7;
  --accent-hover: #0369a1;
  --accent-subtle: #e0f2fe;
  --accent-text: #0369a1;

  --danger: #ef4444;
  --danger-subtle: #fee2e2;
  --success: #10b981;
  --success-subtle: #d1fae5;
  --warning: #f59e0b;
  --warning-subtle: #fef3c7;
  --purple: #8b5cf6;
  --purple-subtle: #ede9fe;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --sidebar-width: 250px;
  --header-height: 60px;
  --bottom-nav-height: 64px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-surface: #131b26;
  --bg-subtle: #1c2636;
  --bg-elevated: #1e293b;
  --border-color: #273549;
  --border-subtle: #1f2a3a;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;

  --accent-primary: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-subtle: rgba(56, 189, 248, 0.15);
  --accent-text: #38bdf8;

  --danger-subtle: rgba(239, 68, 68, 0.2);
  --success-subtle: rgba(16, 185, 129, 0.2);
  --warning-subtle: rgba(245, 158, 11, 0.2);
  --purple-subtle: rgba(139, 92, 246, 0.2);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* Reset & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Shell Container */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Sidebar for Desktop */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal);
  z-index: 40;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-menu {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-subtle);
  color: var(--accent-text);
  border-color: rgba(2, 132, 199, 0.2);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}

.nav-item.active .nav-badge {
  background-color: var(--accent-primary);
  color: #fff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  background-color: var(--bg-primary);
  position: relative;
}

/* Header */
.top-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.page-title-box {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Content Area */
.content-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
}

.tab-pane {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bottom Navigation (Mobile Only) */
.bottom-nav {
  display: none;
  height: var(--bottom-nav-height);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bottom-nav-container {
  display: flex;
  height: 100%;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.bottom-nav-item.active {
  color: var(--accent-primary);
  font-weight: 600;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  outline: none;
  white-space: nowrap;
}

.btn:hover {
  background-color: var(--border-color);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  opacity: 0.95;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.btn-danger {
  background-color: var(--danger-subtle);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

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

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
}

.btn-icon:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

/* Cards & Layout */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: rgba(2, 132, 199, 0.25);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* Form Controls */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input, .textarea, .select {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

.badge-blue { background: var(--accent-subtle); color: var(--accent-text); }
.badge-green { background: var(--success-subtle); color: var(--success); }
.badge-yellow { background: var(--warning-subtle); color: var(--warning); }
.badge-red { background: var(--danger-subtle); color: var(--danger); }
.badge-purple { background: var(--purple-subtle); color: var(--purple); }

/* Modals & Dialogs */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: modalFadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-subtle);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

@keyframes toastIn {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Cloud Sync Indicator Badge */
.cloud-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green { background-color: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
.dot-yellow { background-color: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.5); }
.dot-gray { background-color: #94a3b8; }
.dot-red { background-color: #ef4444; }

.sync-dot.pulse {
  animation: syncPulse 1.2s infinite;
}

@keyframes syncPulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: block;
  }

  .bottom-nav {
    display: block;
  }

  .content-viewport {
    padding: 16px 14px calc(var(--bottom-nav-height) + 20px);
  }

  .top-header {
    padding: 0 16px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .toast-container {
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 16px;
    left: 16px;
  }
}
