/* v4.58 Base Polish
   Purpose: keep the original academy layout and improve it with small, safe visual refinements only.
   This file must stay conservative: no global layout rebuild, no forced page redesign, no heavy overrides. */
:root{
  --ui-text:#1f2937;
  --ui-subtext:#64748b;
  --ui-surface:#ffffff;
  --ui-soft:#f8fafc;
  --ui-soft-2:#f1f5f9;
  --ui-line:#e6ebf1;
  --ui-shadow:0 10px 30px rgba(15,23,42,.055);
  --ui-shadow-hover:0 14px 38px rgba(15,23,42,.085);
  --ui-radius:14px;
  --ui-radius-sm:10px;
  --ui-focus:0 0 0 4px rgba(0,150,136,.13);
}

html{scroll-behavior:smooth;}
body{
  color:var(--ui-text);
  background:
    radial-gradient(circle at 18% -8%, rgba(0,150,136,.08), transparent 30%),
    linear-gradient(180deg,#fff 0%,#f8fafc 360px,#f7f9fb 100%);
  font-family:"Segoe UI",Inter,system-ui,-apple-system,Arial,sans-serif;
  font-size:15px;
  line-height:1.55;
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
}

a{transition:color .16s ease,background-color .16s ease,border-color .16s ease,box-shadow .16s ease,transform .16s ease;}
img{image-rendering:auto;}

/* Header: original structure, cleaner spacing and no overlap. */
.topbar{
  background:rgba(255,255,255,.96)!important;
  border-bottom:1px solid rgba(226,232,240,.92)!important;
  backdrop-filter:saturate(140%) blur(10px);
  box-shadow:0 1px 0 rgba(15,23,42,.035);
}
.brand,
.brand-with-logo{
  min-width:0;
  display:inline-flex;
  align-items:center;
  gap:10px;
  color:var(--primary)!important;
  font-weight:700!important;
  letter-spacing:-.02em;
}
.brand-with-logo img{
  max-height:36px;
  width:auto;
  object-fit:contain;
  border-radius:8px;
}
.brand span{min-width:0;line-height:1.12;}
.brand small{font-weight:500!important;letter-spacing:0;color:#7b8794!important;}
.top-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  min-width:0;
}
.top-actions .btn,
.notification-button{
  white-space:nowrap;
  flex:0 0 auto;
}
.user-label{font-weight:500;color:#64748b;}
.notification-popover{
  border:1px solid var(--ui-line)!important;
  border-radius:16px!important;
  box-shadow:0 24px 64px rgba(15,23,42,.16)!important;
}
.notification-item{border-radius:12px;}

/* Sidebar: keep accordion, make it calmer and easier to scan. */
.layout > .sidebar{
  background:linear-gradient(180deg,#fff 0%,#fbfcfd 100%)!important;
  border-right:1px solid var(--ui-line)!important;
}
.sidebar .side-section{margin:0 10px 7px;border-bottom:1px solid rgba(226,232,240,.62);}
.sidebar .side-section > .side-title{
  border-radius:12px!important;
  color:#6b7280!important;
  font-weight:700!important;
  letter-spacing:.055em;
}
.sidebar .side-section > .side-title:hover,
.sidebar .side-section.open > .side-title{
  background:linear-gradient(135deg,rgba(0,150,136,.09),rgba(14,165,233,.045))!important;
  color:#04756b!important;
}
.side-link,
.sidebar .side-section-content .side-link{
  position:relative;
  min-height:40px;
  border-radius:12px!important;
  font-weight:500!important;
  line-height:1.25;
}
.sidebar .side-section-content .side-link:hover,
.sidebar .side-section-content .side-link.active,
.side-link:hover,
.side-link.active{
  background:linear-gradient(135deg,rgba(0,150,136,.10),rgba(255,255,255,.72))!important;
  color:#006b60!important;
  box-shadow:inset 0 0 0 1px rgba(0,150,136,.06);
}
@media (min-width:901px){
  .side-link:hover{transform:translateX(1px);}
  .dir-rtl .side-link:hover,
  html[dir="rtl"] .side-link:hover{transform:translateX(-1px);}
}
.side-badge,
.sidebar .side-section-badge{
  box-shadow:0 6px 14px rgba(220,38,38,.17)!important;
}

/* Content shell: subtle polish only. */
.main{padding:28px;}
.page-head{
  padding:18px 20px;
  border:1px solid var(--ui-line);
  border-radius:var(--ui-radius);
  background:rgba(255,255,255,.84);
  box-shadow:0 8px 26px rgba(15,23,42,.035);
}
.page-head h1{
  font-size:clamp(24px,2.2vw,31px)!important;
  line-height:1.18;
  letter-spacing:-.025em;
  font-weight:700!important;
}
.page-head .muted{margin-top:5px;}
.muted{color:var(--ui-subtext)!important;}

.card,
.stat,
.mini-stat,
.flag-card,
.path-step,
.checklist-item,
.public-course-section,
.public-course-access-card,
.public-course-teacher-card,
.public-course-media-card,
.builder-shell,
.activity-modal,
.section-settings-modal{
  border-color:var(--ui-line)!important;
  border-radius:var(--ui-radius)!important;
  box-shadow:var(--ui-shadow);
}
.card{
  background:rgba(255,255,255,.96)!important;
}
.card:hover,
.course-card:hover,
.community-post-card:hover{
  box-shadow:var(--ui-shadow-hover)!important;
}
.card h1,.card h2,.card h3{letter-spacing:-.015em;}

/* Buttons and forms: calmer, cleaner, no heavy redesign. */
.btn,
button.btn,
a.btn{
  border-radius:10px!important;
  font-weight:600!important;
  line-height:1.2;
  min-height:38px;
  transition:transform .16s ease,box-shadow .16s ease,filter .16s ease,background-color .16s ease,border-color .16s ease;
}
.btn:not(.btn-light):not(.btn-outline):not(.btn-danger):not(.btn-dark){
  box-shadow:0 8px 18px rgba(0,150,136,.16);
}
.btn:hover{
  filter:none!important;
  transform:translateY(-1px);
  box-shadow:0 10px 24px rgba(15,23,42,.10);
}
.btn:active{transform:translateY(0);}
.btn-light{
  background:#f1f5f9!important;
  color:#263238!important;
  border:1px solid #e2e8f0!important;
}
.btn-outline{background:#fff!important;}
.btn-small{min-height:32px;border-radius:9px!important;}

input,select,textarea{
  border-color:#dce3eb!important;
  border-radius:10px!important;
  color:#172033;
  transition:border-color .16s ease,box-shadow .16s ease,background-color .16s ease;
}
input:hover,select:hover,textarea:hover{border-color:#cbd5e1!important;}
input:focus,select:focus,textarea:focus{
  border-color:var(--primary)!important;
  box-shadow:var(--ui-focus)!important;
}
label{font-weight:600!important;color:#334155;}
textarea{resize:vertical;}

/* Tables: readable rows and safe horizontal scrolling through JS wrapper. */
.table{
  border-color:var(--ui-line)!important;
  border-radius:12px!important;
}
.table th{
  background:#f8fafc!important;
  color:#64748b!important;
  font-weight:700!important;
  letter-spacing:.035em;
}
.table td,.table th{border-bottom-color:#edf2f7!important;}
.table tr:hover td{background:#fbfefd;}
.table-polish-scroll{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  border-radius:12px;
}
.table-polish-scroll > .table{min-width:720px;}

/* Dashboard/stat cards. */
.stats,
.support-stats,
.attendance-kpis,
.public-course-stats{
  gap:16px!important;
}
.stat,
.mini-stat{
  background:#fff!important;
  position:relative;
  overflow:hidden;
}
.stat::before,
.mini-stat::before{
  content:"";
  position:absolute;
  inset:0 0 auto 0;
  height:3px;
  background:linear-gradient(90deg,var(--primary),rgba(14,165,233,.55));
}
.metric-card h1,.stat b,.mini-stat b{font-weight:700!important;letter-spacing:-.03em;}

/* Public pages: keep original public design, only make it more premium and calmer. */
.hero{
  background:
    radial-gradient(circle at 18% 8%,rgba(0,150,136,.10),transparent 32%),
    linear-gradient(135deg,#fff 0%,#f8fcfb 100%)!important;
}
.hero h1{font-weight:750!important;letter-spacing:-.045em;}
.hero-box{
  border-color:rgba(0,150,136,.18)!important;
  box-shadow:0 20px 50px rgba(15,23,42,.07);
}
.course-grid{align-items:stretch;}
.course-card{
  border-radius:16px!important;
  overflow:hidden;
  transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease;
}
.course-card:hover{border-color:rgba(0,150,136,.24)!important;}
.course-cover{background:linear-gradient(135deg,#ecfdf5,#eff6ff)!important;}
.course-cover img{width:100%;height:100%;object-fit:cover;display:block;}
.course-title-link:hover{color:var(--primary);}
.public-course-page{
  background:
    radial-gradient(circle at 12% 0%,rgba(0,150,136,.08),transparent 30%),
    linear-gradient(180deg,#fff 0%,#f8fafc 100%)!important;
}
.public-course-hero{background:transparent!important;}
.public-course-media-card img{border-radius:14px;}
.public-course-access-card{background:linear-gradient(135deg,#fff,#f6fbfa)!important;}

/* Login page: same layout, softer appearance. */
.branded-login-page{
  background:
    radial-gradient(circle at 20% 0%,rgba(0,150,136,.12),transparent 34%),
    linear-gradient(135deg,#fff,#f7fafc)!important;
}
.branded-login-grid{gap:22px!important;}
.branded-login-panel{
  background:linear-gradient(135deg,#fff,#f2fbfa)!important;
}
.login-brand-logo{max-height:74px;width:auto;object-fit:contain;}

/* Builder and learning areas: keep positions, add separators and clarity. */
.builder-shell,.course-builder{
  background:#fff;
}
.builder-nav{background:#fbfcfd!important;}
.builder-nav a{border-radius:10px!important;font-weight:600!important;}
.outline-section{
  border-top-color:#e7edf3!important;
}
.activity-row{
  border-radius:10px;
  padding:10px 8px!important;
  transition:background-color .14s ease;
}
.activity-row:hover{background:#f8fafc;}
.activity-actions .btn{white-space:nowrap;}
.material-tile{box-shadow:none;}
.material-icon{box-shadow:inset 0 0 0 1px rgba(255,255,255,.75),0 9px 18px rgba(15,23,42,.14)!important;}

/* Community and messages: lighter cards and better spacing. */
.community-composer.card,
.community-post-card,
.messages-folder-bar{
  border-color:var(--ui-line)!important;
}
.community-comment{border-color:#edf2f7!important;}
.community-reaction-button,
.community-more-toggle{
  transition:background-color .16s ease,transform .16s ease,box-shadow .16s ease;
}
.community-reaction-button:hover,
.community-more-toggle:hover{transform:translateY(-1px);}

/* Calendar: clearer day cells without changing calendar logic. */
.calendar-layout,
.calendar-grid{gap:14px;}
.calendar-day{
  border-color:#e6edf3!important;
  border-radius:12px!important;
  background:#fff!important;
}
.calendar-day:hover{box-shadow:0 8px 22px rgba(15,23,42,.06);}
.calendar-event-pill{border-radius:999px!important;}

/* Modals/dialogs: prevent content from visually stacking. */
dialog,
.activity-modal,
.section-settings-modal,
.student-detail-modal{
  max-width:calc(100vw - 24px);
}
.activity-modal-header,
.section-settings-modal-header{
  background:linear-gradient(135deg,#fff,#f8fbfa)!important;
}

/* Gentle JS reveal. Applied only after base-polish.js adds .ui-reveal. */
@media (prefers-reduced-motion:no-preference){
  body.ui-ready .ui-reveal{
    opacity:0;
    transform:translateY(8px);
    transition:opacity .34s ease,transform .34s ease,box-shadow .16s ease,border-color .16s ease;
  }
  body.ui-ready .ui-reveal.is-visible{
    opacity:1;
    transform:none;
  }
}

/* Mobile: keep the existing drawer behavior, reduce crowded header controls. */
@media(max-width:900px){
  body{background:#f8fafc;}
  .main{padding:14px!important;}
  .page-head{padding:15px!important;border-radius:13px!important;}
  .topbar{gap:8px;}
  .top-actions{gap:6px;}
  .top-actions > a[href$="dashboard.php"]{display:none;}
  .brand small{display:none;}
  .table-polish-scroll > .table{min-width:680px;}
  .activity-row{align-items:flex-start;}
  .activity-actions{justify-content:flex-start;}
}
@media(max-width:640px){
  body{font-size:14px;}
  .card{padding:14px!important;}
  .hero{padding:28px 14px!important;}
  .hero h1{font-size:32px!important;}
  .btn{width:auto;max-width:100%;}
  .page-head>div:last-child .btn{flex:1 1 auto;}
  .public-course-actions{display:flex;flex-wrap:wrap;gap:8px;}
  .public-course-actions .btn{width:100%;}
}

/* v4.59 HTML / Embed activity isolation
   Keep custom HTML and embeds from breaking the academy layout. */
.academy-isolated-activity{
  width:100%;
  margin:16px 0 18px;
  border:1px solid var(--ui-line,#e6ebf1);
  border-radius:16px;
  background:#fff;
  overflow:hidden;
  box-shadow:0 10px 30px rgba(15,23,42,.055);
}
.academy-isolated-frame{
  display:block;
  width:100%;
  min-height:560px;
  height:clamp(560px,72vh,920px);
  border:0;
  background:#fff;
}
.academy-isolated-embed .academy-isolated-frame,
.academy-isolated-form .academy-isolated-frame{
  min-height:520px;
  height:clamp(520px,68vh,880px);
}
@media(max-width:900px){
  .academy-isolated-activity{border-radius:12px;margin:12px 0 14px;}
  .academy-isolated-frame,
  .academy-isolated-embed .academy-isolated-frame,
  .academy-isolated-form .academy-isolated-frame{
    min-height:460px;
    height:70vh;
  }
}

/* v4.63 Question Bank professional management polish */
.qb-dashboard-grid{
  align-items:start;
}
.qb-card h2,
.qb-bank-management h2,
.qb-question-list-card h2{
  margin-top:0;
}
.qb-bank-form,
.qb-question-form{
  display:block;
}
.qb-inline-check{
  display:flex!important;
  align-items:center;
  gap:8px;
  margin:12px 0;
  color:#334155;
  font-weight:600;
}
.qb-status-check{
  min-height:42px;
  padding:10px 12px;
  border:1px solid var(--ui-line,#e6ebf1);
  border-radius:12px;
  background:#f8fafc;
}
.qb-answer-box{
  margin:14px 0;
  padding:14px;
  border:1px solid #e6edf3;
  border-radius:14px;
  background:linear-gradient(180deg,#ffffff,#f9fbfd);
}
.qb-option-row{
  background:#fff!important;
  border-color:#e5edf5!important;
}
.qb-correct-check{
  margin:0!important;
  white-space:nowrap;
}
.qb-bank-table td{
  vertical-align:top;
}
.qb-actions{
  white-space:nowrap;
}
.qb-edit-row td{
  padding-top:0!important;
  background:#fbfdff;
}
.qb-bank-editor{
  border:1px dashed #d8e3ee;
  border-radius:14px;
  padding:10px 12px;
  background:#fff;
}
.qb-bank-editor summary{
  cursor:pointer;
  font-weight:700;
  color:#0f766e;
}
.qb-edit-grid{
  margin-top:12px;
  align-items:start;
}
.qb-danger-zone{
  padding:16px;
  border:1px solid #fee2e2;
  border-radius:14px;
  background:#fff7f7;
}
.qb-danger-zone h3{
  margin-top:0;
  color:#991b1b;
}
.qb-list-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px;
}
.qb-filter-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:flex-end;
  max-width:55%;
}
.qb-question-editor{
  margin:12px 0;
  border:1px solid #e6edf3;
  border-radius:16px;
  background:#fff;
  overflow:hidden;
}
.qb-question-editor>summary{
  padding:14px 16px;
  background:linear-gradient(180deg,#ffffff,#f8fafc);
  border-bottom:1px solid transparent;
}
.qb-question-editor[open]>summary{
  border-bottom-color:#e6edf3;
}
.qb-edit-question-form{
  padding:16px;
}
.qb-delete-question-form{
  padding:0 16px 16px;
  display:flex;
  justify-content:flex-end;
}
@media(max-width:900px){
  .qb-list-header{
    display:block;
  }
  .qb-filter-actions{
    max-width:none;
    justify-content:flex-start;
    margin-top:10px;
  }
  .qb-actions{
    white-space:normal;
  }
}

/* v4.64 Question Banks separated professional sections */
.qb-pro-shell{
  display:block;
  max-width:1280px;
  margin:0 auto;
}
.qb-pro-hero{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:18px;
  padding:22px 24px;
  border:1px solid #e5edf4;
  background:
    radial-gradient(circle at 5% 0%, rgba(20,184,166,.10), transparent 34%),
    linear-gradient(180deg,#ffffff,#fbfdff);
}
.qb-pro-hero h2{
  margin:4px 0 6px;
  color:#0f172a;
  letter-spacing:-.02em;
}
.qb-eyebrow{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:5px 10px;
  border-radius:999px;
  background:#ecfdf5;
  color:#047857;
  border:1px solid #bbf7d0;
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.qb-stat-strip{
  display:grid;
  grid-template-columns:repeat(3,minmax(90px,1fr));
  gap:10px;
  min-width:320px;
}
.qb-stat{
  padding:14px 12px;
  border:1px solid #e5edf4;
  border-radius:16px;
  background:#fff;
  box-shadow:0 10px 26px rgba(15,23,42,.045);
  text-align:center;
}
.qb-stat strong{
  display:block;
  font-size:24px;
  line-height:1;
  color:#0f766e;
}
.qb-stat span{
  display:block;
  margin-top:6px;
  color:#64748b;
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.qb-pro-tabs{
  position:sticky;
  top:var(--topbar-height,0px);
  z-index:12;
  display:flex;
  gap:8px;
  margin:18px 0;
  padding:8px;
  border:1px solid #e5edf4;
  border-radius:18px;
  background:rgba(255,255,255,.92);
  box-shadow:0 14px 34px rgba(15,23,42,.06);
  backdrop-filter:blur(12px);
}
.qb-pro-tab{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  border-radius:13px;
  color:#475569;
  text-decoration:none!important;
  font-weight:800;
  border:1px solid transparent;
  transition:background .16s ease, color .16s ease, transform .16s ease, border-color .16s ease;
}
.qb-pro-tab:hover{
  background:#f8fafc;
  color:#0f766e;
  transform:translateY(-1px);
}
.qb-pro-tab.active{
  color:#fff;
  background:linear-gradient(135deg,#0f766e,#14b8a6);
  border-color:#0f766e;
  box-shadow:0 10px 22px rgba(15,118,110,.22);
}
.qb-pro-panel{
  animation:qbPanelIn .22s ease both;
}
@keyframes qbPanelIn{
  from{opacity:0; transform:translateY(8px)}
  to{opacity:1; transform:none}
}
.qb-section-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin:6px 0 16px;
}
.qb-section-head h2{
  margin:0 0 5px;
}
.qb-create-bank-panel{
  margin-bottom:18px;
  padding:0;
  overflow:hidden;
}
.qb-create-bank-panel>summary{
  cursor:pointer;
  padding:16px 18px;
  font-weight:800;
  color:#0f766e;
  background:linear-gradient(180deg,#ffffff,#f8fafc);
  border-bottom:1px solid transparent;
}
.qb-create-bank-panel[open]>summary{
  border-bottom-color:#e5edf4;
}
.qb-create-bank-panel form{
  padding:18px;
}
.qb-compact-form textarea{
  min-height:auto;
}
.qb-form-footer{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-top:14px;
}
.qb-bank-card-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(320px,1fr));
  gap:16px;
  align-items:start;
}
.qb-bank-card{
  padding:18px;
  border:1px solid #e5edf4;
  box-shadow:0 12px 28px rgba(15,23,42,.052);
}
.qb-bank-card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}
.qb-bank-card h3{
  margin:0 0 4px;
  color:#0f172a;
}
.qb-bank-description{
  color:#475569;
  margin:12px 0;
  line-height:1.55;
}
.qb-bank-mini-stats{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin:14px 0;
}
.qb-bank-mini-stats span{
  display:inline-flex;
  gap:6px;
  align-items:center;
  padding:8px 10px;
  border-radius:12px;
  background:#f8fafc;
  border:1px solid #e5edf4;
  color:#64748b;
  font-size:13px;
}
.qb-bank-mini-stats b{
  color:#0f172a;
}
.qb-card-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:14px 0;
}
.qb-bank-card .qb-bank-editor{
  margin-top:12px;
  border-style:solid;
}
.qb-question-builder-card{
  max-width:980px;
  margin:0 auto;
  padding:20px;
}
.qb-builder-toolbar{
  display:grid;
  grid-template-columns:minmax(260px,1fr) minmax(220px,.75fr);
  gap:14px;
  padding:14px;
  border:1px solid #e5edf4;
  border-radius:16px;
  background:#f8fafc;
  margin-bottom:16px;
}
.qb-pro-builder-form textarea[name="question"]{
  font-size:15px;
  line-height:1.6;
}
.qb-question-filter-card{
  padding:16px;
  margin-bottom:16px;
}
.qb-filter-form label{
  margin-top:0;
}
.qb-filter-row{
  display:flex;
  gap:10px;
  align-items:center;
}
.qb-filter-row select{
  flex:1;
}
.qb-question-list-card{
  padding:18px;
}
.qb-question-editor:not([open])>summary{
  border-bottom:0;
}
.qb-question-editor>summary{
  cursor:pointer;
  display:block;
  line-height:1.65;
}
.qb-question-editor>summary::marker{
  color:#0f766e;
}
.qb-section-loading .qb-pro-panel{
  opacity:.55;
}
@media(max-width:900px){
  .qb-pro-hero,
  .qb-section-head,
  .qb-form-footer{
    display:block;
  }
  .qb-stat-strip{
    min-width:0;
    margin-top:14px;
  }
  .qb-pro-tabs{
    position:static;
    overflow:auto;
  }
  .qb-pro-tab{
    min-width:140px;
    flex:0 0 auto;
  }
  .qb-bank-card-grid,
  .qb-builder-toolbar{
    grid-template-columns:1fr;
  }
  .qb-filter-row{
    display:block;
  }
  .qb-filter-row .btn{
    margin-top:10px;
    width:100%;
  }
}

/* v4.75 unified staff student profile modal inside Course Builder */
.student-detail-modal.full-student-profile-modal{
  width:min(1120px,calc(100vw - 32px))!important;
  padding:0!important;
  overflow:auto!important;
}
.student-detail-modal.full-student-profile-modal .student-modal-body{
  padding:22px!important;
  margin:0!important;
  max-width:none!important;
  background:#fff!important;
  border-radius:0 0 18px 18px!important;
  box-shadow:none!important;
}
.student-detail-modal.full-student-profile-modal .student-modal-head{
  margin:0!important;
  padding:18px 22px!important;
  max-width:none!important;
  border-radius:18px 18px 0 0!important;
}
