/* =========================================================
   Student Attendance System - Modern Responsive CSS
   ========================================================= */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --secondary-hover: #475569;
  
  /* Status Colors */
  --present: #10b981;
  --present-hover: #059669;
  --present-bg: #ecfdf5;
  --present-border: #a7f3d0;
  
  --absent: #ef4444;
  --absent-hover: #dc2626;
  --absent-bg: #fef2f2;
  --absent-border: #fecaca;
  
  --leave: #f59e0b;
  --leave-hover: #d97706;
  --leave-bg: #fffbeb;
  --leave-border: #fde68a;
  
  --late: #f97316;
  --late-hover: #ea580c;
  --late-bg: #fff7ed;
  --late-border: #fed7aa;
  
  --activity: #0284c7;
  --activity-hover: #0369a1;
  --activity-bg: #f0f9ff;
  --activity-border: #bae6fd;

  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 5rem;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ================= Navbar ================= */
.navbar {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #ffffff;
  padding: 0.85rem 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  background: rgba(255, 255, 255, 0.2);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  backdrop-filter: blur(4px);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

.brand-text .subtext {
  font-size: 0.8rem;
  opacity: 0.9;
  font-weight: 300;
}

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

/* ================= Tabs Navigation ================= */
.tabs-nav {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 66px;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.tab-buttons {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tab-buttons::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.85rem 1.15rem;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ================= Content Area & Tab Panes ================= */
.content-area {
  margin-top: 1.25rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

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

/* ================= Cards ================= */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

/* ================= Control & Filter Grids ================= */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  font-family: var(--font-family);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.date-input-group {
  display: flex;
  gap: 0.4rem;
}

.btn-cluster {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

/* ================= Buttons ================= */
.btn {
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #ffffff;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.btn-success {
  background: var(--present);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--present-hover);
}

.btn-info {
  background: #0284c7;
  color: #ffffff;
}

.btn-info:hover {
  background: #0369a1;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: #ffffff;
}

.btn-outline-success {
  background: transparent;
  color: var(--present);
  border-color: var(--present);
}

.btn-outline-success:hover {
  background: var(--present);
  color: #ffffff;
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-save {
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* ================= Notice Banner ================= */
.notice-banner {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.notice-banner.notice-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.notice-banner.notice-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* ================= Stat Cards Grid ================= */
.summary-cards-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.stat-total .stat-number { color: #3b82f6; }
.stat-present .stat-number { color: var(--present); }
.stat-absent .stat-number { color: var(--absent); }
.stat-leave .stat-number { color: var(--leave); }
.stat-late .stat-number { color: var(--late); }
.stat-activity .stat-number { color: var(--activity); }

/* ================= Search & Legend ================= */
.list-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-box i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  font-family: var(--font-family);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem 0.55rem 2.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  outline: none;
}

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

.legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.dot-present { background: var(--present); }
.dot-absent { background: var(--absent); }
.dot-leave { background: var(--leave); }
.dot-late { background: var(--late); }
.dot-activity { background: var(--activity); }

/* ================= Student Check-in List & Cards ================= */
.student-list-card {
  padding: 0.5rem;
}

.student-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.student-row {
  display: grid;
  grid-template-columns: 50px 100px 1fr auto 160px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  transition: all 0.15s ease;
}

.student-row:hover {
  background: #fbfcfe;
  border-color: #cbd5e1;
}

/* Status-specific row border indicator */
.student-row.status-present { border-left: 4px solid var(--present); background: var(--present-bg); }
.student-row.status-absent { border-left: 4px solid var(--absent); background: var(--absent-bg); }
.student-row.status-leave { border-left: 4px solid var(--leave); background: var(--leave-bg); }
.student-row.status-late { border-left: 4px solid var(--late); background: var(--late-bg); }
.student-row.status-activity { border-left: 4px solid var(--activity); background: var(--activity-bg); }

.student-no-badge {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f5f9;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.student-code {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.student-name-box {
  display: flex;
  flex-direction: column;
}

.student-fullname {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.student-room-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Status Selector Button Group */
.status-btn-group {
  display: flex;
  gap: 0.25rem;
}

.status-btn {
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.status-btn:hover {
  background: #f8fafc;
}

/* Active Status Button Styles */
.status-btn[data-status="present"].active {
  background: var(--present);
  border-color: var(--present);
  color: #ffffff;
  font-weight: 600;
}

.status-btn[data-status="absent"].active {
  background: var(--absent);
  border-color: var(--absent);
  color: #ffffff;
  font-weight: 600;
}

.status-btn[data-status="leave"].active {
  background: var(--leave);
  border-color: var(--leave);
  color: #ffffff;
  font-weight: 600;
}

.status-btn[data-status="late"].active {
  background: var(--late);
  border-color: var(--late);
  color: #ffffff;
  font-weight: 600;
}

.status-btn[data-status="activity"].active {
  background: var(--activity);
  border-color: var(--activity);
  color: #ffffff;
  font-weight: 600;
}

/* Remark Input */
.remark-input {
  font-family: var(--font-family);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  width: 100%;
}

.remark-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* ================= Tables ================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.data-table th, 
.data-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #f1f5f9;
}

.data-table.table-sm th,
.data-table.table-sm td {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
}

/* ================= Badges ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-present { background: var(--present-bg); color: #065f46; border: 1px solid var(--present-border); }
.badge-absent { background: var(--absent-bg); color: #991b1b; border: 1px solid var(--absent-border); }
.badge-leave { background: var(--leave-bg); color: #92400e; border: 1px solid var(--leave-border); }
.badge-late { background: var(--late-bg); color: #9a3412; border: 1px solid var(--late-border); }
.badge-activity { background: var(--activity-bg); color: #075985; border: 1px solid var(--activity-border); }

.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }

/* ================= Dashboard Big Metrics ================= */
.dashboard-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.metric-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.metric-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.metric-primary .metric-icon { background: #dbeafe; color: #2563eb; }
.metric-success .metric-icon { background: #d1fae5; color: #10b981; }
.metric-warning .metric-icon { background: #fef3c7; color: #d97706; }

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-title {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ================= Excel Dropzone & Preview ================= */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.dropzone-icon {
  font-size: 2.8rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.dropzone-text {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.file-input-hidden {
  display: none;
}

.excel-preview {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: #ffffff;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.preview-table-wrapper {
  max-height: 240px;
  overflow-y: auto;
}

.seed-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 1rem;
}

.seed-box h4 {
  font-size: 0.95rem;
  color: #166534;
  margin-bottom: 0.25rem;
}

.seed-box p {
  font-size: 0.82rem;
  color: #15803d;
  margin-bottom: 0.75rem;
}

.student-form .form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

/* ================= States & Utilities ================= */
.loading-state, .empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.loading-state p, .empty-state p {
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-3 { margin-bottom: 0.75rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.w-100 { width: 100%; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--absent); }

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.2s ease-out;
}

.toast-success { background: #065f46; border-left: 4px solid var(--present); }
.toast-error { background: #991b1b; border-left: 4px solid var(--absent); }
.toast-info { background: #1e40af; border-left: 4px solid #60a5fa; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Mobile FAB */
.mobile-save-fab {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
}

.btn-fab {
  border-radius: 9999px;
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

/* ================= Responsive Breakpoints ================= */
@media (max-width: 900px) {
  .grid-2-col {
    grid-template-columns: 1fr;
  }
  
  .summary-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }

  .mobile-save-fab {
    display: block;
  }

  .summary-cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .stat-card {
    padding: 0.5rem 0.25rem;
  }

  .stat-number {
    font-size: 1.25rem;
  }

  /* Compact Mobile Card for Student Check-in */
  .student-row {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.5rem 0.75rem;
    padding: 0.75rem;
  }

  .student-no-badge {
    grid-row: 1;
    grid-column: 1;
  }

  .student-name-box {
    grid-row: 1;
    grid-column: 2;
  }

  .status-btn-group {
    grid-row: 2;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.25rem;
  }

  .status-btn {
    padding: 0.5rem 0.2rem;
    font-size: 0.8rem;
    text-align: center;
  }

  .student-remark-box {
    grid-row: 3;
    grid-column: 1 / -1;
  }

  .student-code {
    display: inline-block;
    margin-left: 0.25rem;
  }
}

@media (max-width: 480px) {
  .tab-btn span {
    font-size: 0.85rem;
  }
  
  .tab-btn {
    padding: 0.65rem 0.75rem;
  }

  .summary-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
