/* AI Training CRM — styles */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e4e7eb;
  --text: #1a1d23;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; }
.brand a { color: var(--text); text-decoration: none; }
.topbar-actions { display: flex; gap: 10px; }

/* ---- Container ---- */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}
.container h1 { margin: 0 0 20px; font-size: 24px; }

/* ---- Buttons ---- */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:hover { background: #f0f1f3; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 10px; }

/* ---- Student grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.student-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.15s;
  position: relative;
}
.student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.student-card-body {
  text-decoration: none;
  color: inherit;
  display: block;
}
.btn-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.student-card:hover .btn-delete {
  opacity: 1;
}
.btn-delete:hover {
  color: var(--bad);
  border-color: var(--bad);
  background: #fef2f2;
}
.card-top { margin-bottom: 12px; }
.card-top h3 {
  margin: 0 0 6px;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-top .badge {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-stats { display: flex; gap: 14px; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.card-stats b { color: var(--text); font-size: 16px; }
.card-renewal { font-size: 13px; font-weight: 500; }
.renewal-ok { color: var(--ok); }
.renewal-warn { color: var(--warn); }
.renewal-bad { color: var(--bad); }

/* ---- Badge ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  background: #eef2ff;
  color: var(--primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ---- Card (section) ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 18px; }
.actions-bar { margin-bottom: 12px; }

/* ---- Student header ---- */
.student-header { margin-bottom: 20px; }
.student-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.student-header h1 { margin: 0 0 8px; }
.btn-delete-student { color: var(--bad); white-space: nowrap; }
.btn-delete-student:hover { background: #fef2f2; border-color: var(--bad); }
.student-meta { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; color: var(--muted); font-size: 14px; }
.notes { margin-top: 10px; color: var(--muted); font-style: italic; }

/* ---- Banner ---- */
.banner {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 500;
}
.banner-ok { background: #ecfdf5; color: var(--ok); }
.banner-warn { background: #fffbeb; color: var(--warn); }
.banner-bad { background: #fef2f2; color: var(--bad); }

/* ---- Table ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.empty-row { text-align: center; color: var(--muted); padding: 20px; }

/* ---- Status pills ---- */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.status-draft { background: #f3f4f6; color: var(--muted); }
.status-ready { background: #fff7ed; color: var(--warn); }
.status-sent { background: #ecfdf5; color: var(--ok); }

/* ---- Comments ---- */
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.comment-form textarea, form textarea, form input, form select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}
.comment-form textarea:focus, form textarea:focus, form input:focus, form select:focus {
  outline: none;
  border-color: var(--primary);
}
.comments { list-style: none; padding: 0; margin: 0; }
.comment {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment-body { margin-bottom: 4px; }
.comment-date { font-size: 12px; color: var(--muted); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 16px; }
.modal label, form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---- Loading / empty / hidden ---- */
.loading { color: var(--muted); padding: 40px; text-align: center; }
.empty { color: var(--muted); padding: 40px; text-align: center; background: var(--card); border-radius: var(--radius); border: 1px dashed var(--border); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; }

/* ---- Login page ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.brand-big { font-size: 28px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.subtitle { text-align: center; color: var(--muted); margin-bottom: 24px; }
.login-card form label { margin-bottom: 14px; }
.hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.hint a { color: var(--primary); }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .container { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .grid { grid-template-columns: 1fr; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 4px; }
}
