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

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --success-color: #059669;
  --danger-color: #dc2626;
  --warning-color: #d97706;
  --background: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px 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);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* MAIN CONTENT */
.app-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  overflow-y: auto;
}

.section {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.section.active {
  display: block;
}

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

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

.section-header h2 {
  font-size: 1.875rem;
  font-weight: 700;
}

.back-btn {
  padding: 0.5rem 1rem;
  background: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

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

/* DASHBOARD */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dashboard-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.dashboard-card h3 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.recent-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.recent-section h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.recent-list {
  max-height: 300px;
  overflow-y: auto;
}

.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.recent-item:hover {
  background: var(--background);
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-info h4 {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.recent-info p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.recent-stats {
  text-align: right;
  font-size: 0.875rem;
}

.quick-actions {
  text-align: center;
}

/* FORMS */
.form-container {
  max-width: 800px;
  margin: 0 auto;
}

.form-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.form-section h3 {
  margin-bottom: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

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

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

.form-group label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

input,
select,
textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* BUTTONS */
.primary-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.large-btn {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* TABS */
.input-tabs {
  display: flex;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

.input-tab {
  display: none;
}

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

/* STUDENTS */
.students-preview {
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.student-preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--background);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.student-preview-item:last-child {
  margin-bottom: 0;
}

.remove-student-btn {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
}

/* ATTENDANCE */
.attendance-info {
  background: var(--surface);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.attendance-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  padding: 1rem;
  border-radius: 0.5rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-card.present .stat-number {
  color: var(--success-color);
}
.stat-card.absent .stat-number {
  color: var(--danger-color);
}
.stat-card.total .stat-number {
  color: var(--primary-color);
}

.attendance-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.bulk-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.present-bulk {
  background: var(--success-color);
  color: white;
}

.absent-bulk {
  background: var(--danger-color);
  color: white;
}

.reset-bulk {
  background: var(--secondary-color);
  color: white;
}

.students-container {
  background: var(--surface);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.student-attendance-card {
  background: var(--background);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  transition: all 0.2s;
}

.student-attendance-card.present {
  background: #dcfce7;
  border-color: var(--success-color);
}

.student-attendance-card.absent {
  background: #fef2f2;
  border-color: var(--danger-color);
}

.student-name {
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-align: center;
}

.student-actions {
  display: flex;
  gap: 0.5rem;
}

.attendance-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

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

.absent-btn {
  background: var(--danger-color);
  color: white;
}

.attendance-btn:hover {
  transform: scale(1.05);
}

/* HISTORY */
.history-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.history-filters select,
.history-filters input {
  min-width: 200px;
}

.history-container {
  max-height: 70vh;
  overflow-y: auto;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.history-title {
  font-weight: 600;
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
}

.history-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.history-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
}

.history-stat {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-weight: 500;
}

.history-stat.present {
  background: #dcfce7;
  color: var(--success-color);
}

.history-stat.absent {
  background: #fef2f2;
  color: var(--danger-color);
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
  background: var(--surface);
  margin: 5% auto;
  border-radius: 0.75rem;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 1.5rem;
  max-height: 50vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* MESSAGES */
.message-container {
  position: fixed;
  top: 80px;
  right: 1rem;
  z-index: 1000;
  max-width: 400px;
}

.message {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease-in-out;
}

.message.success {
  background: #dcfce7;
  color: var(--success-color);
  border: 1px solid #bbf7d0;
}

.message.error {
  background: #fef2f2;
  color: var(--danger-color);
  border: 1px solid #fecaca;
}

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

/* UTILITIES */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mb-4 {
  margin-bottom: 1rem;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .app-main {
    padding: 1rem;
  }

  .header-content {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .header-content h1 {
    font-size: 1.25rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .students-grid {
    grid-template-columns: 1fr;
  }

  .attendance-controls {
    flex-direction: column;
  }

  .bulk-btn {
    width: 100%;
  }

  .modal-content {
    margin: 10% auto;
    width: 95%;
  }

  .modal-actions {
    flex-direction: column;
  }

  .history-filters {
    flex-direction: column;
  }

  .history-filters select,
  .history-filters input {
    min-width: auto;
    width: 100%;
  }

  .message-container {
    right: 0.5rem;
    left: 0.5rem;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .header-actions {
    width: 100%;
    justify-content: space-around;
  }

  .nav-btn {
    flex: 1;
    text-align: center;
  }

  .students-container {
    max-height: 50vh;
  }

  .form-section {
    padding: 1rem;
  }
}
