/* =========================================================
   ES.RA Website Assistant (C+) – CLEAN FINAL STYLES
   - Desktop: higher launcher (premium placement)
   - Card: always anchored to viewport bottom (more space)
   - Mobile: lower, compact, safe-area aware
   - No duplicate overrides
   ========================================================= */

:root{
  --assist-bg: rgba(255,255,255,.10);
  --assist-bg2: rgba(255,255,255,.14);
  --assist-border: rgba(255,255,255,.18);
  --assist-text: #e6ecef;
  --assist-shadow: 0 10px 26px rgba(0,0,0,.45);
  --assist-blue1: #11c3d7;
  --assist-blue2: #0aa7be;
}

/* ===== Launcher Button (Desktop Default) ===== */
.esra-assist-launch{
  position:fixed;
  right:18px;
  bottom:220px; /* High desktop placement (hero zone) */
  z-index:9999;

  display:flex;
  align-items:center;
  gap:12px;
  padding:13px 16px;
  border-radius:999px;

  background:var(--assist-bg);
  border:1px solid var(--assist-border);
  color:var(--assist-text);
  box-shadow:var(--assist-shadow);

  backdrop-filter: blur(12px) saturate(140%) brightness(.92);
  -webkit-backdrop-filter: blur(12px) saturate(140%) brightness(.92);

  cursor:pointer;
  user-select:none;
  transition: transform .18s ease, background .18s ease;
}

.esra-assist-launch:hover{
  transform:translateY(-1px);
  background:var(--assist-bg2);
}

.esra-assist-launch .dot{
  width:12px;
  height:12px;
  border-radius:50%;
  background:linear-gradient(180deg, var(--assist-blue1), var(--assist-blue2));
  box-shadow: 0 0 10px rgba(17,195,215,.7);
}

.esra-assist-launch .label{
  font-weight:900;
  letter-spacing:.02em;
  font-size:15px;
}

/* ===== Modal & Backdrop ===== */
.esra-assist-modal{
  position:fixed;
  inset:0;
  z-index:10000;
  display:none;
}
.esra-assist-modal.open{ display:block; }

.esra-assist-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.55);
}

/* ===== Assistant Card (Desktop) =====
   Anchored to viewport bottom for maximum usable space.
*/
.esra-assist-card{
  position:fixed;
  right:18px;
  left:auto;
  bottom:18px;                 /* Always start from viewport bottom */
  width:380px;
  max-height: calc(100vh - 36px); /* Never exceed viewport height */
  display:flex;
  flex-direction:column;

  border-radius:18px;
  background:rgba(30,33,36,.86);
  border:1px solid rgba(255,255,255,.12);
  box-shadow: 0 18px 40px rgba(0,0,0,.65);

  backdrop-filter: blur(12px) saturate(140%) brightness(.92);
  -webkit-backdrop-filter: blur(12px) saturate(140%) brightness(.92);

  overflow:hidden;
}

/* ===== Header ===== */
.esra-assist-head{
  padding:14px 14px 10px;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  border-bottom:1px solid rgba(255,255,255,.10);
}

.esra-assist-title{
  margin:0;
  font-size:14px;
  font-weight:900;
}

.esra-assist-sub{
  margin:4px 0 0;
  opacity:.9;
  font-size:12px;
  line-height:1.35;
}

.esra-assist-close{
  border:none;
  background:transparent;
  color:var(--assist-text);
  font-size:18px;
  cursor:pointer;
  padding:4px 8px;
  border-radius:10px;
}

.esra-assist-close:hover{
  background:rgba(255,255,255,.08);
}

/* ===== Body (Scrollable) ===== */
.esra-assist-body{
  padding:12px 14px 14px;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}

.esra-assist-row{
  display:grid;
  gap:10px;
  margin-bottom:10px;
}

/* ===== Form Fields ===== */
.esra-assist-field label{
  display:block;
  font-size:12px;
  opacity:.9;
  margin-bottom:6px;
  font-weight:800;
}

.esra-assist-field select,
.esra-assist-field input,
.esra-assist-field textarea{
  width:100%;
  box-sizing:border-box;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  color:var(--assist-text);
  padding:10px 10px;
  outline:none;
  font-size:13px;
}

.esra-assist-field textarea{
  min-height:92px;
  resize:vertical;
}

/* ===== Buttons ===== */
.esra-assist-actions{
  display:grid;
  gap:10px;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  margin-top:12px;
}

.esra-assist-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border-radius:12px;
  padding:10px 10px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.08);
  color:var(--assist-text);
  cursor:pointer;
  font-weight:900;
  font-size:12px;
  text-decoration:none;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.esra-assist-btn:hover{
  transform:translateY(-1px);
  background:rgba(255,255,255,.14);
  box-shadow:0 10px 22px rgba(0,0,0,.45);
}

.esra-assist-btn.primary{
  border:none;
  color:#0c1012;
  background:linear-gradient(90deg, var(--assist-blue1), var(--assist-blue2));
}

.esra-assist-btn.disabled{
  opacity:.45;
  pointer-events:none;
}

/* ===== Mobile Optimization (FINAL) ===== */
@media (max-width:768px){

  /* Lower, smaller launcher to avoid hero/logo overlap */
  .esra-assist-launch{
    right:12px;
    bottom: calc(140px + env(safe-area-inset-bottom));
    padding:8px 11px;
    gap:7px;
  }

  .esra-assist-launch .label{ font-size:12px; }
  .esra-assist-launch .dot{ width:8px; height:8px; }

  /* Full-width responsive card on mobile, anchored to bottom */
  .esra-assist-card{
    left:12px;
    right:12px;
    width:auto;

    bottom: calc(12px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
    border-radius:16px;
  }

  /* Stack action buttons vertically on mobile */
  .esra-assist-actions{ grid-template-columns:1fr; }
}

/* Hide launcher when modal is open (prevents overlap) */
.esra-assist-modal.open + .esra-assist-launch,
.esra-assist-modal.open ~ .esra-assist-launch{
  display:none;
}