/* ═══════════════════════════════════════════
   Components CSS
════════════════════════════════════════════ */

/* ─── Form Elements ─── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.03em; }
.form-required { color: var(--red); margin-left: 3px; }

.input-wrapper { position: relative; }
.input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
}
.form-input {
  width: 100%; padding: 12px 14px 12px 44px;
  background: var(--bg-input); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; transition: all var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.12); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.no-icon { padding-left: 14px; }
.form-select {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; transition: all var(--transition); outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9cc8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px; cursor: pointer;
}
.form-select:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.12); }
.form-textarea {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; transition: all var(--transition); outline: none;
  resize: vertical; min-height: 80px;
}
.form-textarea:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.12); }

.toggle-password {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); transition: color var(--transition);
}
.toggle-password:hover { color: var(--text-primary); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

.btn-blue {
  background: linear-gradient(135deg, #1a56db, #1d4ed8);
  color: #fff; box-shadow: 0 2px 10px rgba(26,86,219,0.3);
}
.btn-blue:hover { box-shadow: 0 4px 20px rgba(26,86,219,0.45); transform: translateY(-1px); }
.btn-green {
  background: linear-gradient(135deg, #059669, #0e9f6e);
  color: #fff; box-shadow: 0 2px 10px rgba(14,159,110,0.3);
}
.btn-green:hover { box-shadow: 0 4px 20px rgba(14,159,110,0.45); transform: translateY(-1px); }
.btn-red {
  background: linear-gradient(135deg, #dc2626, #e02424);
  color: #fff; box-shadow: 0 2px 10px rgba(224,36,36,0.3);
}
.btn-red:hover { box-shadow: 0 4px 20px rgba(224,36,36,0.45); }
.btn-yellow {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff;
}
.btn-ghost {
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-outline {
  background: transparent; color: var(--brand-primary);
  border: 1.5px solid var(--brand-primary);
}
.btn-outline:hover { background: var(--blue-bg); }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}

/* ─── Badges / Chips ─── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-present { background: var(--green-bg); color: var(--green); }
.badge-absent { background: var(--red-bg); color: var(--red); }
.badge-excused { background: var(--yellow-bg); color: var(--yellow); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }

/* Role badges */
.role-tag {
  display: inline-block; padding: 3px 10px;
  border-radius: 100px; font-size: 11px; font-weight: 700;
}
.role-tag.super_admin { background: var(--purple-bg); color: #a78bfa; }
.role-tag.block_admin { background: var(--blue-bg); color: #60a5fa; }
.role-tag.floor_warden { background: var(--green-bg); color: #34d399; }
.role-tag.assistant { background: var(--teal-bg); color: #22d3ee; }
.role-tag.observer { background: var(--yellow-bg); color: #fbbf24; }

/* ─── Alerts ─── */
.alert {
  padding: 14px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-error { background: var(--red-bg); border: 1px solid rgba(224,36,36,0.3); color: #f87171; }
.alert-success { background: var(--green-bg); border: 1px solid rgba(14,159,110,0.3); color: #34d399; }
.alert-warning { background: var(--yellow-bg); border: 1px solid rgba(217,119,6,0.3); color: #fbbf24; }
.alert-info { background: var(--blue-bg); border: 1px solid rgba(26,86,219,0.3); color: #60a5fa; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 24px;
  transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Stat Cards */
.stat-card {
  padding: 24px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border-color);
  transition: all var(--transition); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.blue::before { background: linear-gradient(90deg, #1a56db, #3b82f6); }
.stat-card.green::before { background: linear-gradient(90deg, #059669, #10b981); }
.stat-card.red::before { background: linear-gradient(90deg, #dc2626, #ef4444); }
.stat-card.yellow::before { background: linear-gradient(90deg, #d97706, #f59e0b); }
.stat-card.purple::before { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }
.stat-card.teal::before { background: linear-gradient(90deg, #0891b2, #06b6d4); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: var(--blue-bg); } .stat-icon.blue svg { stroke: #60a5fa; }
.stat-icon.green { background: var(--green-bg); } .stat-icon.green svg { stroke: #34d399; }
.stat-icon.red { background: var(--red-bg); } .stat-icon.red svg { stroke: #f87171; }
.stat-icon.yellow { background: var(--yellow-bg); } .stat-icon.yellow svg { stroke: #fbbf24; }
.stat-icon.purple { background: var(--purple-bg); } .stat-icon.purple svg { stroke: #a78bfa; }
.stat-icon.teal { background: var(--teal-bg); } .stat-icon.teal svg { stroke: #22d3ee; }
.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px; font-weight: 800; color: var(--text-primary); line-height: 1;
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; font-weight: 500; }
.stat-change {
  font-size: 12px; font-weight: 600; margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ─── Table ─── */
.table-wrapper {
  overflow-x: auto; border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: 14px;
}
thead tr {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}
thead th {
  padding: 13px 16px; text-align: left;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); letter-spacing: 0.05em;
  text-transform: uppercase; white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody td {
  padding: 14px 16px; color: var(--text-primary);
  vertical-align: middle;
}
.table-empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted); font-size: 14px;
}
.table-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Search/Filter Bar ─── */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.search-input-wrapper {
  position: relative; flex: 1; min-width: 200px;
}
.search-input-wrapper svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; padding: 10px 14px 10px 38px;
  background: var(--bg-input); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; outline: none; transition: all var(--transition);
}
.search-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }

/* ─── Progress Bar ─── */
.progress-bar-wrap {
  height: 8px; background: var(--border-color);
  border-radius: 4px; overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: 4px;
  transition: width 0.6s ease;
}
.progress-bar.green { background: linear-gradient(90deg, #059669, #10b981); }
.progress-bar.blue { background: linear-gradient(90deg, #1a56db, #3b82f6); }
.progress-bar.red { background: linear-gradient(90deg, #dc2626, #ef4444); }
.progress-bar.yellow { background: linear-gradient(90deg, #d97706, #f59e0b); }

/* ─── Loading Spinner ─── */
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border-color);
  border-top-color: var(--brand-primary);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; flex-direction: column; gap: 16px;
}
.loading-state p { color: var(--text-muted); font-size: 14px; }

/* ─── Empty State ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 24px; text-align: center;
}
.empty-state svg { width: 56px; height: 56px; color: var(--text-muted); margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-muted); max-width: 320px; }

/* ─── Attendance Status Buttons ─── */
.att-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.att-btn {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; border: 1.5px solid transparent;
  transition: all var(--transition); cursor: pointer;
}
.att-btn.present {
  background: var(--green-bg); color: var(--green); border-color: rgba(14,159,110,0.3);
}
.att-btn.present:hover, .att-btn.present.active {
  background: var(--green); color: #fff; border-color: var(--green);
}
.att-btn.absent {
  background: var(--red-bg); color: var(--red); border-color: rgba(224,36,36,0.3);
}
.att-btn.absent:hover, .att-btn.absent.active {
  background: var(--red); color: #fff; border-color: var(--red);
}
.att-btn.excused {
  background: var(--yellow-bg); color: var(--yellow); border-color: rgba(217,119,6,0.3);
}
.att-btn.excused:hover, .att-btn.excused.active {
  background: var(--yellow); color: #fff; border-color: var(--yellow);
}

/* ─── Student Row Card ─── */
.student-att-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px solid var(--border-color);
  margin-bottom: 8px; transition: all var(--transition);
}
.student-att-row:hover { border-color: rgba(26,86,219,0.3); }
.student-att-row.marked { opacity: 0.7; }
.sar-avatar {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1a56db, #0e9f6e);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.sar-info { flex: 1; min-width: 0; }
.sar-name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.sar-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; margin-top: 2px; }
.sar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sar-status { flex-shrink: 0; }

/* ─── Room Group Header ─── */
.room-group-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--border-color);
  margin-bottom: 10px; margin-top: 20px;
}
.room-group-header:first-child { margin-top: 0; }
.rgh-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px; font-weight: 700; color: var(--brand-primary);
}
.rgh-label { font-size: 13px; color: var(--text-muted); }
.rgh-count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  padding: 3px 10px; background: var(--blue-bg); color: #60a5fa;
  border-radius: 100px;
}

/* ─── Notification Item ─── */
.notif-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 20px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px solid var(--border-color);
  margin-bottom: 8px; transition: all var(--transition); cursor: pointer;
}
.notif-item:hover { border-color: rgba(26,86,219,0.3); }
.notif-item.unread { border-left: 3px solid var(--brand-primary); }
.notif-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 18px;
}
.notif-icon.warning { background: var(--yellow-bg); }
.notif-icon.info { background: var(--blue-bg); }
.notif-icon.alert { background: var(--red-bg); }
.notif-body { flex: 1; }
.notif-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.notif-message { font-size: 13px; color: var(--text-secondary); margin-top: 3px; line-height: 1.5; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.notif-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand-primary); flex-shrink: 0; margin-top: 6px;
}

/* ─── Chart Container ─── */
.chart-container {
  position: relative;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 24px;
}
.chart-title { font-size: 15px; font-weight: 700; margin-bottom: 20px; color: var(--text-primary); }

/* ─── Tabs ─── */
.tab-bar {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-surface); border-radius: var(--radius-md);
  border: 1px solid var(--border-color); margin-bottom: 24px;
  width: fit-content;
}
.tab-btn {
  padding: 8px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: all var(--transition); white-space: nowrap;
}
.tab-btn.active {
  background: var(--brand-primary); color: #fff;
  box-shadow: 0 2px 8px rgba(26,86,219,0.3);
}
.tab-btn:hover:not(.active) { color: var(--text-primary); background: var(--bg-card-hover); }

/* ─── View Header ─── */
.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 14px;
}
.view-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px; font-weight: 700; color: var(--text-primary);
}
.view-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 3px; }
.view-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

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

/* ─── Charts Grid ─── */
.charts-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
  margin-bottom: 24px;
}
.charts-grid-equal { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 900px) {
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats-grid-4, .stats-grid-3, .stats-grid-2 { grid-template-columns: 1fr 1fr; }
  .view-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .student-att-row { flex-wrap: wrap; }
}
