/* Dashboard Components - Analytics & Preview */

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
  min-height: 400px; /* Prevent layout shift */
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Dashboard Cards */
.dashboard-card {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid var(--border-gray);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-height: 180px; /* Fixed minimum height */
  transform: translateY(0); /* Start stable */
  opacity: 1;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-blue), var(--success-green));
}

.file-processing-card::before {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.financial-card::before {
  background: linear-gradient(90deg, var(--success-green), #10b981);
}

.breakdown-card::before {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

/* Card Icons */
.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
  color: white;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
}

.financial-icon {
  background: linear-gradient(135deg, var(--success-green), var(--dark-green));
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.breakdown-icon {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Card Content */
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-stats {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f1f5f9;
  min-height: 40px; /* Prevent jumping */
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
  flex: 1;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
  text-align: right;
  min-width: 60px;
}

.stat-success {
  color: var(--success-green);
}

.stat-danger {
  color: #ef4444;
}

.stat-income {
  color: var(--success-green);
}

.stat-expense {
  color: #ef4444;
}

.stat-net {
  color: var(--primary-blue);
  font-size: 1.1rem;
}

/* Preview Table */
.preview-table {
  max-height: 300px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border-gray);
  margin-top: 1rem;
}

.table-custom {
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  border-collapse: collapse;
}

.table-custom thead th {
  background-color: var(--primary-blue);
  color: white;
  border: none;
  font-weight: 600;
  padding: 16px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-custom tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-gray);
  vertical-align: top;
}

.table-custom tbody tr:hover {
  background-color: var(--light-blue);
}

/* Loading States */
.dashboard-card.loading {
  opacity: 0.7;
}

.dashboard-card.loading .stat-value {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
  color: transparent;
  min-height: 20px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Responsive Dashboard */
@media (max-width: 768px) {
  .dashboard-grid {
    gap: 1rem;
    min-height: 300px;
  }
  
  .dashboard-card {
    padding: 1rem;
    min-height: 150px;
  }
  
  .card-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
  
  .stat-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    min-height: 50px;
  }
  
  .stat-value {
    font-size: 1.1rem;
    text-align: left;
    min-width: auto;
  }

  .table-custom thead th,
  .table-custom tbody td {
    padding: 8px;
    font-size: 0.9rem;
  }

  .preview-table {
    max-height: 250px;
  }
}