@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =========================================================
   Modern SaaS Design System — Smart Attendance Tracker
   ========================================================= */

:root {
  /* Colors */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --primary: red;
  --primary-hover: #d90000;
  --primary-light: #e0e7ff;

  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #047857;

  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #b45309;

  --border-light: #e2e8f0;
  --border-focus: rgba(79, 70, 229, 0.3);

  /* Shadows & Radii */
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* =========================================================
   RESET & BASE UTILITIES
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Micro-animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-in {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* =========================================================
   TYPOGRAPHY
   ========================================================= */
h1,
h2,
h3 {
  font-weight: 600;
  color: var(--text-main);
}

p {
  color: var(--text-muted);
  line-height: 1.5;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  outline: none;
  white-space: nowrap;
}

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

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

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

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
  border-color: var(--border-light);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

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

.btn-danger-outline:hover:not(:disabled) {
  background-color: var(--danger-bg);
}

.btn-full {
  width: 100%;
}

/* =========================================================
   FORMS
   ========================================================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

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

.form-group input {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 10px 14px;
  transition: all 0.2s ease;
}

.form-group input::placeholder {
  color: var(--text-light);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

/* =========================================================
   SPINNER & TOASTS
   ========================================================= */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-float);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  min-width: 250px;
  border-left: 4px solid transparent;
}

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

.toast.success .icon {
  color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.error .icon {
  color: var(--danger);
}

/* Standard fallback block alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid rgba(16, 185, 129, 0.2);
}


/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: var(--bg-app);
  background-image: radial-gradient(circle at top right, var(--primary-light), transparent 40%),
    radial-gradient(circle at bottom left, #fce7f3, transparent 40%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  text-align: center;
}

.login-logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  box-shadow: 0 4px 12px var(--border-focus);
}

.login-title {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 30px;
}

.login-form {
  text-align: left;
}

.login-hint {
  margin-top: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-hint code {
  background: var(--bg-app);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* =========================================================
   DASHBOARD - SIDEBAR LAYOUT
   ========================================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background-color: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.sidebar-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
}

.sidebar-nav {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background-color: var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.class-card {
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.class-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.class-card h3 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
  flex: 1;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 40px;
}

.page-header {
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 700;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Tab Panes */
.tab-pane {
  display: none;
}

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

/* Cards Layout */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
}

/* =========================================================
   MOBILE HEADER & BACKDROP OVERLAY
   ========================================================= */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 60px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
  background-color: var(--bg-surface-hover);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================= */

/* Tablet viewports: Sidebar collapses to icon strip */
@media (max-width: 900px) and (min-width: 769px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 70px;
  }

  .sidebar-title,
  .nav-item span,
  .user-name {
    display: none;
  }

  .main-content {
    margin-left: 70px;
    padding: 24px;
  }
}

/* Mobile viewports: Sliding Drawer Sidebar & Header Stacking */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: var(--shadow-float);
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Force details to display inside mobile drawer menu */
  .sidebar-title,
  .user-name {
    display: block !important;
  }

  .nav-item span {
    display: inline !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 16px !important;
  }

  .mobile-header {
    display: flex;
    margin: -16px -16px 20px -16px; /* offset main-content padding */
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
  }

  .page-header > div {
    width: 100%;
  }

  .page-header .form-group {
    width: 100%;
    margin-bottom: 0;
    align-items: stretch;
  }

  .page-header input[type="date"] {
    width: 100%;
  }

  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }

  .summary-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  /* Table styling enhancements on mobile */
  .card.table-responsive {
    padding: 16px !important;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  .data-table th, 
  .data-table td {
    padding: 12px 10px;
    font-size: 0.825rem;
  }

  .student-info {
    gap: 8px;
  }

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .att-label {
    padding: 5px 8px;
    font-size: 0.775rem;
  }

  /* Toast position */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
  
  .toast {
    min-width: auto;
    width: 100%;
  }
}

/* Small mobile devices padding adjustment */
@media (max-width: 480px) {
  .login-layout {
    padding: 16px;
  }

  .login-card {
    padding: 28px 20px;
    border-radius: var(--radius-md);
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* =========================================================
   STUDENT LIST
   ========================================================= */
.student-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.student-list::-webkit-scrollbar {
  width: 6px;
}

.student-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  transition: all 0.2s ease;
}

.student-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--primary-light);
}

.student-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.student-name {
  font-weight: 500;
  font-size: 0.95rem;
}

/* =========================================================
   TABLES & ATTENDANCE GRID
   ========================================================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-surface-hover);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

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

/* Radio Buttons for Attendance */
.att-radio {
  display: none;
}

.att-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-muted);
}

.att-label:hover {
  border-color: var(--text-light);
}

.att-radio.att-present:checked+.att-label {
  background-color: var(--success-bg);
  border-color: var(--success);
  color: var(--success-text);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.att-radio.att-absent:checked+.att-label {
  background-color: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-text);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

/* Row highlights */
.att-row-present {
  background-color: rgba(16, 185, 129, 0.03);
}

.att-row-absent {
  background-color: rgba(239, 68, 68, 0.03);
}

/* Summary Cards (Report) */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.stat-card.primary {
  border-top: 4px solid var(--primary);
}

.stat-card.success {
  border-top: 4px solid var(--success);
}

.stat-card.danger {
  border-top: 4px solid var(--danger);
}

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

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}

/* Status Pills */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.pill-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.pill-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

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

.mb-4 {
  margin-bottom: 16px;
}

.mt-4 {
  margin-top: 16px;
}

.flex {
  display: flex;
}

.gap-2 {
  gap: 8px;
}