/* Smart Attendance System - Minimalist & Clean Design System */

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  
  --status-present: #16a34a;
  --status-present-bg: #dcfce7;
  --status-late: #d97706;
  --status-late-bg: #fef3c7;
  --status-absent: #dc2626;
  --status-absent-bg: #fee2e2;
  --status-excused: #2563eb;
  --status-excused-bg: #dbeafe;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 10px;
  --radius-md: 6px;
}

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

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 2rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
}

.brand span.logo-icon {
  background: var(--text-main);
  color: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-main);
}

/* Container */
.container {
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* Grid & Cards */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

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

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

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

.btn-secondary:hover {
  background: #f1f5f9;
}

.btn-danger {
  background: var(--status-absent);
  color: #ffffff;
}

.btn-danger:hover {
  background: #b91c1c;
}

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

.badge-present {
  background: var(--status-present-bg);
  color: var(--status-present);
}

.badge-late {
  background: var(--status-late-bg);
  color: var(--status-late);
}

.badge-absent {
  background: var(--status-absent-bg);
  color: var(--status-absent);
}

.badge-excused {
  background: var(--status-excused-bg);
  color: var(--status-excused);
}

.badge-open {
  background: var(--status-present-bg);
  color: var(--status-present);
}

.badge-closed {
  background: #f1f5f9;
  color: var(--text-muted);
}

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

table.data-table th, table.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

table.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f8fafc;
}

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

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Scanner Box */
.scanner-box {
  background: #ffffff;
  border: 2px dashed var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-align: center;
  margin-bottom: 1.75rem;
}

.scan-input-lg {
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 0.03em;
  padding: 0.75rem;
  border-radius: var(--radius-md);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  background: #0f172a;
  border-left: 4px solid var(--accent-primary);
  color: #ffffff;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.nav-logout {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.login-panel {
  max-width: 420px;
  margin: 8vh auto 0;
}

.login-submit {
  width: 100%;
}

.login-error {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--status-absent-bg);
  color: var(--status-absent);
}

@media (max-width: 700px) {
  .navbar {
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .brand {
    font-size: 1rem;
    white-space: nowrap;
  }

  .nav-links {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .nav-links a:not(.btn) {
    display: none;
  }

  .container {
    padding: 1.25rem 1rem;
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .card, .scanner-box {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.55rem;
  }

  .btn {
    min-height: 44px;
    justify-content: center;
  }

  #toast-container {
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  .scan-input-lg {
    font-size: 1rem;
  }
}

/* Print view override */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .navbar, .btn {
    display: none !important;
  }
  .print-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 15px !important;
  }
  .qr-card-print {
    border: 2px solid #000 !important;
    padding: 15px !important;
    text-align: center !important;
    page-break-inside: avoid;
  }
}
