/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #6C63FF;
  --primary-dark:  #5A52D5;
  --primary-light: #EEF0FF;
  --danger:        #EF4444;
  --success:       #22C55E;
  --warning:       #F59E0B;
  --text:          #1A202C;
  --text-muted:    #718096;
  --border:        #E2E8F0;
  --bg:            #F7F8FC;
  --surface:       #FFFFFF;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.1);
  --transition:    .18s ease;
  --header-h:      60px;
  --font:          'Inter', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ═══════════════════════════════════════════════
   UTILITÁRIOS
═══════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════
   LOADER
═══════════════════════════════════════════════ */
.loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(2px);
}

.loader__spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 10000;
  display: flex; flex-direction: column; gap: .5rem;
}

.toast {
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
  max-width: 320px;
}

.toast--success { background: var(--success); }
.toast--error   { background: var(--danger); }
.toast--info    { background: var(--primary); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ═══════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════ */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header__inner {
  max-width: 1200px; margin: 0 auto;
  height: 100%;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.5rem;
}

.header__logo {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.05rem;
  color: var(--text); text-decoration: none;
}

.header__nav { display: flex; gap: 1rem; margin-left: .5rem; }

.nav-link {
  color: var(--text-muted); font-size: .9rem; font-weight: 500;
  padding: .25rem .5rem; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.nav-link:hover { color: var(--primary); background: var(--primary-light); }

.header__user {
  margin-left: auto;
  display: flex; align-items: center; gap: .75rem;
  font-size: .9rem;
}

.avatar {
  width: 34px; height: 34px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}

.header__menu-toggle {
  display: none;
  flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer;
  padding: .25rem; margin-left: auto;
}
.header__menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: var(--transition);
}

/* ═══════════════════════════════════════════════
   BOTÕES
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem; font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.btn--primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn--outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn--outline:hover {
  background: var(--primary-light);
}

.btn--ghost {
  background: transparent; color: var(--text-muted);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--bg); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--danger:hover { background: #DC2626; border-color: #DC2626; }

.btn--sm { padding: .4rem .9rem; font-size: .82rem; }
.btn--full { width: 100%; }

/* ═══════════════════════════════════════════════
   FORMULÁRIOS
═══════════════════════════════════════════════ */
.form { display: flex; flex-direction: column; gap: 1rem; }

.form__group { display: flex; flex-direction: column; gap: .35rem; }

.form__label { font-size: .85rem; font-weight: 600; color: var(--text); }

.form__input,
.form__select,
.form__textarea {
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.15);
}

.form__textarea { resize: vertical; min-height: 90px; }

.radio-group { display: flex; gap: 1rem; }

.radio-option {
  display: flex; align-items: center; gap: .4rem;
  cursor: pointer; font-size: .9rem;
}
.radio-option input[type="radio"] { accent-color: var(--primary); }

/* ═══════════════════════════════════════════════
   PÁGINAS
═══════════════════════════════════════════════ */
.page { display: none; }
.page.active { display: block; }

.page--centered {
  min-height: calc(100vh - var(--header-h));
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.page--centered.active { display: flex; }

.page--padded {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ═══════════════════════════════════════════════
   AUTH CARD
═══════════════════════════════════════════════ */
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 420px;
}

.auth-card__logo {
  display: flex; flex-direction: column; align-items: center;
  gap: .75rem; margin-bottom: 2rem;
}
.auth-card__logo h1 { font-size: 1.4rem; font-weight: 700; }

.auth-card__switch {
  text-align: center; margin-top: 1.25rem;
  font-size: .9rem; color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   PAGE HEADER
═══════════════════════════════════════════════ */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.page-title   { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .2rem; }

/* ═══════════════════════════════════════════════
   CARD GRID (dashboard)
═══════════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.disc-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  padding: 1.5rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: .5rem;
}
.disc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
  text-decoration: none;
}

.disc-card__nome   { font-size: 1.05rem; font-weight: 700; }
.disc-card__info   { font-size: .85rem; color: var(--text-muted); }
.disc-card__badge  {
  display: inline-flex; align-items: center;
  gap: .3rem; margin-top: auto;
  font-size: .78rem; font-weight: 600; color: var(--primary);
}

/* ═══════════════════════════════════════════════
   DISCIPLINA INTERNA
═══════════════════════════════════════════════ */
.disc-header {
  display: flex; align-items: flex-start;
  flex-wrap: wrap; gap: 1rem;
  margin-bottom: 1.5rem;
}
.disc-header > div { flex: 1; min-width: 0; }

.convite-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .2rem .6rem;
  font-size: .85rem;
  user-select: all;
}

.badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .78rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 20px;
}

/* TABS */
.tabs {
  display: flex; gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab {
  background: none; border: none; cursor: pointer;
  padding: .65rem 1.1rem;
  font-family: var(--font); font-size: .9rem; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.tab:hover  { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.tab-content--chat {
  display: none;
  flex-direction: column;
  height: calc(100vh - 280px);
  min-height: 320px;
}
.tab-content--chat.active { display: flex; }

.tab-toolbar {
  display: flex; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* LISTAS (materiais, atividades, agenda) */
.list-container { display: flex; flex-direction: column; gap: .75rem; }

.list-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  transition: border-color var(--transition);
}
.list-item:hover { border-color: var(--primary); }

.list-item__icon {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.list-item__info { flex: 1; min-width: 0; }
.list-item__titulo { font-weight: 600; font-size: .95rem; }
.list-item__meta   { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }

.list-item__actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* status badges para entregas/atividades */
.status-badge {
  display: inline-flex; align-items: center;
  font-size: .75rem; font-weight: 600;
  padding: .2rem .6rem; border-radius: 20px;
}
.status-badge--pendente  { background: #FEF3C7; color: #92400E; }
.status-badge--enviada   { background: #DBEAFE; color: #1E40AF; }
.status-badge--corrigida { background: #D1FAE5; color: #065F46; }
.status-badge--ativa     { background: #D1FAE5; color: #065F46; }
.status-badge--encerrada { background: var(--bg); color: var(--text-muted); }

/* AGENDA */
.aula-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.aula-card--ativa { border-color: var(--success); }

.aula-card__data {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: .6rem .9rem;
  text-align: center;
  flex-shrink: 0;
}
.aula-card__data .dia  { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.aula-card__data .mes  { font-size: .75rem; font-weight: 600; text-transform: uppercase; }

.aula-card__info { flex: 1; min-width: 0; }
.aula-card__titulo { font-weight: 700; }
.aula-card__horario { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }

/* ═══════════════════════════════════════════════
   CHAT
═══════════════════════════════════════════════ */
.chat-box {
  flex: 1; overflow: hidden;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.chat-messages {
  height: 100%; overflow-y: auto;
  padding: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
  scroll-behavior: smooth;
}

.chat-msg {
  max-width: 72%;
  display: flex; flex-direction: column;
}
.chat-msg--mine  { align-self: flex-end; align-items: flex-end; }
.chat-msg--other { align-self: flex-start; align-items: flex-start; }

.chat-msg__nome {
  font-size: .75rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: .2rem;
}

.chat-msg__bubble {
  padding: .6rem .9rem;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg--mine  .chat-msg__bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg--other .chat-msg__bubble { background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; }

.chat-msg__hora {
  font-size: .7rem; color: var(--text-muted); margin-top: .2rem;
}

.chat-form {
  display: flex; gap: .75rem;
  padding: .75rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat-form .form__input { flex: 1; }

/* ═══════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { transform: scale(.95) translateY(8px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 1.05rem; font-weight: 700; }
.modal__close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: .25rem; border-radius: 4px;
  transition: color var(--transition);
}
.modal__close:hover { color: var(--danger); }

.modal__body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal__body .form { gap: 1rem; }

.modal__footer {
  display: flex; justify-content: flex-end; gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem; padding: 4rem 1rem;
  color: var(--text-muted); text-align: center;
}

/* ═══════════════════════════════════════════════
   RESPONSIVO
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .header__nav   { display: none; }
  .header__user  { display: none; }

  .header__menu-toggle { display: flex; }

  /* menu mobile aberto */
  .header.menu-open .header__nav {
    display: flex; flex-direction: column;
    position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--surface);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    gap: .75rem;
  }
  .header.menu-open .header__user {
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem 1rem;
    position: absolute;
    top: calc(var(--header-h) + 120px);
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .page--padded { padding: 1.25rem 1rem; }

  .auth-card { padding: 2rem 1.25rem; }

  .disc-header { flex-direction: column; }

  .chat-msg { max-width: 88%; }

  .tab-content--chat {
    height: calc(100vh - 320px);
  }

  .aula-card { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 1.25rem; }
}