/* Teacher Resources portal + school information chatbot (official theme page). */

.tr-page {
  --navy: #001f47;
  --gold: #fbcb09;
  --blue: #0083ca;
  --text: #223;
  --muted: #5a6573;
  --line: #d9dee6;
  --bg: #f4f6f9;
  --card: #fff;
  background: #f4f6f9;
  min-height: 60vh;
  font-family: "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: #223;
  margin: 0 -15px;
  padding: 0 0 8px;
}

body.view-login .portal-only,
.tr-page.view-login .portal-only { display: none !important; }
body.view-portal .login-only,
.tr-page.view-portal .login-only { display: none !important; }
.portal-only { display: none; }
body.view-portal .portal-only,
.tr-page.view-portal .portal-only { display: block; }

.sina-menu > li.tr-current > a {
  color: #fbcb09 !important;
}

.tr-signed {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
  color: #001f47;
  margin-bottom: 8px;
}
body.view-portal .tr-signed { display: flex; }
.tr-signed .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: #fbcb09; color: #001f47;
  display: grid; place-items: center;
  font-weight: 800; font-size: 11px;
  overflow: hidden;
  flex: 0 0 24px;
}
.tr-signed .avatar img { width: 24px; height: 24px; object-fit: cover; }

.login-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: flex;
  justify-content: center;
}
.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid #d9dee6;
  border-top: 4px solid #fbcb09;
  border-radius: 12px;
  padding: 36px 32px 32px;
  box-shadow: 0 12px 32px rgba(0,31,71,.08);
  text-align: center;
}
.login-card h1 { margin: 0 0 8px; color: #001f47; font-size: 26px; }
.login-card .sub {
  margin: 0 0 28px;
  color: #5a6573;
  font-size: 14px;
  line-height: 1.5;
}
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #dadce0;
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #3c4043;
}
.google-btn:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.google-btn:disabled { opacity: .65; cursor: wait; }
.auth-error {
  display: none;
  margin-top: 16px;
  padding: 10px 12px;
  background: #fdecea;
  border-left: 3px solid #c5221f;
  font-size: 13px;
  color: #8a1f11;
  text-align: left;
  line-height: 1.45;
}

.portal {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 64px;
  width: 100%;
}
.portal-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 10px;
}
.portal-hero h1 { margin: 0 0 6px; color: #001f47; font-size: 30px; }
.portal-hero .sub { margin: 0; color: #5a6573; font-size: 14px; }
.portal-hero-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.search { position: relative; }
.search input {
  width: min(320px, 100%);
  border: 1px solid #d9dee6;
  border-radius: 999px;
  padding: 10px 14px 10px 38px;
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: #0083ca; }
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  opacity: .45;
}
.dept { margin-top: 32px; }
.dept > .grid.dept-top { margin-bottom: 22px; }
.dept > h2 {
  margin: 0 0 14px;
  font-size: 20px;
  color: #001f47;
  border-left: 4px solid #fbcb09;
  padding-left: 12px;
  line-height: 1.3;
}
.subdept { margin: 0 0 22px; }
.subdept h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #001f47;
  font-weight: 700;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.card {
  background: #fff;
  border: 1px solid #d9dee6;
  border-radius: 14px;
  padding: 18px 16px 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 148px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,31,71,.1);
  border-color: #c9d4e3;
}
.card-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; color: #001f47;
  background: #fff3bf;
  font-size: 13px;
  align-self: flex-start;
}
.card.it .card-icon { background: #e3f2fb; color: #005b8f; }
.card.admin .card-icon { background: #e8edf5; color: #001f47; }
.card.activity .card-icon { background: #ece8ff; color: #3b2d8a; }
.card.affairs .card-icon { background: #e9f7ef; color: #1b5e3b; }
.card.sheet .card-icon { background: #e7f6ed; color: #1b6b3a; }
.card.form .card-icon { background: #fff3d6; color: #8a5a00; }
.card h3 { margin: 2px 0 0; font-size: 16px; color: #001f47; }
.card p { margin: 0; font-size: 13px; color: #5a6573; line-height: 1.45; flex: 1; }
.card .open { font-size: 12px; font-weight: 700; color: #0083ca; }
.none {
  margin: 0;
  color: #5a6573;
  font-size: 13px;
  font-style: italic;
  padding: 4px 0 8px;
}
.empty {
  display: none;
  text-align: center;
  color: #5a6573;
  padding: 40px 10px;
}
.portal-note {
  margin-top: 28px;
  font-size: 13px;
  color: #5a6573;
  line-height: 1.5;
}
.signout {
  display: inline-block;
  margin-top: 8px;
  background: none;
  border: 0;
  color: #001f47;
  cursor: pointer;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 700;
}

.chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: #001f47;
  color: #fbcb09;
  box-shadow: 0 8px 24px rgba(0,31,71,.35);
  cursor: pointer;
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
}
body.page-teacher-resources .chat-launcher { display: flex; }
.chat-launcher:hover { background: #00285c; }
.chat-launcher.is-open { background: #fbcb09; color: #001f47; }

.chat-panel {
  position: fixed;
  right: 22px;
  bottom: 92px;
  width: min(380px, calc(100vw - 24px));
  height: min(540px, calc(100vh - 130px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,31,71,.28);
  border: 1px solid #d9dee6;
  z-index: 10001;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}
.chat-panel * { box-sizing: border-box; }
.chat-panel.open { display: flex; }
.chat-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  float: none !important;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  background: #001f47 !important;
  color: #fff !important;
  padding: 12px 14px !important;
  margin: 0 !important;
  border: 0 !important;
  border-bottom: 3px solid #fbcb09 !important;
  text-align: left !important;
  height: auto !important;
  min-height: 58px;
  gap: 8px;
}
.chat-head > div { flex: 1; min-width: 0; }
.chat-head h2 {
  color: #fff !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  line-height: 1.3 !important;
  float: none !important;
  position: static !important;
  text-shadow: none !important;
  background: none !important;
  display: block !important;
}
.chat-head p {
  margin: 2px 0 0 !important;
  padding: 0 !important;
  font-size: 11px !important;
  color: #c9d3df !important;
  border: 0 !important;
  line-height: 1.3 !important;
}
.chat-head button {
  background: transparent !important;
  border: 0 !important;
  color: #fff !important;
  font-size: 22px !important;
  line-height: 1 !important;
  cursor: pointer;
  padding: 0 4px !important;
  flex: 0 0 auto;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f4f6f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #d9dee6;
  color: #223;
  border-bottom-left-radius: 4px;
}
.chat-user {
  align-self: flex-end;
  background: #001f47;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-pending { color: #5a6573; font-style: italic; }
.chat-error { color: #8a1f11; background: #fdecea; }
.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #d9dee6;
  background: #fff;
}
.chat-form input {
  flex: 1;
  border: 1px solid #d9dee6;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
}
.chat-form input:focus { border-color: #0083ca; }
.chat-form button {
  border: 0;
  border-radius: 999px;
  background: #001f47;
  color: #fbcb09;
  font-weight: 700;
  font-size: 13px;
  padding: 0 14px;
  cursor: pointer;
}
.chat-form button:disabled { opacity: .55; cursor: wait; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .portal-hero { flex-direction: column; align-items: stretch; }
  .portal-hero-tools { align-items: stretch; }
  .search input { width: 100%; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
}

/* Reset official theme heading styles inside Teacher Resources */
.tr-page .card h3,
.tr-page h3.card-title {
  font-size: 16px !important;
  margin: 2px 0 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: #001f47 !important;
  line-height: 1.3 !important;
  font-weight: 700 !important;
  background: none !important;
}
.tr-page .dept > h2 {
  font-size: 20px !important;
  color: #001f47 !important;
  border-left: 4px solid #fbcb09 !important;
  padding: 0 0 0 12px !important;
  margin: 0 0 14px !important;
  line-height: 1.3 !important;
  background: none !important;
}
.tr-page .subdept h3 {
  font-size: 15px !important;
  margin: 0 0 10px !important;
  padding: 0 !important;
  border: 0 !important;
  color: #001f47 !important;
  font-weight: 700 !important;
}
.tr-page .portal-hero h1,
.login-card h1 {
  color: #001f47 !important;
  border: 0 !important;
  padding: 0 !important;
  background: none !important;
  text-shadow: none !important;
  position: static !important;
}
