/**
 * KGMB Dashboard KPI Cards Styles - Phase 8 Enhanced
 * Updated for 3-card layout with state analytics graph
 */

.kgmb-dashboard-kpi-container {
  margin-bottom: 2rem;
}

.kgmb-kpi-card {
  transition: all 0.3s ease;
  height: 100%;
  min-height: 150px;
}

.kgmb-kpi-card:hover {
  transform: translateY(-3px);
}

/* Card animations */
.kgmb-kpi-card {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

.kgmb-kpi-card:nth-child(1) {
  animation-delay: 0.1s;
}

.kgmb-kpi-card:nth-child(2) {
  animation-delay: 0.2s;
}

.kgmb-kpi-card:nth-child(3) {
  animation-delay: 0.3s;
}

/* Pulse effect for icons */
.kgmb-kpi-card .iconify {
  animation: pulse 2s infinite;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

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

/* Light mode styles (default) */
.kgmb-theme-light .kgmb-kpi-card {
  background-color: #ffffff;
  color: #1f2937;
}

.kgmb-theme-light .kgmb-kpi-card h3 {
  color: #4b5563;
}

.kgmb-theme-light .kgmb-kpi-card p {
  color: #111827;
}

.kgmb-theme-light .kgmb-kpi-card .text-gray-500 {
  color: #6b7280;
}

.kgmb-theme-light .kgmb-kpi-card .text-gray-600 {
  color: #4b5563;
}

.kgmb-theme-light .kgmb-kpi-card .text-gray-800 {
  color: #1f2937;
}

/* Updated card colors for 3-card layout */
/* First card - Blue (New Members Application) */
.kgmb-theme-light .kgmb-kpi-card:nth-child(1) {
  background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
}

.kgmb-theme-light .kgmb-kpi-card:nth-child(1) h3 {
  color: #0277bd;
}

/* Second card - Green (Total Members) */
.kgmb-theme-light .kgmb-kpi-card:nth-child(2) {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.kgmb-theme-light .kgmb-kpi-card:nth-child(2) h3 {
  color: #2e7d32;
}

/* Third card - Amber (New Loan Application) */
.kgmb-theme-light .kgmb-kpi-card:nth-child(3) {
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.kgmb-theme-light .kgmb-kpi-card:nth-child(3) h3 {
  color: #ff8f00;
}

/* Dark mode overrides */
.kgmb-theme-dark .kgmb-kpi-card {
  background-color: #1f2937 !important;
  color: #e5e7eb !important;
}

.kgmb-theme-dark .kgmb-kpi-card h3 {
  color: #93c5fd !important;
}

.kgmb-theme-dark .kgmb-kpi-card p {
  color: #f3f4f6 !important;
}

.kgmb-theme-dark .kgmb-kpi-card .text-gray-500,
.kgmb-theme-dark .kgmb-kpi-card .text-gray-600 {
  color: #9ca3af !important;
}

.kgmb-theme-dark .kgmb-kpi-card .text-green-600 {
  color: #6ee7b7 !important;
}

.kgmb-theme-dark .kgmb-kpi-card .text-red-600 {
  color: #fca5a5 !important;
}

.kgmb-theme-dark .kgmb-kpi-card .text-gray-800 {
  color: #f3f4f6 !important;
}

/* State Analytics Graph Styles */
#state-analytics-chart {
  width: 100%;
  height: 350px;
}

.kgmb-chart-container {
  background: #ffffff;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-top: 2rem;
}

.kgmb-chart-container h3 {
  color: #1f2937;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: between;
}

.kgmb-chart-container .chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.kgmb-chart-container .chart-info {
  color: #6b7280;
  font-size: 0.875rem;
  margin-top: 1rem;
  text-align: center;
}

/* Loading state for chart */
.kgmb-chart-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 350px;
  color: #6b7280;
}

.kgmb-chart-loading .iconify {
  margin-right: 0.5rem;
  animation: spin 1s linear infinite;
}

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

/* Chart empty state */
.kgmb-chart-empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 350px;
  color: #9ca3af;
}

.kgmb-chart-empty .iconify {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.kgmb-chart-empty h4 {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.kgmb-chart-empty p {
  font-size: 0.875rem;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .kgmb-kpi-card {
    margin-bottom: 1rem;
  }
  
  #state-analytics-chart {
    height: 250px;
  }
  
  .kgmb-chart-container {
    padding: 1rem;
  }
  
  .kgmb-chart-container .chart-header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}

@media (max-width: 768px) {
  #state-analytics-chart {
    height: 300px;
  }
}

/* Custom color variations for different user roles */
.admin-role .kgmb-kpi-card:nth-child(1) {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

.admin-role .kgmb-kpi-card:nth-child(2) {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}

.admin-role .kgmb-kpi-card:nth-child(3) {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

/* Card hover effects */
.kgmb-kpi-card:hover .kgmb-counter {
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

/* Trend indicators */
.kgmb-trend-up {
  color: #10b981;
}

.kgmb-trend-down {
  color: #ef4444;
}

.kgmb-trend-neutral {
  color: #6b7280;
}

/* Enhanced iconify icon styling */
.kgmb-kpi-card .iconify[data-icon*="arrow-trending-up"] {
  color: #10b981;
}

.kgmb-kpi-card .iconify[data-icon*="arrow-trending-down"] {
  color: #ef4444;
}

.kgmb-kpi-card .iconify[data-icon*="minus"] {
  color: #6b7280;
}

/* Chart legend styling */
.apexcharts-legend {
  justify-content: center !important;
}

.apexcharts-legend-text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* Tooltip styling */
.apexcharts-tooltip {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
}

.apexcharts-tooltip-title {
  background: #f9fafb !important;
  color: #374151 !important;
  border-bottom: 1px solid #e5e7eb !important;
  font-weight: 600 !important;
}

/* Grid styling */
.kgmb-dashboard-kpi-container .grid {
  gap: 1.5rem;
}

/* Enhanced 3-column responsive behavior */
@media (min-width: 1024px) {
  .kgmb-dashboard-kpi-container .grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1em;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .kgmb-dashboard-kpi-container .grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .kgmb-dashboard-kpi-container .grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 .kgmb-kpi-card:nth-child(3) {
    grid-column: span 2;
    max-width: 50%;
    margin: 0 auto;
  }
}

@media (max-width: 767px) {
  .kgmb-dashboard-kpi-container .grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

/* Animation delays for 3 cards */
.kgmb-kpi-card:nth-child(1) { animation-delay: 0.1s; }
.kgmb-kpi-card:nth-child(2) { animation-delay: 0.2s; }
.kgmb-kpi-card:nth-child(3) { animation-delay: 0.3s; }

/* Ensure proper spacing */
.kgmb-dashboard-kpi-container .mb-8 {
  margin-bottom: 2rem;
}

.kgmb-dashboard-kpi-container .mt-8 {
  margin-top: 2rem;
  margin-bottom: 1em;
}

.kgmb-kpi-card.relative.overflow-hidden.rounded-lg.p-6.transition-all.duration-300.bg-white.shadow-md.hover\:shadow-lg.bg-gradient-to-br.from-blue-50.to-blue-100 {
  align-content: center;
}

.kgmb-kpi-card.relative.overflow-hidden.rounded-lg.p-6.transition-all.duration-300.bg-white.shadow-md.hover\:shadow-lg.bg-gradient-to-br.from-green-50.to-green-100 {
  align-content: center;
}

.kgmb-kpi-card.relative.overflow-hidden.rounded-lg.p-6.transition-all.duration-300.bg-white.shadow-md.hover\:shadow-lg.bg-gradient-to-br.from-amber-50.to-amber-100 {
  align-content: center;
}

.text-sm {
  font-size: 15px !important;
  font-weight: bold;
  text-align: center;
}

.text-3xl.font-bold.text-gray-800.mb-2 {
  text-align: center;
}

.flex.items-center.text-sm {
  display: block;
}

.flex.items-center.text-red-600.mr-2 {
  display: inline-block;
}

.flex.items-center.text-gray-600.mr-2 {
  display: inline-block;
}

.flex.items-center.text-green-600.mr-2 {
  display: inline-block;
}

iconify-icon {
  display: inline-block;
}

.text-lg.font-semibold.text-gray-800 {
  font-size: 15px !important;
  text-transform: uppercase;
}

.bg-white.rounded-lg.shadow-md.p-6 {
  padding: 2em !important;
}

.kgmb-chart-empty h4 {
  font-size: 25px !important;
  text-transform: uppercase;
}

.card .card-title {
  font-size: 15px !important;
  text-transform: uppercase;
}

.card-body {
  padding: 1em !important;
}

.row {
  margin-top: unset !important;
  margin-right: unset !important;
  margin-left: unset !important;
}

.mb-0.text-primary {
  color: rgb(75, 145, 247) !important;
}

.mb-0.text-success {
  color: rgb(34, 222, 135) !important;
}

.card-body.text-center {
  align-content: center;
}

.text-muted.mb-0 {
  color: white !important;
}

.text-muted {
  color: white !important;
}

.card-body {
  align-content: center;
}

.col-md-6 {
  padding-top: unset !important;
}

