/* ============ Digital Bill Book — Animations & Effects ============ */

/* Smooth transitions for all interactive elements */
* {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

/* Disable transitions on page load to prevent flash */
.preload * {
  transition: none !important;
}

/* ========== Keyframe Animations ========== */

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

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

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

@keyframes progress {
  from { width: 0%; }
  to { width: 100%; }
}

/* ========== Animation Classes ========== */

.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.8s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.8s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.8s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.5s ease-out;
}

/* Stagger animation delays for lists */
.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }

/* ========== Hover Effects ========== */

/* Card lift on hover */
.card-hover {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(15, 23, 42, .15);
}

/* Button hover effects */
.btn-hover-scale {
  transition: transform 0.2s ease;
}

.btn-hover-scale:hover {
  transform: scale(1.05);
}

.btn-hover-shine {
  position: relative;
  overflow: hidden;
}

.btn-hover-shine::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.btn-hover-shine:hover::before {
  left: 100%;
}

/* Icon bounce on hover */
.icon-bounce:hover {
  animation: bounce 0.6s ease infinite;
}

/* ========== Loading States ========== */

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 2000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 8px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(37, 99, 235, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ========== Page Transitions ========== */

.page-enter {
  animation: fadeInUp 0.5s ease-out;
}

.page-exit {
  animation: fadeIn 0.3s ease-out reverse;
}

/* ========== Notification Animations ========== */

.notification-enter {
  animation: slideInRight 0.4s ease-out;
}

.notification-exit {
  animation: slideInRight 0.3s ease-out reverse;
}

/* Flash message slide in */
.flash {
  animation: fadeInDown 0.5s ease-out;
}

/* ========== Modal Animations ========== */

.modal-backdrop {
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  animation: scaleIn 0.3s ease-out;
}

/* ========== Chart Animations ========== */

.chart-bar {
  transform-origin: bottom;
  animation: scaleIn 0.8s ease-out;
}

.chart-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 2s ease-out forwards;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* ========== Number Counter Animation ========== */

.counter {
  font-variant-numeric: tabular-nums;
}

/* Dashboard Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white !important;
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-lg);
  flex-wrap: wrap;
}

.welcome-banner * {
  color: white !important;
}

.welcome-content h2 {
  color: white !important;
  margin: 0 0 8px 0;
}

.welcome-content p {
  color: rgba(255, 255, 255, 0.9) !important;
  margin: 0;
}

.subscription-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.subscription-badge * {
  color: white !important;
}

.subscription-badge .plan-badge {
  background: #ecfdf5;
  color: #166534 !important;
  border: 1px solid #a7f3d0;
}

.subscription-badge .plan-badge-trial {
  background: #fef3c7;
  color: #92400e !important;
  border-color: #fcd34d;
}

/* Ensure stat cards are visible */
.stat-card {
  background: var(--card) !important;
  color: var(--ink) !important;
}

.stat-card .k,
.stat-card .v,
.stat-card .sub {
  color: inherit !important;
}

.stat-card .k {
  color: var(--muted) !important;
}

.stat-card .v {
  color: var(--ink) !important;
}

.stat-card .sub {
  color: var(--muted) !important;
}

/* Ensure panels and content are visible */
.panel {
  background: var(--card) !important;
  color: var(--ink) !important;
}

.panel h2,
.panel h3,
.panel p,
.panel a,
.panel span,
.panel div {
  color: inherit;
}

.panel .muted {
  color: var(--muted) !important;
}

/* Table visibility */
table {
  color: var(--ink) !important;
}

td, th {
  color: inherit !important;
}

@media (max-width: 640px) {
  .welcome-banner {
    padding: 18px;
  }
  
  .subscription-badge {
    width: 100%;
    align-items: flex-start;
    text-align: left;
  }
}

/* Testimonials */
.testimonials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

.testimonial-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.testimonial-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.testimonial-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

.testimonial-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 2px;
}

.testimonial-role {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
}

.testimonial-location {
  font-size: 12px;
  color: var(--muted);
}

.testimonial-rating {
  margin-bottom: 12px;
  font-size: 14px;
}

.testimonial-rating .star {
  margin-right: 2px;
}

.testimonial-text {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
  font-style: italic;
  margin: 0;
}

/* Stats with animated numbers */
.hero-stats .stat-item {
  text-align: center;
}

.hero-stats .counter {
  display: inline-block;
}

/* ========== Gradient Animation ========== */

.gradient-animated {
  background: linear-gradient(
    -45deg,
    var(--primary),
    var(--accent),
    #7c3aed,
    var(--primary)
  );
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ========== Scroll Animations ========== */

.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Auto-reveal for dashboard (no scroll needed) */
.app-content .scroll-reveal {
  opacity: 1;
  transform: translateY(0);
  animation: fadeInUp 0.8s ease-out;
}

/* ========== Progress Bar ========== */

.progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.progress-bar-indeterminate::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: var(--primary);
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0% { left: -30%; }
  100% { left: 100%; }
}

/* ========== Ripple Effect ========== */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.ripple:active::after {
  width: 300px;
  height: 300px;
}

/* ========== Tooltip Animations ========== */

.tooltip {
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.tooltip.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ========== Accessibility ========== */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ========== Print Styles ========== */

/* Trust badges / social proof */
.trust-badges {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 32px;
  opacity: 0.8;
}

.trust-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 600;
}

.trust-badge-icon {
  font-size: 20px;
}

/* Feature comparison table */
.comparison-table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.comparison-table th {
  background: var(--primary);
  color: white;
  padding: 16px;
  text-align: center;
}

.comparison-table td {
  text-align: center;
  padding: 14px;
}

.comparison-table .check {
  color: var(--success);
  font-size: 20px;
  font-weight: bold;
}

.comparison-table .cross {
  color: var(--muted);
  font-size: 16px;
  opacity: 0.4;
}

@media (max-width: 768px) {
  .testimonials-grid {
    grid-template-columns: 1fr;
  }
  
  .trust-badges {
    gap: 20px;
  }
}

@media print {
  .animate-fade-in,
  .animate-fade-in-up,
  .animate-fade-in-down,
  .animate-slide-in-left,
  .animate-slide-in-right,
  .animate-scale-in {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
