/* ==========================================================================
   EduCenter Pro - Component Library
   Buttons, Cards, Tables, Modals, Badges, Tabs, Scanner, ID Card & Print
   ========================================================================== */

/* Grid Systems */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.grid-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.grid-equal-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.grid-3col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .grid-2col, .grid-equal-2col {
    grid-template-columns: 1fr;
  }
}

/* Stat Cards (KPIs) */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-bounce);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-lg), 0 0 15px rgba(99, 102, 241, 0.1);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--card-accent, var(--primary)), transparent);
  opacity: 0.8;
}

.stat-icon-wrapper {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: var(--bg-surface-elevated);
  color: var(--card-accent, var(--primary));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.neutral { color: var(--text-muted); }

/* Standard Content Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header h3 i, .card-header h3 svg {
  color: var(--primary);
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-ar);
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-whatsapp {
  background: var(--whatsapp);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}
.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
  transform: translateY(-1px);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  line-height: 1;
}

.badge-primary { background: var(--primary-glow); color: var(--primary-light); border: 1px solid var(--border-glow); }
.badge-success { background: var(--success-bg); color: var(--success-light); border: 1px solid var(--success-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-light); border: 1px solid var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-light); border: 1px solid var(--warning-border); }
.badge-info { background: var(--info-bg); color: var(--info-light); border: 1px solid var(--info-border); }

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

select.form-control {
  cursor: pointer;
  appearance: auto;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Filter Bar */
.filter-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
}

.filter-input {
  min-width: 220px;
  padding: 0.55rem 0.9rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.88rem;
  outline: none;
}

.filter-input:focus {
  border-color: var(--primary);
}

/* Modern Data Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--bg-surface-elevated);
  padding: 0.9rem 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

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

/* Student Avatar Chip */
.student-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.student-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--primary), #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.student-info h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.student-info span {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Table Row Actions */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.action-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-icon-btn:hover {
  background: var(--primary-glow);
  color: var(--primary-light);
  border-color: var(--border-glow);
}

.action-icon-btn.btn-del:hover {
  background: var(--danger-bg);
  color: var(--danger-light);
  border-color: var(--danger-border);
}

.action-icon-btn.btn-wa:hover {
  background: var(--whatsapp-bg);
  color: var(--whatsapp);
  border-color: var(--whatsapp);
}

/* Quick Attendance Scanner Box */
.attendance-scanner-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.07) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 2px dashed var(--border-glow);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.scanner-input-container {
  max-width: 550px;
  margin: 1.5rem auto 0;
  display: flex;
  gap: 0.75rem;
}

.scanner-input-container input {
  flex: 1;
  padding: 1rem 1.25rem;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 2px solid var(--primary);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 0 15px var(--primary-glow);
  outline: none;
}

.scanner-input-container input:focus {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

/* Attendance Quick Result Banner */
.scan-result-banner {
  margin-top: 1.25rem;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: bounceIn 0.4s var(--transition-bounce);
}

@keyframes bounceIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Attendance Status Buttons in Row */
.attendance-btn-group {
  display: flex;
  background: var(--bg-surface-elevated);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  gap: 0.25rem;
}

.att-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.att-btn.present.active { background: var(--success); color: #fff; }
.att-btn.absent.active { background: var(--danger); color: #fff; }
.att-btn.late.active { background: var(--warning); color: #111827; }
.att-btn.excused.active { background: var(--info); color: #fff; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  padding: 1.5rem;
}

.modal-overlay.open,
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: all var(--transition-bounce);
  position: relative;
}

.modal-overlay.open .modal-content,
.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text-primary);
  animation: slideInLeft 0.35s var(--transition-bounce);
}

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

.toast-success { border-color: var(--success); }
.toast-danger { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }

/* Student ID Card Modern Design */
.id-card-preview {
  width: 360px;
  border-radius: 20px;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 1.5rem;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.id-card-preview::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, transparent 70%);
}

.id-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 0.85rem;
  margin-bottom: 1.2rem;
}

.id-card-body {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.id-card-photo {
  width: 75px;
  height: 90px;
  border-radius: 12px;
  border: 2px solid var(--primary-light);
  background: #2e1065;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.id-card-qr-box {
  margin-top: 1.2rem;
  padding: 0.75rem;
  background: #ffffff;
  border-radius: 12px;
  text-align: center;
  color: #0f172a;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#studentQRCodeContainer img,
#studentQRCodeContainer canvas {
  margin: 0 auto;
  display: block;
  border-radius: 4px;
}

/* Mobile & Web Camera QR Scanner */
.camera-scanner-wrapper {
  margin-top: 1.25rem;
  background: #000;
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.25);
  display: none;
}

.camera-scanner-wrapper.active {
  display: block;
}

#cameraStreamBox {
  width: 100% !important;
  min-height: 280px;
  background: #0f172a;
}

#cameraStreamBox video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.scanner-laser-line {
  position: absolute;
  top: 10%;
  left: 5%;
  right: 5%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #10b981, #34d399, transparent);
  box-shadow: 0 0 12px #10b981;
  animation: laserScan 2.2s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 10;
}

@keyframes laserScan {
  0% { top: 15%; opacity: 0.6; }
  50% { opacity: 1; }
  100% { top: 85%; opacity: 0.6; }
}

.camera-scanner-controls {
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Honor Board (لوحة الشرف) */
.honor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.honor-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, var(--bg-surface) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-bounce);
}

.honor-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.2);
}

.honor-badge-medal {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #fff;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

/* Printable Official Invoice / Receipt */
.receipt-box {
  background: #fff;
  color: #111827;
  padding: 2rem;
  border-radius: 12px;
  max-width: 480px;
  margin: 0 auto;
  border: 1px solid #e5e7eb;
  font-family: var(--font-ar);
}

.receipt-header {
  text-align: center;
  border-bottom: 2px dashed #9ca3af;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.92rem;
}

.receipt-row.total {
  border-top: 2px solid #111827;
  border-bottom: 2px solid #111827;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 0.75rem 0;
  margin-top: 0.75rem;
}

.receipt-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px dashed #9ca3af;
  font-size: 0.8rem;
  color: #6b7280;
}
