/* ============================================================
   EXTRA.CSS - Bổ sung animation và polish
   Import sau style.css: <link rel="stylesheet" href="css/extra.css"/>
   ============================================================ */

/* ============================================================
   PULL TO REFRESH INDICATOR
   ============================================================ */
.ptr-indicator {
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden; transition: height 0.2s ease;
  color: var(--text-muted); font-size: 13px; gap: 8px;
}
.ptr-indicator.visible { height: 48px; }
.ptr-spin { animation: spin 1s linear infinite; }

/* ============================================================
   FAB - Floating Action Button (alternative to top button)
   ============================================================ */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-height) + 16px);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: white; font-size: 24px;
  border: none; cursor: pointer; box-shadow: 0 4px 16px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 40;
}
.fab:hover { transform: scale(1.1) rotate(90deg); }
.fab:active { transform: scale(0.95); }

/* ============================================================
   NUMBER COUNTER ANIMATION
   ============================================================ */
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-value.animated { animation: countUp 0.4s ease; }

/* ============================================================
   RIPPLE EFFECT trên buttons
   ============================================================ */
.ripple-container { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.15); transform: scale(0);
  animation: rippleAnim 0.5s linear;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ============================================================
   PROGRESS BAR - Thanh tiến trình đóng quỹ tháng
   ============================================================ */
.progress-wrap {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-secondary); margin-bottom: 8px;
}
.progress-bar-bg {
  height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   CATEGORY ICON GRID (chi tiêu quick-pick)
   ============================================================ */
.cat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 16px;
}
.cat-item {
  background: var(--bg-input); border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 8px;
  text-align: center; cursor: pointer; transition: var(--transition);
}
.cat-item:hover, .cat-item.selected {
  border-color: var(--accent); background: var(--accent-glow);
}
.cat-item .cat-icon { font-size: 24px; display: block; margin-bottom: 4px; }
.cat-item .cat-name { font-size: 10px; color: var(--text-secondary); font-weight: 600; line-height: 1.2; }

/* ============================================================
   AMOUNT INPUT với format tự động
   ============================================================ */
.amount-display {
  font-size: 28px; font-weight: 800; text-align: center;
  color: var(--accent-light); padding: 16px;
  border-bottom: 2px solid var(--accent); margin-bottom: 16px;
  min-height: 64px; letter-spacing: 1px;
}

/* ============================================================
   MONTH TABS - điều hướng nhanh theo tháng
   ============================================================ */
.month-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px;
  margin-bottom: 12px; scrollbar-width: none;
}
.month-tabs::-webkit-scrollbar { display: none; }
.month-tab {
  flex-shrink: 0; padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: var(--transition); font-family: inherit;
}
.month-tab.active {
  background: var(--accent); border-color: var(--accent); color: white;
}

/* ============================================================
   SEARCH HIGHLIGHT
   ============================================================ */
mark {
  background: rgba(59, 130, 246, 0.3); color: var(--accent-light);
  border-radius: 2px; padding: 0 1px;
}

/* ============================================================
   SKELETON IMPROVED
   ============================================================ */
.skeleton-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; gap: 12px; align-items: center;
}
.skeleton-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
}
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 12px; border-radius: 6px; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line, .skeleton-avatar {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card2) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ============================================================
   NOTIFICATION DOT
   ============================================================ */
.notif-dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--bg-secondary);
}

/* ============================================================
   STATS MINI - inline stats trong list
   ============================================================ */
.mini-stats {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.mini-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; text-align: center;
}
.mini-stat-val { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.mini-stat-lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   DIVIDER WITH LABEL
   ============================================================ */
.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0; color: var(--text-muted); font-size: 11px; font-weight: 600;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ============================================================
   COIN FLIP ANIMATION (khi tính tồn quỹ)
   ============================================================ */
@keyframes coinFlip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg) scale(0.8); }
  100% { transform: rotateY(0deg); }
}
.coin-flip { animation: coinFlip 0.6s ease; }

/* ============================================================
   SAFE AREA (iPhone notch)
   ============================================================ */
.bottom-nav {
  padding-bottom: max(env(safe-area-inset-bottom), 8px);
}
.modal {
  padding-bottom: max(env(safe-area-inset-bottom), 20px);
}

/* ============================================================
   DARK MODE OPTIMIZATIONS
   ============================================================ */
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select {
  color-scheme: dark;
}

/* ============================================================
   PRINT STYLES (khi in báo cáo)
   ============================================================ */
@media print {
  .bottom-nav, .app-header, .btn-add, .action-btn, .modal-overlay { display: none !important; }
  .app-main { padding-top: 0 !important; padding-bottom: 0 !important; }
  .page { display: block !important; }
  body { background: white !important; color: black !important; }
}

/* ============================================================
   LANDSCAPE MOBILE
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header { height: 48px; }
  :root { --header-height: 48px; --nav-height: 54px; }
  .nav-label { display: none; }
  .nav-icon { font-size: 20px; }
}
