/* ==========================================================================
   Rohtak Public School — Student Management System
   Visual identity: "the register" — navy ledger, brass rule lines,
   a Fraunces display face for headings, Inter for everything functional.
   ========================================================================== */

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

:root{
  --navy: #14213d;
  --navy-deep: #0c1526;
  --brass: #c9a24b;
  --brass-soft: #e4cd8f;
  --paper: #f7f4ec;
  --paper-line: #e4dfd0;
  --ink: #1b1b1f;
  --slate: #5b6472;
  --slate-soft: #8a90a0;
  --white: #ffffff;
  --red: #b3413a;
  --green: #3f7a5c;

  --radius: 4px;
  --shadow-card: 0 1px 2px rgba(20,33,61,0.06), 0 8px 24px rgba(20,33,61,0.06);
  --shadow-modal: 0 20px 60px rgba(12,21,38,0.35);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,.brand-word{
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin: 0;
}

a{ color: inherit; }

/* --------------------------------------------------------------------
   Ledger background texture — faint ruled lines, used on auth screen
   -------------------------------------------------------------------- */
.ledger-bg{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 24px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 37px,
      var(--paper-line) 37px,
      var(--paper-line) 38px
    ),
    var(--paper);
  position: relative;
}
.ledger-bg::before{
  content:"";
  position:absolute;
  top:0; bottom:0; left: 64px;
  width:1px;
  background: rgba(179,65,58,0.25);
}

/* --------------------------------------------------------------------
   Auth card
   -------------------------------------------------------------------- */
.auth-card{
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 40px 36px 32px;
  position: relative;
  z-index: 1;
}
.crest{
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--brass-soft);
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 20px;
  display:flex; align-items:center; justify-content:center;
  margin: 0 auto 18px;
  border: 2px solid var(--brass);
}
.auth-card h1{
  font-size: 26px;
  text-align: center;
}
.auth-sub{
  text-align: center;
  color: var(--slate);
  font-size: 13.5px;
  margin: 6px 0 28px;
}
.eyebrow{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass);
  font-weight: 700;
  text-align: center;
  display:block;
  margin-bottom: 6px;
}

.field{ margin-bottom: 16px; }
.field label{
  display:block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea{
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d6d2c4;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus{
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  background: var(--white);
}
.field-row{ display:flex; gap: 12px; }
.field-row .field{ flex:1; }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--navy); color: var(--white); width: 100%; }
.btn-primary:hover{ background: var(--navy-deep); }
.btn-brass{ background: var(--brass); color: var(--navy-deep); }
.btn-brass:hover{ background: var(--brass-soft); }
.btn-ghost{ background: transparent; color: var(--navy); border: 1px solid var(--paper-line); }
.btn-ghost:hover{ background: var(--paper); }
.btn-danger{ background: transparent; color: var(--red); border: 1px solid rgba(179,65,58,0.35); }
.btn-danger:hover{ background: rgba(179,65,58,0.08); }
.btn-sm{ padding: 6px 12px; font-size: 12.5px; }
.btn[disabled]{ opacity: .6; cursor: not-allowed; }

.switch-mode{
  text-align:center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--slate);
}
.switch-mode button{
  background:none; border:none; color: var(--navy);
  font-weight: 700; cursor:pointer; text-decoration: underline;
  font-family: inherit; font-size: 13px; padding: 0;
}

.form-msg{
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display:none;
}
.form-msg.show{ display:block; }
.form-msg.error{ background: rgba(179,65,58,0.08); color: var(--red); border: 1px solid rgba(179,65,58,0.25); }
.form-msg.success{ background: rgba(63,122,92,0.08); color: var(--green); border: 1px solid rgba(63,122,92,0.25); }

/* --------------------------------------------------------------------
   App shell (dashboard + students page)
   -------------------------------------------------------------------- */
.app-shell{ min-height: 100vh; display:flex; }

.sidebar{
  width: 220px;
  flex-shrink:0;
  background: var(--navy);
  color: var(--white);
  padding: 24px 18px;
  display:flex;
  flex-direction:column;
}
.sidebar .brand{
  display:flex; align-items:center; gap:10px;
  margin-bottom: 32px;
  padding: 0 6px;
}
.sidebar .crest{ width:34px; height:34px; font-size:14px; margin:0; }
.sidebar .brand-word{ color: var(--white); font-size: 15px; line-height:1.2; }
.sidebar .brand-word small{ display:block; color: var(--brass-soft); font-size:10px; letter-spacing:.08em; text-transform:uppercase; font-family:'Inter',sans-serif; font-weight:600; }

.nav-link{
  display:flex; align-items:center; gap:10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.75);
  text-decoration:none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.nav-link:hover{ background: rgba(255,255,255,0.06); color: var(--white); }
.nav-link.active{ background: rgba(201,162,75,0.15); color: var(--brass-soft); font-weight:600; }

.sidebar-footer{
  margin-top:auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.sidebar-footer .user-email{
  font-size: 11.5px;
  color: rgba(255,255,255,0.55);
  margin-bottom: 10px;
  word-break: break-all;
}

.main{ flex:1; min-width:0; }
.topbar{
  height: 64px;
  border-bottom: 1px solid var(--paper-line);
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 28px;
  background: var(--white);
}
.topbar h2{ font-size: 19px; }
.topbar .date-badge{
  font-size: 12.5px; color: var(--slate);
  font-weight:500;
}

.content{ padding: 28px; max-width: 1180px; }

/* stat cards */
.stat-grid{ display:grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap:16px; margin-bottom: 28px; }
.stat-card{
  background: var(--white);
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-num{
  font-family:'Fraunces',serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--navy);
  line-height:1;
}
.stat-card .stat-label{
  font-size: 12px;
  color: var(--slate);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}

.panel{
  background: var(--white);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.panel-head{
  padding: 16px 20px;
  border-bottom: 1px solid var(--paper-line);
  font-family:'Fraunces',serif;
  font-weight:600;
  color: var(--navy);
  font-size: 15.5px;
}

/* toolbar above students table */
.toolbar{
  display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between;
  margin-bottom: 16px;
}
.toolbar-filters{ display:flex; gap:10px; flex-wrap:wrap; flex:1; }
.toolbar-filters input, .toolbar-filters select{
  padding: 9px 12px;
  border: 1px solid #d6d2c4;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--white);
}
.toolbar-filters input[type="search"]{ min-width: 220px; }

/* ledger-style table */
.ledger-table{ width:100%; border-collapse: collapse; }
.ledger-table thead th{
  text-align:left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate);
  font-weight:700;
  padding: 12px 16px;
  border-bottom: 2px solid var(--navy);
  background: var(--paper);
}
.ledger-table tbody td{
  padding: 13px 16px;
  font-size: 13.8px;
  border-bottom: 1px solid var(--paper-line);
  color: var(--ink);
  vertical-align: middle;
}
.ledger-table tbody tr:hover{ background: rgba(201,162,75,0.06); }
.roll-badge{
  display:inline-block;
  font-family:'Fraunces',serif;
  font-weight:600;
  color: var(--navy);
  background: var(--paper);
  border:1px solid var(--paper-line);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 12.5px;
}
.class-pill{
  display:inline-block;
  font-size: 12px;
  font-weight:600;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(20,33,61,0.08);
  color: var(--navy);
}
.row-actions{ display:flex; gap:8px; }
.empty-row td{ text-align:center; color: var(--slate-soft); padding: 40px 16px; font-size:13.5px; }

/* modal */
.modal-overlay{
  position:fixed; inset:0;
  background: rgba(12,21,38,0.55);
  display:none;
  align-items:center; justify-content:center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.show{ display:flex; }
.modal{
  width:100%; max-width: 560px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  max-height: 90vh;
  overflow-y:auto;
}
.modal-head{
  padding: 20px 24px;
  border-bottom: 1px solid var(--paper-line);
  display:flex; align-items:center; justify-content:space-between;
}
.modal-head h3{ font-size: 18px; }
.modal-close{
  background:none; border:none; font-size: 20px; color: var(--slate);
  cursor:pointer; line-height:1; padding:4px;
}
.modal-body{ padding: 22px 24px; }
.modal-foot{
  padding: 16px 24px;
  border-top: 1px solid var(--paper-line);
  display:flex; justify-content:flex-end; gap:10px;
}

/* attendance status toggle */
.status-group{ display:inline-flex; border:1px solid #d6d2c4; border-radius: var(--radius); overflow:hidden; }
.status-btn{
  border:none; background: var(--white); color: var(--slate);
  font-family:inherit; font-size:12.5px; font-weight:600;
  padding: 7px 12px; cursor:pointer; border-right: 1px solid #d6d2c4;
}
.status-btn:last-child{ border-right:none; }
.status-btn:hover{ background: var(--paper); }
.status-btn.active[data-status="Present"]{ background: rgba(63,122,92,0.14); color: var(--green); }
.status-btn.active[data-status="Absent"]{ background: rgba(179,65,58,0.14); color: var(--red); }
.status-btn.active[data-status="Late"]{ background: rgba(201,162,75,0.22); color: #8a6d1f; }

.status-tag{ display:inline-block; font-size:11.5px; font-weight:700; padding:3px 9px; border-radius:20px; }
.status-tag.Present{ background: rgba(63,122,92,0.12); color: var(--green); }
.status-tag.Absent{ background: rgba(179,65,58,0.12); color: var(--red); }
.status-tag.Late{ background: rgba(201,162,75,0.22); color: #8a6d1f; }

.attendance-summary{
  display:flex; gap:18px; align-items:center;
  font-size: 13px; color: var(--slate);
  margin-bottom: 4px;
}
.attendance-summary strong{ color: var(--navy); }

.hint{ font-size:12px; color: var(--slate-soft); margin-top:4px; }
.loading-text{ color: var(--slate); font-size: 13.5px; padding: 20px; text-align:center; }

@media (max-width: 720px){
  .sidebar{ display:none; }
  .content{ padding: 18px; }
  .field-row{ flex-direction:column; gap:0; }
  .ledger-bg::before{ display:none; }
}
