/* ===== FridgeKeeper Global Styles ===== */

:root {
  --fk-primary: #4f46e5;
  --fk-primary-light: #818cf8;
  --fk-primary-dark: #3730a3;
  --fk-accent: #f59e0b;
  --fk-success: #10b981;
  --fk-danger: #ef4444;
  --fk-warning: #f59e0b;
  --fk-info: #3b82f6;
  --fk-bg: #f3f4f6;
  --fk-card: #ffffff;
  --fk-text: #1f2937;
  --fk-text-light: #6b7280;
  --fk-border: #e5e7eb;
}

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--fk-bg);
  color: var(--fk-text);
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--fk-bg);
  position: relative;
}

/* Bottom Navigation */
.fk-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--fk-card);
  border-top: 1px solid var(--fk-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0 env(safe-area-inset-bottom, 0);
  z-index: 100;
}

.fk-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border: none;
  background: none;
  font-size: 11px;
  color: var(--fk-text-light);
  cursor: pointer;
  transition: color 0.2s;
}

.fk-nav-item.active {
  color: var(--fk-primary);
}

.fk-nav-item svg {
  width: 24px;
  height: 24px;
}

/* Page container */
.fk-page {
  padding: 16px 16px 80px;
  min-height: 100vh;
  animation: fk-fade-in 0.25s ease;
}

/* 带悬浮按钮的页面：底部留足空间，避免 FAB 遮挡列表最后一项 */
.fk-page:has(.fk-fab) {
  padding-bottom: 150px;
}

@keyframes fk-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.fk-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.fk-header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--fk-card);
  border: 1px solid var(--fk-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fk-text);
}

/* Cards */
.fk-card {
  background: var(--fk-card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.fk-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fk-text-light);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Item row */
.fk-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--fk-card);
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.15s;
}

.fk-item-row:active {
  transform: scale(0.98);
}

.fk-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.fk-item-info {
  flex: 1;
  min-width: 0;
}

.fk-item-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fk-item-meta {
  font-size: 12px;
  color: var(--fk-text-light);
}

/* Badges */
.fk-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.fk-badge-danger { background: #fee2e2; color: #991b1b; }
.fk-badge-warning { background: #fef3c7; color: #92400e; }
.fk-badge-success { background: #d1fae5; color: #065f46; }
.fk-badge-info { background: #dbeafe; color: #1e40af; }
.fk-badge-neutral { background: #f3f4f6; color: #374151; }

/* Buttons */
.fk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.fk-btn:active { transform: scale(0.97); }
.fk-btn:disabled { opacity: 0.5; }

.fk-btn-primary {
  background: var(--fk-primary);
  color: white;
}

.fk-btn-secondary {
  background: var(--fk-card);
  color: var(--fk-text);
  border: 1px solid var(--fk-border);
}

.fk-btn-danger {
  background: var(--fk-danger);
  color: white;
}

.fk-btn-success {
  background: var(--fk-success);
  color: white;
}

.fk-btn-block {
  width: 100%;
}

/* FAB */
.fk-fab {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(140px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--fk-primary);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(79,70,229,0.35);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.15s;
}

.fk-fab:active {
  transform: translateX(140px) scale(0.9);
}

/* Forms */
.fk-form-group {
  margin-bottom: 14px;
}

.fk-form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fk-text-light);
  margin-bottom: 4px;
}

.fk-form-input,
.fk-form-select,
.fk-form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--fk-border);
  border-radius: 10px;
  font-size: 15px;
  background: white;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.fk-form-input:focus,
.fk-form-select:focus,
.fk-form-textarea:focus {
  border-color: var(--fk-primary);
}

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

/* Modal / Bottom Sheet */
.fk-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fk-fade-in 0.2s;
}

.fk-modal {
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 16px env(safe-area-inset-bottom, 16px);
  animation: fk-slide-up 0.3s ease;
}

@keyframes fk-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.fk-modal-title {
  font-size: 18px;
  font-weight: 700;
}

.fk-modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: #f3f4f6;
  border-radius: 50%;
  font-size: 16px;
  color: var(--fk-text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Login */
.fk-login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: white;
}

.fk-login-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--fk-primary), var(--fk-primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 16px;
}

.fk-login-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.fk-login-subtitle {
  font-size: 14px;
  color: var(--fk-text-light);
  margin-bottom: 32px;
}

/* Category colors */
.cat-vegetable { background: #d1fae5; }
.cat-fruit { background: #fed7aa; }
.cat-meat { background: #fecaca; }
.cat-dairy { background: #dbeafe; }
.cat-seafood { background: #cffafe; }
.cat-grain { background: #fef3c7; }
.cat-snack { background: #fce7f3; }
.cat-beverage { background: #e0e7ff; }
.cat-condiment { background: #fef9c3; }
.cat-frozen { background: #e0f2fe; }
.cat-other { background: #f3f4f6; }

/* Empty state */
.fk-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--fk-text-light);
}

.fk-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.fk-empty-text {
  font-size: 14px;
}

/* Loading */
.fk-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--fk-text-light);
}

.fk-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--fk-border);
  border-top-color: var(--fk-primary);
  border-radius: 50%;
  animation: fk-spin 0.8s linear infinite;
}

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

/* Tabs */
.fk-tabs {
  display: flex;
  gap: 4px;
  background: #e5e7eb;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.fk-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fk-text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.fk-tab.active {
  background: white;
  color: var(--fk-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Lottery animation */
.fk-lottery {
  text-align: center;
  padding: 20px;
}

.fk-lottery-dish {
  width: 200px;
  height: 200px;
  margin: 20px auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fk-primary), var(--fk-primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  color: white;
  box-shadow: 0 8px 24px rgba(79,70,229,0.3);
  animation: fk-pulse 0.6s ease infinite alternate;
}

.fk-lottery-dish.spinning {
  animation: fk-spin-lottery 0.3s linear infinite;
}

@keyframes fk-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

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

/* Alert banner */
.fk-alert-banner {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.fk-alert-banner.warning {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
}

.fk-alert-banner.info {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
}

/* Search bar */
.fk-search-bar {
  position: relative;
  margin-bottom: 12px;
}

.fk-search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--fk-border);
  border-radius: 10px;
  font-size: 14px;
  background: white;
  outline: none;
}

.fk-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fk-text-light);
}

/* Recipe card */
.fk-recipe-card {
  background: var(--fk-card);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.fk-recipe-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fk-recipe-name {
  font-size: 16px;
  font-weight: 700;
}

.fk-recipe-body {
  padding: 0 16px 14px;
}

.fk-recipe-section {
  margin-bottom: 10px;
}

.fk-recipe-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fk-text-light);
  margin-bottom: 4px;
}

.fk-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  margin: 2px;
}

.fk-tag-available { background: #d1fae5; color: #065f46; }
.fk-tag-missing { background: #fee2e2; color: #991b1b; }
.fk-tag-ai { background: #e0e7ff; color: #3730a3; }

/* Toast */
.fk-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  animation: fk-toast-in 0.3s;
  white-space: nowrap;
}

@keyframes fk-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Family group */
.fk-family-member {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #f9fafb;
  margin-bottom: 8px;
}

.fk-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--fk-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

/* Progress bar */
.fk-progress-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.fk-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}
