/* ==========================================================================
   1. BASE & RESET + OVERFLOW PROTECTION
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;                    /* 1rem = 16px – good accessibility base */
  scroll-behavior: smooth;
}

body {
  font-family: 'Georgia', 'Times New Roman', Times, serif;
  background: #f9faf7;
  color: #2f2f2f;
  line-height: 1.68;
  min-height: 100vh;
  overflow-x: hidden;                 /* Prevent unwanted horizontal scroll */
}

/* ==========================================================================
   2. TYPOGRAPHY
   ========================================================================== */
h1, h2, h3 {
  color: #1a3c34;
  font-weight: 500;
  letter-spacing: -0.015em;
}

h1 { font-size: clamp(1.9rem, 5.5vw, 2.6rem); margin-bottom: 1.2rem; }
h2 { font-size: clamp(1.6rem, 4.8vw, 2.1rem); margin-bottom: 1rem;  }
h3 { font-size: clamp(1.3rem, 4vw, 1.6rem);  margin-bottom: 0.9rem; }

p, li {
  margin-bottom: 1rem;
}

a {
  color: #2e7d32;
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover,
a:focus {
  color: #1b5e20;
  text-decoration: underline;
}

/* ==========================================================================
   3. LAYOUT & CONTAINERS
   ========================================================================== */
.container {
  max-width: 1140px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2.2rem 0 1.6rem;
  border-bottom: 1px solid #d4e0d9;
  flex-wrap: wrap;
  gap: 1.2rem;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 2rem 0 2.8rem;
  justify-content: flex-start;
}

.section {
  margin: 3.5rem 0;
}

.section h2 {
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #d4e0d9;
}

/* ==========================================================================
   4. BUTTONS – Elegant & Classic
   ========================================================================== */
.elegant-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.78rem 1.65rem;
  font-family: inherit;
  font-size: 1.03rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.22s ease;
  letter-spacing: 0.015em;
  border: none;
}

.elegant-btn:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.11);
}

.elegant-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3.5px rgba(46,125,50,0.22);
}

.elegant-btn.back {
  background: #f8f9f6;
  color: #1a3c34;
  border: 1px solid #c8d6cf;
  padding: 0.7rem 1.5rem;
}

.elegant-btn.back:hover {
  background: #e8f0ed;
}

.elegant-btn.logout {
  background: linear-gradient(135deg, #c62828 0%, #b71c1c 100%);
  color: white;
  padding: 0.7rem 1.5rem;
}

.elegant-btn.primary {
  background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
  color: white;
}

.elegant-btn.accent {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
  color: white;
}

.elegant-btn.secondary {
  background: #f8f9f6;
  color: #1a3c34;
  border: 1px solid #c8d6cf;
}

.elegant-btn.secondary:hover {
  background: #e8f0ed;
}

.elegant-btn.danger {
  background: linear-gradient(135deg, #c62828 0%, #b71c1c 100%);
  color: white;
}

.elegant-btn.detail {
  background: linear-gradient(135deg, #4a148c 0%, #311b92 100%);
  color: white;
}

.elegant-btn.small {
  padding: 0.55rem 1.15rem;
  font-size: 0.96rem;
}

.elegant-btn.large {
  padding: 1rem 2.1rem;
  font-size: 1.16rem;
}

/* ==========================================================================
   5. NAVIGATION & HEADER ELEMENTS
   ========================================================================== */
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.trial-info-container {
  background: #fff8e1;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0 2.5rem;
  text-align: center;
  border-left: 5px solid #ffb300;
}

.trial-info {
  font-size: 1.05rem;
  color: #5d4037;
}

.countdown {
  color: #c62828;
  font-weight: 600;
  margin: 0 0.6rem;
}

/* ==========================================================================
   6. FORMS & INPUTS
   ========================================================================== */
.form-group,
.form-row,
.form-classic {
  margin-bottom: 1.6rem;
}

.form-classic {
  max-width: 720px;
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 3px 16px rgba(0,0,0,0.06);
  border: 1px solid #e0e8e4;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #1a3c34;
  font-size: 1.03rem;
}

input,
textarea {
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: 1px solid #c1d4cc;
  border-radius: 7px;
  font-size: 1.02rem;
  background: #fdfefd;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 3.5px rgba(46,125,50,0.14);
}

.required {
  color: #c62828;
  font-weight: bold;
}

/* ==========================================================================
   7. TABLES
   ========================================================================== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 9px;
  box-shadow: 0 3px 16px rgba(0,0,0,0.07);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 9px;
  overflow: hidden;
  table-layout: auto;
}

th, td {
  padding: 1.05rem 1.2rem;
  text-align: left;
  border-bottom: 1px solid #e0e8e4;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  background: #e8f0ed;
  color: #1a3c34;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.91rem;
  letter-spacing: 0.035em;
  white-space: nowrap;
}

/* Mobile scrollable table */
@media (max-width: 768px) {
  .table-wrapper {
    margin: 0 -1rem;
  }
  table {
    display: block;
    overflow-x: auto;
  }
}

/* ==========================================================================
   8. CARDS & GRIDS
   ========================================================================== */
.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.6rem;
  margin-bottom: 2.8rem;
}

.card {
  background: white;
  border-radius: 10px;
  padding: 1.6rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.07);
  border-left: 5px solid;
  overflow: hidden;
}

.attendance-card  { border-left-color: #2e7d32; }
.assignments-card { border-left-color: #1565c0; }

/* ==========================================================================
   9. MESSAGES & STATES
   ========================================================================== */
.success-msg,
.error {
  padding: 1.2rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  border-left: 5px solid;
}

.success-msg {
  background: #e8f5e9;
  color: #1b5e20;
  border-left-color: #2e7d32;
}

.error {
  background: #ffebee;
  color: #c62828;
  border-left-color: #c62828;
}

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  background: #f9fafb;
  border-radius: 10px;
  color: #5d7a70;
  font-size: 1.15rem;
  margin: 2rem 0;
}

/* ==========================================================================
   10. FOOTER
   ========================================================================== */
.footer {
  margin-top: 5rem;
  padding: 2rem 0;
  text-align: center;
  color: #6b7c74;
  font-size: 0.95rem;
  border-top: 1px solid #e0e8e4;
}

/* ==========================================================================
   11. RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 480px) {
  .container,
  .page-header,
  .action-bar,
  .overview-cards,
  .content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  h1 { font-size: 2rem; }

  .action-bar {
    flex-direction: column;
    gap: 0.9rem;
  }

  .action-bar .elegant-btn {
    width: 100%;
  }

  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .overview-cards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1025px) {
  .container {
    max-width: 1200px;
  }
}

/* ==========================================================================
   12. CENTERED FORMS (login / register)
   ========================================================================== */
.login-container,
.register-container {
  background: white;
  max-width: 460px;
  margin: 4rem auto;
  padding: 2.8rem 2.2rem;
  border-radius: 10px;
  box-shadow: 0 10px 38px rgba(0,0,0,0.11);
  border: 1px solid #e0e6e2;
}

@media (max-width: 480px) {
  .login-container,
  .register-container {
    margin: 2rem 1.2rem;
    padding: 2.2rem 1.8rem;
  }
}

/* ==========================================================================
   ATTENDANCE PAGE SPECIFIC
   ========================================================================== */
.attendance-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0 3rem;
}

.student-card {
  background: white;
  border: 1px solid #e0e8e4;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: all 0.18s ease;
}

.student-card:hover {
  box-shadow: 0 5px 20px rgba(0,0,0,0.09);
  transform: translateY(-2px);
}

.student-name {
  font-size: 1.18rem;
  color: #1a3c34;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.student-class {
  color: #5d7a70;
  font-size: 0.98rem;
  margin-bottom: 1.2rem;
}

.radio-group {
  display: flex;
  gap: 2.2rem;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 1.02rem;
  color: #2f2f2f;
}

.radio-group input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #2e7d32;
}

.form-actions {
  margin: 2.8rem 0 1rem;
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.summary-section {
  margin-top: 3.5rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 16px rgba(0,0,0,0.07);
}

.summary-table th,
.summary-table td {
  padding: 1rem 1.2rem;
  text-align: center;
  border-bottom: 1px solid #e0e8e4;
}

.summary-table th {
  background: #e8f0ed;
  color: #1a3c34;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
}

.student-name-col {
  text-align: left;
  font-weight: 500;
}

.stat-center {
  text-align: center;
}

.stat-bold {
  font-weight: 600;
}

.attendance-good    { background: #e8f5e9; color: #1b5e20; }
.attendance-warning { background: #fff3e0; color: #e65100; }
.attendance-poor    { background: #ffebee; color: #c62828; }

/* ==========================================================================
   ADD / EDIT STUDENT FORM
   ========================================================================== */
.form-classic {
  max-width: 680px;
  background: white;
  padding: 2.2rem;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.07);
  border: 1px solid #e0e8e4;
  margin: 2rem auto;
}

.form-row {
  margin-bottom: 1.8rem;
}

.form-row label {
  display: block;
  margin-bottom: 0.55rem;
  font-weight: 500;
  color: #1a3c34;
  font-size: 1.04rem;
}

.form-row input {
  width: 100%;
  padding: 0.9rem 1.1rem;
  font-size: 1.03rem;
}

/* ==========================================================================
   FORM ACTIONS (Save + Cancel)
   ========================================================================== */
.form-actions {
  margin-top: 2.5rem;
  display: flex;
  gap: 1.3rem;
  flex-wrap: wrap;
}

.form-actions .elegant-btn {
  min-width: 160px;
}

/* ==========================================================================
   REQUIRED FIELD INDICATOR
   ========================================================================== */
.required {
  color: #c62828;
  font-weight: bold;
  margin-left: 0.3rem;
}

/* ==========================================================================
   BULK MARKS ENTRY PAGE
   ========================================================================== */
.assignment-info-box {
  background: #e8f0ed;
  padding: 1.4rem 1.8rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  border-left: 5px solid #2e7d32;
}

.assignment-info-box p {
  margin: 0.4rem 0;
  font-size: 1.03rem;
}

.points-wrapper {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.points-wrapper input {
  width: 110px;
  text-align: center;
}

.points-max {
  color: #5d7a70;
  font-weight: 500;
}

.student-name-col {
  font-weight: 500;
  text-align: left;
}

/* ==========================================================================
   ACTION BAR – IMPROVED RESPONSIVENESS
   ========================================================================== */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 2rem 0 2.8rem;
  justify-content: center;           /* center on all screens */
}

.action-bar .elegant-btn {
  flex: 1 1 220px;                   /* grow but don't shrink too much */
  min-width: 200px;                  /* minimum touch-friendly size */
  max-width: 320px;                  /* prevent too wide on desktop */
  text-align: center;
}

/* Mobile – full width, stacked, larger touch targets */
@media (max-width: 640px) {
  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
  }

  .action-bar .elegant-btn {
    flex: 1 1 auto;
    min-width: unset;
    width: 100%;
    padding: 0.95rem 1.4rem;        /* larger touch area */
    font-size: 1.05rem;
  }
}

/* Tablet – 2 columns when possible */
@media (min-width: 641px) and (max-width: 1024px) {
  .action-bar {
    justify-content: center;
  }

  .action-bar .elegant-btn {
    flex-basis: calc(50% - 0.5rem);
  }
}

/* Desktop – single row, nicely spaced */
@media (min-width: 1025px) {
  .action-bar {
    justify-content: flex-start;
    gap: 1.2rem;
  }

  .action-bar .elegant-btn {
    flex: 0 1 auto;
    min-width: 180px;
  }
}