/**
 * 📊 Dashboard & Analytics Styles
 * Beautiful, modern dashboard styling
 */

/* Card Popup Modal Styles */
.card-popup-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.card-popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.card-popup-content {
  position: relative;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  z-index: 10001;
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

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

.card-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.card-popup-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.card-popup-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.card-popup-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.card-popup-body {
  padding: 0;
  max-height: calc(80vh - 80px);
  overflow-y: auto;
}

/* Dashboard Tabs — pill style */
.dashboard-tabs { display: none; } /* legacy, replaced by rpt-tab-bar */

.rpt-tab-bar {
  display: flex;
  gap: 6px;
  padding: 16px 20px 0;
  flex-wrap: wrap;
  background: #f8faff;
  border-bottom: 1px solid #e8edf5;
}

.rpt-tab {
  padding: 10px 18px;
  border-radius: 10px 10px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  bottom: -1px;
}
.rpt-tab:hover { color: #0284c7; background: #fff; border-color: #e8edf5; }
.rpt-tab.active {
  background: #fff;
  color: #0284c7;
  border-color: #e8edf5;
  border-bottom-color: #fff;
  box-shadow: 0 -2px 8px rgba(2,132,199,0.08);
}

.rpt-tab-body {
  background: #fff;
  padding: 0;
}

.rpt-panel {
  padding: 24px;
  animation: fadeInPanel 0.2s ease;
}

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

.tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #6b7280;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  position: relative;
  bottom: -2px;
}

.tab-btn:hover {
  color: #004aad;
  background: #f3f4f6;
}

.tab-btn.active {
  color: #004aad;
  border-bottom-color: #004aad;
  background: #f3f4f6;
}

/* Tab Content */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

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

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 24px;
  color: white;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card.clickable {
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.stat-card.clickable:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
}

.stat-card.clickable * {
  pointer-events: none;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: pulse 3s ease-in-out infinite;
}

.stat-card:nth-child(2) {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  box-shadow: 0 8px 24px rgba(245, 87, 108, 0.3);
}

.stat-card:nth-child(3) {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  box-shadow: 0 8px 24px rgba(79, 172, 254, 0.3);
}

.stat-card:nth-child(4) {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  box-shadow: 0 8px 24px rgba(67, 233, 123, 0.3);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 22px 20px;
  color: white;
  box-shadow: 0 8px 24px rgba(102,126,234,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stat-icon {
  font-size: 28px;
  opacity: 0.85;
  background: rgba(255,255,255,0.18);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-value {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}

.stat-label {
  font-size: 13px;
  opacity: 0.82;
  font-weight: 500;
  letter-spacing: 0.2px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* Chart Container */
.chart-container {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-top: 24px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-header h3 {
  margin: 0;
  color: #1f2937;
  font-size: 18px;
}

.chart-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-filters input[type="date"] {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
}

.chart-filters .btn.small {
  padding: 6px 12px;
  font-size: 12px;
}

.chart-filters span {
  color: #6b7280;
  font-size: 13px;
}

#leaveTrendChart {
  width: 100%;
  max-width: 100%;
  height: 350px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(168, 85, 247, 0.02) 100%);
  border-radius: 12px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar select,
.filter-bar input[type="month"] {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  color: #1f2937;
}

.filter-bar select:focus,
.filter-bar input[type="month"]:focus {
  outline: none;
  border-color: #004aad;
  box-shadow: 0 0 0 3px rgba(0, 74, 173, 0.1);
}

/* Dashboard Tables */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.dashboard-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

.dashboard-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.dashboard-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dashboard-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
  color: #374151;
  word-wrap: break-word;
  max-width: 200px;
}

.reason-cell {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-table tbody tr {
  transition: background 0.2s ease;
}

.dashboard-table tbody tr:hover {
  background: #f9fafb;
}

.dashboard-table tbody tr:last-child td {
  border-bottom: none;
}

/* Attendance Grid - Compact Design */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.attendance-horizontal-grid {
  display: flex;
  flex-direction: row;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 4px 16px 4px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  width: 100%;
}

/* Modern Attendance Cards */
.attendance-modern-card {
  flex: 0 0 auto;
  min-width: 280px;
  max-width: 300px;
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.attendance-modern-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.attendance-modern-card:hover::before {
  transform: scaleX(1);
}

.attendance-modern-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.attendance-modern-card.gradient-green::before {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.attendance-modern-card.gradient-orange::before {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.attendance-modern-card.gradient-red::before {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.modern-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.teacher-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.teacher-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  overflow: hidden;
  border: 3px solid #fff;
  outline: 2px solid rgba(99,102,241,0.25);
}

.teacher-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.teacher-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: 'Poppins', sans-serif;
}

.teacher-name {
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.3;
}

.attendance-percentage-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 16px;
  min-width: 80px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.attendance-percentage-badge.green {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
}

.attendance-percentage-badge.orange {
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
  color: #9a3412;
}

.attendance-percentage-badge.red {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
}

.percentage-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.percentage-icon {
  font-size: 16px;
}

.modern-card-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item-modern {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.stat-item-modern:hover {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  transform: translateX(4px);
}

.stat-icon-modern {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-details {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.stat-label-modern {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-value-modern {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
}

.horizontal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}

.horizontal-card-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}

.horizontal-card-stats span {
  display: block;
  padding: 4px 0;
}

.attendance-compact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
  align-items: stretch;
  width: 100%;
}

.attendance-compact-card {
  flex: 1 1 auto;
  min-width: 220px;
  max-width: 300px;
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-left: 4px solid #004aad;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.attendance-compact-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.compact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.compact-header strong {
  color: #1f2937;
  font-size: 14px;
}

.attendance-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.compact-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #6b7280;
}

.compact-stats span {
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 6px;
}

.attendance-table-container {
  margin-top: 20px;
}

.compact-table {
  font-size: 13px;
}

.compact-table th,
.compact-table td {
  padding: 10px 12px;
}

.attendance-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-left: 4px solid #004aad;
}

.attendance-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.attendance-card h3 {
  margin: 0 0 16px 0;
  color: #1f2937;
  font-size: 18px;
}

.attendance-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #f9fafb;
  border-radius: 8px;
}

.stat-item .stat-label {
  color: #6b7280;
  font-size: 14px;
}

.stat-item .stat-value {
  font-weight: 700;
  font-size: 16px;
  color: #1f2937;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  .stat-value {
    font-size: 28px;
  }
  
  .stat-icon {
    font-size: 24px;
  }
  
  .dashboard-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-btn {
    white-space: nowrap;
    padding: 10px 14px;
    font-size: 12px;
    min-width: auto;
  }
  
  .chart-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .chart-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .chart-filters input[type="date"],
  .chart-filters button {
    width: 100%;
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-bar select,
  .filter-bar input[type="month"],
  .filter-bar button {
    width: 100%;
  }
  
  .dashboard-table {
    font-size: 11px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .dashboard-table th,
  .dashboard-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }
  
  .attendance-grid,
  .attendance-compact-grid,
  .attendance-horizontal-grid {
    flex-direction: column;
    gap: 10px;
  }
  
  .attendance-compact-card,
  .attendance-horizontal-card,
  .attendance-modern-card {
    padding: 12px;
    min-width: 100%;
    max-width: 100%;
  }
  
  .attendance-modern-card {
    min-width: 100%;
    max-width: 100%;
  }
  
  .teacher-icon {
    width: 44px;
    height: 44px;
  }

  .teacher-initials {
    font-size: 15px;
  }
  
  .teacher-name {
    font-size: 14px;
  }
  
  .attendance-percentage-badge {
    padding: 8px 12px;
    min-width: 70px;
  }
  
  .percentage-value {
    font-size: 20px;
  }
  
  .stat-item-modern {
    padding: 10px;
  }
  
  .stat-icon-modern {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  
  .card-popup-content {
    width: 95%;
    max-height: 85vh;
  }
  
  .card-popup-header {
    padding: 16px 20px;
  }
  
  .card-popup-header h3 {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    padding: 14px;
  }
  
  .stat-value {
    font-size: 24px;
  }
  
  .stat-icon {
    font-size: 20px;
  }
  
  .chart-container {
    padding: 12px;
  }
  
  .chart-header h3 {
    font-size: 16px;
  }
  
  #leaveTrendChart {
    height: 250px;
  }
  
  .compact-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .compact-stats {
    flex-direction: column;
    gap: 6px;
  }
}

