/**
 * Dealy - 대시보드 스타일
 * 스크린샷 디자인 기반
 */

/* ========== 배경 블롭 애니메이션 ========== */
.dashboard-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  background: transparent; /* body 배경 사용 */
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.2;
  animation: float 20s ease-in-out infinite;
}

.blob-1 {
  width: 400px;
  height: 400px;
  top: -100px;
  left: -100px;
  background: linear-gradient(135deg, #00D9A3 0%, #00A378 100%);
  animation-delay: 0s;
}

.blob-2 {
  width: 350px;
  height: 350px;
  top: 40%;
  right: -100px;
  background: linear-gradient(135deg, #33E3B3 0%, #00D9A3 100%);
  animation-delay: 5s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  bottom: -100px;
  left: 30%;
  background: linear-gradient(135deg, #00A378 0%, #007a59 100%);
  animation-delay: 10s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(50px, -50px) scale(1.1);
  }
  50% {
    transform: translate(-30px, 30px) scale(0.9);
  }
  75% {
    transform: translate(40px, 60px) scale(1.05);
  }
}

/* ========== 헤더 ========== */
.app-header {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: var(--spacing-md);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.8);
  position: sticky;
  top: 0;
  z-index: 100;
  
  /* PWA: Safe Area 패딩만 적용 (margin-top 제거로 스크롤 문제 해결) */
  padding-top: max(var(--spacing-md), env(safe-area-inset-top, 12px));
}

.app-header .logo {
  height: 32px;
  width: auto;
}

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

.app-header .tagline {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  opacity: 0.8;
  margin-right: auto; /* 왼쪽에 붙이기 */
}

/* 헤더 우측 요소들 (PWA 버튼, 사용자 메뉴) */
.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 480px) {
  .app-header .tagline {
    display: none; /* 모바일에서는 슬로건 숨김 */
  }
  
  /* 모바일에서 헤더 간격 조정 */
  .app-header .container > div:last-child {
    gap: 6px !important;
  }
  
  .btn-header-install {
    width: 32px;
    height: 32px;
  }
  
  .btn-header-install svg {
    width: 18px;
    height: 18px;
  }
}

/* ========== 사용자 메뉴 ========== */
.user-menu {
  position: relative;
}

.btn-user {
  padding: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-user:hover {
  background: var(--gray-100);
  color: var(--primary);
}

/* ========== 헤더 PWA 설치 버튼 ========== */
.btn-header-install {
  padding: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  cursor: pointer;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-right: 8px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-header-install:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-header-install:active {
  transform: translateY(0);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: all 0.2s;
}

.user-dropdown:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-info {
  padding: 16px;
}

.user-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.user-email {
  font-size: 13px;
  color: var(--text-secondary);
}

.dropdown-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 0;
}

.dropdown-item {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--gray-100);
}

.dropdown-item:first-of-type {
  border-radius: 0 0 12px 12px;
}

.dropdown-item svg {
  flex-shrink: 0;
}

/* ========== Pull to Refresh ========== */
.pull-refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  background: white;
  padding: 12px 20px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.pull-refresh-indicator .refresh-spinner {
  width: 20px;
  height: 20px;
  color: var(--primary);
  transition: transform 0.2s;
}

.pull-refresh-indicator.refreshing .refresh-spinner {
  animation: spin 1s linear infinite;
}

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

.pull-refresh-indicator .refresh-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ========== 요약 카드 ========== */
.summary-card {
  background: linear-gradient(135deg, #00D9A3 0%, #00BF8F 100%);
  color: white;
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin: var(--spacing-lg) var(--spacing-md);
  box-shadow: 0 4px 16px rgba(0, 217, 163, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.summary-card .label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: var(--spacing-sm);
}

.summary-card .amount {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--spacing-lg);
  letter-spacing: -0.02em;
}

.summary-card .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.summary-card .stat-item .stat-label {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.summary-card .stat-item .stat-value {
  font-size: 18px;
  font-weight: 700;
}

/* ========== 재고 섹션 ========== */
.inventory-section {
  padding: 0 var(--spacing-md) var(--spacing-xl);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
}

.section-header h2 {
  font-size: 20px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.inventory-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
}

.view-all-btn {
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ========== 차량 카드 ========== */
.car-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  gap: var(--spacing-md);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: visible;
  touch-action: pan-y; /* 세로 스크롤은 허용 */
}

.car-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
  border-color: rgba(0, 217, 163, 0.2);
}

.car-card:active {
  transform: scale(0.98);
}

/* 스와이프 삭제 버튼 */
.swipe-delete-btn {
  position: absolute;
  top: 0;
  right: -80px;
  width: 80px;
  height: 100%;
  background: #ef4444;
  border: none;
  color: white;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transition: background 0.2s;
  z-index: 1;
}

.swipe-delete-btn:active {
  background: #dc2626;
}

.swipe-delete-btn svg {
  width: 24px;
  height: 24px;
}

.car-card .car-image {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--gray-100);
  flex-shrink: 0;
}

.car-card .car-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.car-card .car-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.car-card .car-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-sm);
}

.car-card .car-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.car-card .days-badge {
  background: var(--gray-100);
  color: var(--text-tertiary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.car-card .car-trim {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 2px 0 8px 0;
}

.car-card .car-notes {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 33px;
}

.car-card .car-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.car-card .cost-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.car-card .cost-label {
  font-size: 11px;
  color: var(--text-tertiary);
}

.car-card .cost-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.car-card .profit-info {
  text-align: right;
}

.car-card .profit-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.car-card .profit-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--success);
}

.car-card .profit-value.negative {
  color: var(--danger);
}

/* ========== 빈 상태 ========== */
.empty-state {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-md);
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: var(--spacing-lg);
}

/* ========== 플로팅 액션 버튼 ========== */
.fab {
  position: fixed;
  right: var(--spacing-md);
  bottom: calc(var(--spacing-xl) + var(--safe-area-inset-bottom));
  
  width: 56px;
  height: 56px;
  
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  
  font-size: 24px;
  box-shadow: var(--shadow-xl);
  
  cursor: pointer;
  transition: all var(--transition-base);
  
  z-index: 90;
}

.fab:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

/* ========== 필터/정렬 바 ========== */
.filter-bar {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-full);
  
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ========== 통계 그리드 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  padding: 0 var(--spacing-md) var(--spacing-lg);
}

.stat-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  text-align: center;
}

.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: var(--spacing-sm);
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ========== 반응형 ========== */
@media (min-width: 768px) {
  .car-card {
    padding: var(--spacing-lg);
  }
  
  .car-card .car-image {
    width: 120px;
    height: 120px;
  }
  
  .car-card .car-name {
    font-size: 18px;
  }
  
  .car-card .profit-value {
    font-size: 20px;
  }
}
