/**
 * Shared layout polish for all tenant skins (edu-sites).
 * Loaded after theme CSS + common.css. Safe, progressive enhancements only.
 * Does NOT replace skin look — improves structure, mobile, a11y, overflow.
 */

/* ---------- Base content hygiene ---------- */
img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

#main-content img,
.main-container img,
.teacher-content img,
#content img,
.content img,
#forparentssm img {
  max-width: 100%;
  height: auto;
}

table {
  max-width: 100%;
}

.main-container,
.teacher-content,
#content,
#forparentssm,
.content {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* Scrollable tables on narrow screens */
.main-container table,
.teacher-content table,
#content table,
.content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Classic shell (themes 7–11): #root / #center ---------- */
#root {
  min-height: 100vh;
}

#center {
  box-sizing: border-box;
}

#main-content .main-container {
  min-height: 280px;
}

/* Side column breathing room */
#side-content.side-content,
.side-content {
  box-sizing: border-box;
}

.side-box .header p {
  margin: 0;
}

/* Support / messages badges */
#navigation .blink,
.side-content .blink {
  color: #c0392b;
  font-weight: 700;
  animation: edu-blink 1.2s ease-in-out infinite;
}

@keyframes edu-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* Back-to-top */
.buttonup {
  z-index: 40;
  opacity: .9;
  transition: opacity .2s ease, transform .2s ease;
}
.buttonup:hover {
  opacity: 1;
  transform: translateY(-2px);
}

/* Flash / expire alerts */
.web_alert,
.alert {
  box-sizing: border-box;
}
.web_alert.show_alert {
  z-index: 100;
}

/* ---------- Teacher shell (themes 1–3) ---------- */
.teacher-info .container.vhh,
.teacher-info .container {
  box-sizing: border-box;
}

.teacher-content {
  min-height: 240px;
}

.teacher-info aside ul {
  padding-left: 0;
}

.teacher-info .banner .search-form input[type="text"] {
  max-width: 100%;
  box-sizing: border-box;
}

/* ---------- Middle shell (themes 4–6) ---------- */
#contentBlock,
#middle,
#content.centered {
  box-sizing: border-box;
}

#contentBlock .content,
#middle #content,
#forparents {
  min-height: 240px;
}

/* ---------- Focus / a11y ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

/* Skip visual glitches from empty widgets */
.side-box.infosidelist-widget:empty {
  display: none;
}

/* ---------- Classic: mobile 3-column stack ---------- */
@media (max-width: 991px) {
  /* Many classic skins float main + side; force readable stack */
  #center {
    display: flex;
    flex-direction: column;
  }

  #main-content {
    width: 100% !important;
    float: none !important;
    max-width: 100%;
  }

  #side-content,
  .side-content#side-content {
    width: 100% !important;
    float: none !important;
    max-width: 100%;
    margin-top: 1rem;
  }

  #center .clear {
    display: none;
  }

  /* Horizontal menu: allow wrap / scroll */
  .header-menu,
  #header-menu,
  nav.header-menu,
  .top-menu {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Teacher: stack aside / content / banner */
@media (max-width: 991px) {
  .teacher-info .container.vhh,
  .teacher-info .container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .teacher-info aside,
  .teacher-info .teacher-content,
  .teacher-info .banner {
    width: 100% !important;
    float: none !important;
    max-width: 100%;
  }

  .teacher-info aside {
    order: 1;
  }

  .teacher-info .teacher-content {
    order: 2;
  }

  .teacher-info .banner {
    order: 3;
  }
}

/* Middle: stack left / content / right */
@media (max-width: 991px) {
  #contentBlock,
  #middle {
    display: flex;
    flex-direction: column;
  }

  #contentBlock .left-menu,
  #contentBlock .content,
  #contentBlock .right-menu,
  #middle .left-menu,
  #middle #content,
  #middle .right-menu,
  #content.centered .left-menu,
  #content.centered #forparents,
  #content.centered .right-menu {
    width: 100% !important;
    float: none !important;
    max-width: 100%;
  }
}

/* ---------- Print ---------- */
@media print {
  .buttonup,
  .bvi_eye,
  #side-content .auth-widget,
  .side-box.auth-widget {
    display: none !important;
  }

  body {
    background: #fff !important;
  }

  #main-content,
  .teacher-content,
  #content,
  .content {
    width: 100% !important;
    float: none !important;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .buttonup,
  #navigation .blink,
  .side-content .blink {
    animation: none !important;
    transition: none !important;
  }
}

/*
 * Cookie / personal-data banner (baseline for all skins)
 * Was previously only in public/css/style.css and per-theme CSS.
 * Modern skins that drop legacy style.css still need this.
 * Skins may override with higher-specificity rules.
 */
.personal-data-processing-agreement-widget {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  width: 100%;
  box-sizing: border-box;
  padding: 0 0.75rem 0.85rem;
  background: transparent;
  pointer-events: none;
}

.personal-data-processing-agreement-widget .wrapper {
  pointer-events: auto;
  box-sizing: border-box;
  width: min(100%, 1040px);
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.95rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1rem;
  background: linear-gradient(115deg, #0f3a4f 0%, #0d7a72 100%);
  color: #f4fbfa;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 40px rgba(7, 32, 51, 0.32);
}

.personal-data-processing-agreement-widget .acceptance-text {
  flex: 1 1 240px;
  width: auto;
  margin: 0;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  color: #f4fbfa;
}

.personal-data-processing-agreement-widget .acceptance-text a {
  color: #ffe08a;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.personal-data-processing-agreement-widget .acceptance-text a:hover {
  color: #ffffff;
}

.personal-data-processing-agreement-widget .acceptance-button {
  flex: 0 0 auto;
  margin: 0;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
  color: #0b2430;
  background: linear-gradient(180deg, #ffe08a, #f0b429);
  box-shadow: 0 8px 18px rgba(240, 180, 41, 0.32);
  white-space: nowrap;
}

.personal-data-processing-agreement-widget .acceptance-button:hover {
  filter: brightness(1.05);
}

@media (max-width: 640px) {
  .personal-data-processing-agreement-widget .wrapper {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .personal-data-processing-agreement-widget .acceptance-button {
    width: 100%;
  }
}
