/*
 * AIOS V24.1 — scoped visual polish after the V24 theme layer.
 * Auth / admin request content / request chat / compact metric cards /
 * permission search + user-role select. No JS, data, or workflow changes.
 */

/* 1. AUTH: a single, cohesive split-screen instead of a card inside a card. */
body.auth-body {
  overflow-x:hidden;
}
body.auth-body .auth-experience {
  width:min(1040px,100%);
  min-height:580px;
  grid-template-columns:minmax(0,.88fr) minmax(0,1.12fr);
  border-radius:23px;
  overflow:hidden;
}
body.auth-body .auth-showcase {
  padding:26px 27px 28px;
}
body.auth-body .auth-showcase-top {
  position:relative;
  z-index:1;
  align-items:center;
  gap:10px;
}
body.auth-body .auth-showcase-top img {
  display:block;
  width:44px;
  height:44px;
  border-radius:12px;
}
body.auth-body .ava-auth-illustration {
  min-height:260px;
  isolation:isolate;
}
body.auth-body .ava-auth-illustration::before {
  content:"";
  position:absolute;
  inset:auto;
  width:min(290px,92%);
  aspect-ratio:1;
  border-radius:50%;
  background:radial-gradient(circle,rgba(28,215,198,.24),rgba(10,174,166,.09) 45%,transparent 73%);
  z-index:-1;
  pointer-events:none;
}
body.auth-body .ava-auth-illustration .ava-mascot--auth {
  display:flex;
  width:clamp(155px,15vw,218px);
  height:clamp(155px,15vw,218px);
  max-width:none;
}
body.auth-body .auth-showcase-bottom h2 {
  font-size:clamp(21px,2.5vw,26px);
  line-height:1.45;
}
body.auth-body .auth-showcase-bottom p {
  font-size:12px;
  line-height:1.75;
}
body.auth-body .auth-workspace {
  min-width:0;
  padding:clamp(22px,3vw,38px) clamp(20px,3.8vw,48px);
}
body.auth-body .auth-card,
html[data-theme="light"] body.auth-body .auth-card,
html[data-theme="light"] body.auth-body .auth-login-card,
html[data-theme="light"] body.auth-body .register-card {
  background:transparent!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  padding:0!important;
}
body.auth-body .auth-login-card {
  max-width:435px;
}
body.auth-body .auth-card h1 {
  margin:8px 0 16px;
  font-size:clamp(23px,2.7vw,27px);
  line-height:1.45;
}
body.auth-body .auth-card .field {
  margin:12px 0;
}
body.auth-body .auth-card .field input {
  min-height:47px;
  font-size:14px;
}
body.auth-body .auth-card .btn.wide {
  min-height:45px;
}
body.auth-body .auth-card label.check,
body.auth-body .auth-workspace label.check {
  color:#e0eef3!important;
  font-size:12px;
  line-height:1.6;
}
html[data-theme="light"] body.auth-body .auth-card label.check,
html[data-theme="light"] body.auth-body .auth-workspace label.check {
  color:#2e5060!important;
}
html[data-theme="light"] body.auth-body .auth-card label.check input[type="checkbox"] {
  accent-color:#007470;
}
body.auth-body .auth-card .auth-link-button,
html[data-theme="light"] body.auth-body .auth-card .auth-link-button {
  background:transparent!important;
  border:0!important;
  box-shadow:none!important;
  padding:6px 1px!important;
  text-decoration:underline;
  text-underline-offset:3px;
}
body.auth-body .auth-card .auth-link-button { color:#9be8dc!important; }
html[data-theme="light"] body.auth-body .auth-card .auth-link-button { color:#006b61!important; }
body.auth-body .register-choice { gap:9px; margin-top:15px; }
body.auth-body .register-choice .btn { min-width:0; white-space:normal; text-align:center; }
html[data-theme="light"] body.auth-body .auth-workspace {
  background:#fff!important;
  color:#193e4e!important;
}
html[data-theme="light"] body.auth-body .auth-showcase {
  background:radial-gradient(circle at 52% 45%,rgba(0,181,174,.2),transparent 49%),linear-gradient(152deg,#0e3d48,#0b293a 59%,#071b2a)!important;
}
html[data-theme="light"] body.auth-body .auth-experience {
  background:#fff!important;
  border:1px solid #d5e5e9;
  box-shadow:0 18px 60px rgba(24,57,76,.12);
}
html[data-theme="light"] body.auth-body .auth-card :is(h1,h2),
html[data-theme="light"] body.auth-body .auth-card .field label { color:#193c4c!important; }
html[data-theme="light"] body.auth-body .auth-kicker { color:#087d70!important; }

/* 2. Admin /Requests labels and values: protect against old dark text overrides. */
html:not([data-theme="light"]) body.ai-platform :is(.rep-info-grid,.analysis-grid,.warranty-summary,.inspection-summary) > div > strong,
html:not([data-theme="light"]) body.ai-platform .page-content :is(.representative-card,.representative-result-card,.warranty-calculation-card,.customer-comment-card,.admin-rating-card) strong,
html:not([data-theme="light"]) body.ai-platform .page-content .table-card tbody td strong,
html:not([data-theme="light"]) body.ai-platform .page-content .section-head strong {
  color:#eff9fd!important;
}
html:not([data-theme="light"]) body.ai-platform .page-content .card > strong {color:#f2fbfd!important}
html:not([data-theme="light"]) body.ai-platform :is(.rep-info-grid,.analysis-grid) > div > small {color:#b3c9d5!important}
html[data-theme="light"] body.ai-platform :is(.rep-info-grid,.analysis-grid,.warranty-summary,.inspection-summary) > div > strong,
html[data-theme="light"] body.ai-platform .page-content :is(.representative-card,.representative-result-card,.warranty-calculation-card,.customer-comment-card,.admin-rating-card) strong,
html[data-theme="light"] body.ai-platform .page-content .card > strong {
  color:#163f50!important;
}

/* 3. Chat: compact content-sized bubbles in *both* themes, preserving alignment. */
body.ai-platform .chat-card {padding:15px!important}
body.ai-platform .chat-card .section-head {margin-bottom:9px!important}
body.ai-platform .chat-card .chat-thread {
  display:flex!important;
  flex-direction:column!important;
  gap:6px!important;
  min-height:64px!important;
  max-height:230px!important;
  padding:9px!important;
  border-radius:11px!important;
  overflow-y:auto!important;
  align-items:stretch;
}
body.ai-platform .chat-card .chat-message {
  box-sizing:border-box!important;
  flex:0 0 auto!important;
  width:max-content!important;
  min-width:0!important;
  max-width:min(57%,350px)!important;
  padding:6px 9px!important;
  margin:0!important;
  font-size:11.5px!important;
  line-height:1.55!important;
  border-radius:10px!important;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}
body.ai-platform .chat-card .chat-message.system {
  align-self:center;
  width:fit-content!important;
  max-width:min(76%,460px)!important;
  padding:6px 11px!important;
  font-size:11px!important;
}
body.ai-platform .chat-card .chat-message.admin {align-self:flex-start}
body.ai-platform .chat-card .chat-message.user {align-self:flex-end}
body.ai-platform .chat-card .chat-meta {
  display:flex;
  gap:9px!important;
  margin-bottom:2px!important;
  align-items:center;
  flex-wrap:wrap;
}
body.ai-platform .chat-card .chat-meta :is(strong,time) {
  font-size:9.5px!important;
  line-height:1.35!important;
}
body.ai-platform .chat-card .chat-compose {margin-top:7px!important;gap:7px!important}
body.ai-platform .chat-card .chat-compose textarea {
  min-height:40px!important;
  max-height:100px!important;
  padding:7px 9px!important;
  font-size:12px!important;
}
body.ai-platform .chat-card .chat-compose .btn {min-height:39px!important;padding:8px 12px!important}

/* 4. Metrics: reduce empty space in the horizontal KPI strip. */
body.ai-platform .metric-grid {
  gap:8px!important;
  margin-bottom:12px!important;
}
body.ai-platform .metric-grid > .metric {
  min-height:75px!important;
  padding:11px 12px!important;
  border-radius:11px!important;
  box-shadow:none!important;
}
body.ai-platform .metric-grid > .metric::before {width:3px!important}
body.ai-platform .metric-grid > .metric::after {width:80px!important;height:80px!important}
body.ai-platform .metric-grid > .metric small {
  font-size:11px!important;
  line-height:1.35!important;
  margin-bottom:4px!important;
}
body.ai-platform .metric-grid > .metric strong {
  font-size:clamp(19px,1.8vw,24px)!important;
  line-height:1.25!important;
}

/* 5. Admin Permissions: a clear light search field, role selector, and focus state. */
body.ai-platform .permission-toolbar,
body.ai-platform .permission-toolbar .permission-search {
  min-width:0;
}
body.ai-platform .permission-search {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
  width:100%;
}
body.ai-platform .permission-search input[name="search"] {
  flex:1 1 240px;
  min-width:0;
  min-height:42px!important;
  border-radius:10px!important;
}
body.ai-platform .permission-search .btn {min-height:42px!important}
body.ai-platform .role-form {min-width:0;align-items:center}
body.ai-platform .role-form .search-select {min-width:150px;max-width:210px}
body.ai-platform .role-form .search-select__control {min-height:38px;border-radius:9px}
html[data-theme="light"] body.ai-platform .permission-toolbar {
  background:#fff!important;
  border:1px solid #d5e4e8!important;
  box-shadow:none!important;
}
html[data-theme="light"] body.ai-platform .permission-search input[name="search"],
html[data-theme="light"] body.ai-platform .role-form :is(select,.search-select__control,.search-select__search) {
  background:#fff!important;
  color:#153b4c!important;
  border:1px solid #b8d2dc!important;
  box-shadow:none!important;
}
html[data-theme="light"] body.ai-platform .permission-search input[name="search"]::placeholder {
  color:#687e8a!important;
  opacity:1!important;
}
html[data-theme="light"] body.ai-platform .permission-search input[name="search"]:focus,
html[data-theme="light"] body.ai-platform .role-form .search-select__control:focus-within {
  outline:0!important;
  border-color:#007470!important;
  box-shadow:0 0 0 3px rgba(0,116,112,.14)!important;
}
html[data-theme="light"] body.ai-platform .role-form .search-select__value {color:#234a59!important}
html[data-theme="light"] body.ai-platform .role-form .search-select__menu,
html[data-theme="light"] body.ai-platform .role-form .search-select__options {
  background:#fff!important;
  border-color:#c6dbe3!important;
  color:#193e4e!important;
}
html[data-theme="light"] body.ai-platform .role-form .search-select__option:hover,
html[data-theme="light"] body.ai-platform .role-form .search-select__option.is-selected {
  background:#e1f4ee!important;
  color:#006c62!important;
}
html[data-theme="light"] body.ai-platform .permission-matrix td:first-child :is(strong,small) {color:#1b4655!important}
html[data-theme="light"] body.ai-platform .permission-switch :is(span,label) {color:#325363!important}

@media(max-width:700px) {
  body.auth-body {padding:60px 12px 20px!important;align-items:flex-start!important}
  body.auth-body .auth-experience {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    min-height:0;
    width:100%;
    border-radius:18px;
  }
  body.auth-body .auth-showcase {
    display:flex;
    min-height:72px;
    padding:13px 18px;
    justify-content:center;
  }
  body.auth-body .auth-showcase-top {
    align-self:flex-start;
    gap:10px;
  }
  body.auth-body .auth-showcase-top img{width:37px;height:37px}
  body.auth-body .auth-showcase-bottom,
  body.auth-body .ava-auth-illustration {display:none!important}
  body.auth-body .auth-workspace {padding:20px 18px 23px}
  body.auth-body .auth-card h1{font-size:24px;margin:7px 0 13px}
  body.auth-body .auth-card .field{margin:10px 0}
  body.auth-body .auth-card .field input{min-height:44px}
  body.auth-body .auth-card .register-choice{gap:7px}
  body.auth-body .auth-card .register-choice .btn{font-size:11px;padding-inline:8px}
  body.ai-platform .chat-card {padding:12px!important}
  body.ai-platform .chat-card .chat-message {max-width:82%!important}
  body.ai-platform .chat-card .chat-message.system {max-width:92%!important}
  body.ai-platform .chat-card .chat-thread {max-height:230px!important}
  body.ai-platform .metric-grid > .metric {min-height:68px!important;padding:9px 10px!important}
  body.ai-platform .metric-grid > .metric strong{font-size:20px!important}
  body.ai-platform .permission-search input[name="search"]{flex-basis:100%;width:100%}
  body.ai-platform .permission-search .btn{min-height:39px!important}
  body.ai-platform .role-form .search-select{min-width:125px;width:160px;max-width:100%}
}
@media(max-width:400px) {
  body.auth-body .auth-workspace {padding:17px 14px 21px}
  body.ai-platform .chat-card .chat-message{max-width:90%!important}
  body.ai-platform .metric-grid{gap:7px!important}
  body.ai-platform .metric-grid > .metric small{font-size:10px!important}
}
@media(prefers-reduced-motion:reduce) {
  body.auth-body .ava-auth-illustration .ava-mascot--auth img{animation:none!important}
}

/* QA follow-up: these nested request detail cards were not themed by V24. */
html[data-theme="light"] body.ai-platform .page-content .rep-info-grid > div,
html[data-theme="light"] body.ai-platform .page-content .analysis-grid > div {
  background:#f4f9fa!important;
  border:1px solid #d1e3e9!important;
  color:#1e4554!important;
  box-shadow:none!important;
}
html[data-theme="light"] body.ai-platform .page-content .rep-info-grid > div small,
html[data-theme="light"] body.ai-platform .page-content .analysis-grid > div small {
  color:#577380!important;
}
html[data-theme="light"] body.ai-platform .page-content .rep-info-grid > div strong,
html[data-theme="light"] body.ai-platform .page-content .analysis-grid > div strong {
  color:#163f50!important;
}
/* The permission search FORM itself inherited a dark background; fix its surface. */
html[data-theme="light"] body.ai-platform .permission-toolbar .permission-search {
  background:transparent!important;
  border:0!important;
  color:#244b5b!important;
  box-shadow:none!important;
  padding:0!important;
}
/* One brand mark in the showcase is enough on login; avoids double logo. */
body.auth-body .auth-login-card .brand-mark{display:none!important}
