/* ===== Moura Lacerda — Portal do Aluno ===== */
:root {
  --bordeaux: #7a1f2b;
  --bordeaux-dark: #5e1620;
  --bordeaux-light: #9a3341;
  --yellow: #f4c430;
  --yellow-soft: #fdf3d3;
  --navy: #16223c;
  --navy-soft: #24345a;
  --green: #1f9d55;
  --green-soft: #e4f6ec;
  --blue: #2563c9;
  --blue-soft: #e6effb;
  --amber: #b7791f;
  --amber-soft: #fbf0d6;
  --white: #ffffff;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #1e2433;
  --text-muted: #6b7280;
  --border: #e7e9ef;
  --shadow: 0 1px 2px rgba(22, 34, 60, .06), 0 6px 18px rgba(22, 34, 60, .06);
  --shadow-lg: 0 10px 40px rgba(22, 34, 60, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 250px;
  --header-h: 60px;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bordeaux) 0%, var(--bordeaux-dark) 100%);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform .28s ease;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-logo {
  width: 42px; height: 42px; flex: none;
  border-radius: 11px;
  background: var(--yellow);
  color: var(--bordeaux-dark);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  letter-spacing: -1px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
.brand-text b { display: block; font-size: 15px; line-height: 1.15; }
.brand-text span { font-size: 11px; opacity: .8; letter-spacing: .5px; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.82);
  font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a .ic { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active {
  background: #fff; color: var(--bordeaux);
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.nav a.active .ic { color: var(--bordeaux); }
.sidebar-foot {
  padding: 14px 18px;
  font-size: 11px; opacity: .7;
  border-top: 1px solid rgba(255,255,255,.12);
}
.sidebar-foot a { text-decoration: underline; }

/* ===== Main ===== */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 40;
}
.header h1 { font-size: 17px; margin: 0; font-weight: 700; }
.header .spacer { flex: 1; }
.burger {
  display: none;
  background: none; border: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer; color: var(--bordeaux);
  align-items: center; justify-content: center;
}
.burger:hover { background: var(--bg); }
.header-user {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 6px 5px 12px;
  background: var(--bg);
  border-radius: 999px;
}
.header-user .u-name { font-size: 13px; font-weight: 600; }
.header-user .u-sub { font-size: 11px; color: var(--text-muted); }
.header-user .avatar { width: 34px; height: 34px; font-size: 13px; }

/* ===== Content ===== */
.content { padding: 22px; max-width: 1080px; width: 100%; }
.page-head { margin-bottom: 18px; }
.page-head h2 { margin: 0 0 2px; font-size: 22px; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 13px; }

/* ===== Avatar ===== */
.avatar {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bordeaux) 0%, var(--bordeaux-light) 100%);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}
.avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  border-radius: 50%; display: block;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* Hero / student summary */
.hero {
  background: linear-gradient(120deg, var(--bordeaux) 0%, var(--bordeaux-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
  display: flex; align-items: center; gap: 18px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(244,196,48,.18);
}
.hero .avatar {
  width: 72px; height: 72px; font-size: 26px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.5);
}
.hero-info { z-index: 1; }
.hero-info h2 { margin: 0 0 4px; font-size: 22px; }
.hero-info p { margin: 0; opacity: .9; font-size: 13px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px;
  background: rgba(255,255,255,.15);
  padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.hero-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }

/* Stat cards */
.stat {
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.stat .stat-ic {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; margin-bottom: 4px;
}
.stat .stat-ic.b1 { background: var(--yellow-soft); color: var(--amber); }
.stat .stat-ic.b2 { background: var(--green-soft); color: var(--green); }
.stat .stat-ic.b3 { background: var(--blue-soft); color: var(--blue); }
.stat .stat-ic.b4 { background: var(--bordeaux); color: #fff; opacity:.92; }
.stat .stat-val { font-size: 26px; font-weight: 800; line-height: 1; color: var(--navy); }
.stat .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; color: var(--navy); }

/* Info list */
.info-list { display: grid; gap: 0; }
.info-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text-muted); }
.info-row .v { font-weight: 600; text-align: right; }

/* Notices */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  background: var(--white);
}
.notice:last-child { margin-bottom: 0; }
.notice .n-ic { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.notice.info .n-ic { background: var(--blue-soft); color: var(--blue); }
.notice.success .n-ic { background: var(--green-soft); color: var(--green); }
.notice b { display: block; font-size: 14px; }
.notice p { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
.notice .n-date { font-size: 11px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.gray { background: #eef0f4; color: var(--text-muted); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; }
table.data thead th {
  background: var(--navy); color: #fff;
  font-size: 12px; font-weight: 600; letter-spacing: .3px;
  white-space: nowrap;
}
table.data thead th:first-child { border-top-left-radius: var(--radius); }
table.data thead th:last-child { border-top-right-radius: var(--radius); }
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:nth-child(even) { background: #fafbfc; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data .strike { color: var(--text-muted); text-decoration: line-through; font-size: 12px; }

/* ===== Progress ===== */
.progress { height: 8px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--bordeaux), var(--bordeaux-light)); border-radius: 999px; }

/* ===== Subject cards ===== */
.subject-card { display: flex; flex-direction: column; gap: 12px; }
.subject-card .s-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.subject-card .s-code { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: .5px; }
.subject-card h3 { margin: 2px 0 0; font-size: 16px; }
.subject-card .s-teacher { font-size: 13px; color: var(--text-muted); }
.subject-card .s-meta { display: flex; gap: 18px; flex-wrap: wrap; }
.subject-card .s-meta .m-val { font-size: 18px; font-weight: 700; color: var(--navy); }
.subject-card .s-meta .m-lbl { font-size: 11px; color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; background: var(--bordeaux); color: #fff;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--white); color: var(--bordeaux); border-color: var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.green { background: var(--green); }
.btn.navy { background: var(--navy); }
.btn.block { width: 100%; }

/* ===== Carteirinha / cartão digital ===== */
.idcard-wrap { max-width: 400px; margin: 0 auto; width: 100%; }
.idcard {
  border-radius: 22px;
  background: linear-gradient(155deg, #8a2331 0%, #5e1620 55%, #16223c 135%);
  color: #fff;
  padding: 22px 20px;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.idcard::before {
  content: ""; position: absolute; right: -70px; top: -70px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(244,196,48,.14);
}
.idcard::after {
  content: ""; position: absolute; left: -50px; bottom: -80px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.idcard > * { position: relative; z-index: 1; }

/* Topo: logo + tipo do cartão */
.idcard-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 20px;
}
.idcard-brand { display: flex; align-items: center; gap: 10px; }
.idcard-brand .brand-logo { width: 36px; height: 36px; font-size: 14px; border-radius: 10px; }
.idcard-brand .t small {
  display: block; font-size: 9px; letter-spacing: 1.5px;
  text-transform: uppercase; opacity: .8;
}
.idcard-brand .t b { font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.idcard-type {
  font-size: 9px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  background: var(--yellow); color: var(--bordeaux-dark);
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}

/* Corpo: foto + nome */
.idcard-main { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.idcard-photo {
  width: 78px; height: 98px; border-radius: 14px; flex: none;
  background: rgba(255,255,255,.14);
  overflow: hidden; position: relative;
  border: 2px solid rgba(255,255,255,.45);
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700;
}
.idcard-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.idcard-id { min-width: 0; }
.idcard-id h3 { margin: 0 0 3px; font-size: 19px; line-height: 1.2; }
.idcard-id .course { font-size: 13px; opacity: .9; }
.idcard-reg {
  display: inline-block; margin-top: 9px;
  font-size: 12px; font-weight: 600; letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.14);
  padding: 4px 11px; border-radius: 8px;
}

/* Campos */
.idcard-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px;
  padding-top: 16px; border-top: 1px solid rgba(255,255,255,.18);
}
.idcard-field .l {
  font-size: 9px; text-transform: uppercase; letter-spacing: .8px; opacity: .7;
  margin-bottom: 2px;
}
.idcard-field .v { font-size: 13px; font-weight: 600; }

/* Rodapé: status + chip decorativo */
.idcard-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.18);
}
.idcard-status {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(31,157,85,.28); color: #bff2d3;
  padding: 5px 13px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.idcard-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #37d982; }
.idcard-chip {
  width: 46px; height: 34px; border-radius: 7px; position: relative;
  background: linear-gradient(135deg, #f7d979 0%, #e0a92f 100%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.idcard-chip::before, .idcard-chip::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 1px;
  background: rgba(94,22,32,.45);
}
.idcard-chip::before { top: 12px; }
.idcard-chip::after { top: 21px; }
.idcard-note {
  margin-top: 14px; font-size: 11px; color: var(--text-muted);
  text-align: center; font-style: italic;
}

@media (max-width: 380px) {
  .idcard-main { gap: 12px; }
  .idcard-id h3 { font-size: 17px; }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22,34,60,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius);
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  background: var(--bordeaux); color: #fff;
  padding: 16px 20px; display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head button { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; }

/* ===== Alerts ===== */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; margin-bottom: 16px;
}
.alert.success { background: var(--green-soft); color: var(--green); border: 1px solid #bfe6cd; }
.alert.error { background: #fdecec; color: #c0392b; border: 1px solid #f5c6c6; }
.alert.info { background: var(--blue-soft); color: var(--blue); border: 1px solid #c9ddf6; }

.demo-banner {
  background: var(--yellow-soft); color: var(--amber);
  border: 1px solid #f0dfa8;
  text-align: center; font-size: 12px; font-weight: 600;
  padding: 8px 14px;
}

/* ===== Forms (admin) ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--navy); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--bordeaux);
  box-shadow: 0 0 0 3px rgba(122,31,43,.12);
}
.field textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }
.field .hint { font-size: 11px; color: var(--text-muted); }
fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 0 0 20px;
}
fieldset legend { font-weight: 700; color: var(--bordeaux); padding: 0 8px; font-size: 15px; }

.photo-preview {
  width: 90px; height: 90px; border-radius: 12px; overflow: hidden;
  background: var(--bg); border: 1px dashed var(--border);
  display: grid; place-items: center; color: var(--text-muted); font-size: 12px;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ===== Login (admin) ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, var(--bordeaux) 0%, var(--navy) 100%); }
.login-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px; padding: 32px; }
.login-card .brand { border: none; justify-content: center; padding: 0 0 20px; }
.login-card h2 { text-align: center; margin: 0 0 4px; font-size: 20px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 16px; }

/* Admin topbar */
.admin-top {
  background: var(--bordeaux); color: #fff;
  padding: 14px 22px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 40;
}
.admin-top .brand-logo { width: 36px; height: 36px; font-size: 15px; }
.admin-top b { font-size: 15px; }
.admin-top .spacer { flex: 1; }
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }

/* ===== Overlay for mobile menu ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(22,34,60,.5);
  z-index: 45; display: none;
}
.overlay.show { display: block; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .burger { display: flex; }
  .header-user .u-info { display: none; }
  .content { padding: 16px; }
  .hero { flex-direction: column; text-align: center; }
}
@media (max-width: 480px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
  .hero-info h2 { font-size: 19px; }
}

/* Safe area for iOS PWA */
@supports (padding: max(0px)) {
  .header { padding-top: env(safe-area-inset-top); height: calc(var(--header-h) + env(safe-area-inset-top)); }
  .sidebar { padding-top: env(safe-area-inset-top); }
}
