/* Meddelanden – modern, enkel UI (scopad via body.msg-page) */

/* Meddelandesidor ska följa samma bakgrund/gradient som resten av sajten.
   Viktigt: sätt inte `background: transparent` här, annars syns HTML:ens vita bakgrund.
   Vi låter därför body behålla sajtens globala bakgrund (theme-runtime.css). */

.msg-wrap{ max-width:980px; margin:18px auto; padding:0 14px 24px; }

.msg-card{
  background:#fff;
  border:1px solid rgba(0,0,0,.08);
  border-radius:16px;
  box-shadow:0 10px 30px rgba(0,0,0,.06);
}

.msg-card-hd{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid rgba(0,0,0,.06);
}

.msg-title{ margin:0; font-size:20px; }
.msg-sub{ margin:4px 0 0; opacity:.75; font-size:13px; }

.msg-list{ display:grid; gap:10px; padding:14px; }

/* Rad-wrapper så vi kan ha en radera-knapp bredvid länken */
.msg-item{
  display:flex;
  gap:10px;
  align-items:stretch;
}

.msg-item .msg-thread{ flex:1; }

.msg-del{
  display:flex;
  align-items:center;
  margin:0;
}

.msg-delbtn{
  width:44px;
  height:44px;
  border-radius:14px;
  border:1px solid rgba(0,0,0,.10);
  background:#fff;
  cursor:pointer;
  transition: transform .15s, box-shadow .2s, background .2s;
  font-size:18px;
  line-height:1;
}

.msg-delbtn:hover{
  transform: translateY(-1px);
  box-shadow:0 10px 20px rgba(0,0,0,.08);
  background: rgba(239,68,68,.06);
}

.msg-delbtn:active{ transform: translateY(0px) scale(.98); }

/* Inbox-rader (trådar) – mer "proffsigt" upplägg */
.msg-thread{
  display:grid;
  grid-template-columns: 12px 64px 1fr;
  gap:12px;
  align-items:start;
  padding:14px;
  border:1px solid rgba(0,0,0,.07);
  border-radius:16px;
  text-decoration:none;
  color:inherit;
  background:#fff;
  transition: box-shadow .2s, transform .2s, background .2s, border-color .2s;
}

.msg-thread:hover{
  box-shadow:0 12px 26px rgba(0,0,0,.08);
  transform:translateY(-1px);
}

.msg-thread.is-unread{
  background: rgba(2,132,199,.06);
  border-color: rgba(2,132,199,.25);
}

.msg-dot{
  width:10px;
  height:10px;
  margin-top:6px;
  border-radius:999px;
  background: rgba(2,132,199,.95);
  box-shadow: 0 0 0 5px rgba(2,132,199,.12);
  opacity:0;
}
.msg-thread.is-unread .msg-dot{ opacity:1; animation: msgPulse 1.8s ease-in-out infinite; }
@keyframes msgPulse{
  0%, 100%{ transform: scale(1); box-shadow: 0 0 0 5px rgba(2,132,199,.12); }
  50%{ transform: scale(1.06); box-shadow: 0 0 0 7px rgba(2,132,199,.08); }
}

.msg-thumb{
  width:64px;
  height:64px;
  border-radius:12px;
  object-fit:cover;
  border:1px solid rgba(0,0,0,.10);
  background:#fff;
}

.msg-main{ min-width:0; }

.msg-row1{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
}
.msg-adtitle{
  font-weight:900;
  font-size:16px;
  line-height:1.2;
}
.msg-time{
  font-size:12px;
  opacity:.75;
  white-space:nowrap;
}

.msg-row2{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-top:2px;
}
.msg-with{ font-size:13px; opacity:.85; }

.msg-meta{ font-size:13px; opacity:.75; margin-top:4px; }

.msg-snippet{
  margin-top:8px;
  font-size:14px;
  opacity:.88;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

.msg-unreadpill{
  display:inline-flex;
  padding:4px 10px;
  border-radius:999px;
  background: rgba(2,132,199,.12);
  border: 1px solid rgba(2,132,199,.22);
  color:#075985;
  font-size:12px;
  font-weight:800;
}

.msg-pill{
  display:inline-flex;
  padding:4px 10px;
  border-radius:999px;
  background:rgba(2,132,199,.10);
  border:1px solid rgba(2,132,199,.18);
  font-size:12px;
  font-weight:700;
  color:#075985;
}

/* Header-badge + toolbar */
.msg-unreadline{ margin-top:8px; }
.msg-unreadbadge{
  display:inline-flex;
  gap:8px;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background: rgba(2,132,199,.10);
  border: 1px solid rgba(2,132,199,.18);
  font-size:12px;
  font-weight:800;
  color:#075985;
}

.msg-toolbar{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:0 16px 14px;
  flex-wrap:wrap;
}
.msg-toolbar-left, .msg-toolbar-right{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.msg-toolbar .btn-primary{
  color:#fff;
  border-color: rgba(2,132,199,.30);
  background: linear-gradient(135deg, rgba(2,132,199,.95), rgba(59,130,246,.95));
  box-shadow: 0 10px 22px rgba(2,132,199,.18);
}
.msg-search{
  height: var(--btn-h);
  padding: 0 12px;
  border-radius: var(--btn-radius);
  border: 1px solid rgba(0,0,0,.14);
  min-width: 240px;
  outline:none;
  background:#fff;
}
.msg-search:focus{ border-color: rgba(2,132,199,.55); box-shadow: 0 0 0 4px rgba(2,132,199,.14); }

/* Mobil */
@media (max-width: 640px){
  .msg-thread{ grid-template-columns: 12px 54px 1fr; padding:12px; }
  .msg-thumb{ width:54px; height:54px; }
  .msg-search{ min-width: 160px; flex: 1; }
  .msg-row1{ flex-direction:column; align-items:flex-start; }
  .msg-time{ opacity:.7; }
}

.msg-ad{
  display:flex;
  gap:12px;
  align-items:center;
  padding:12px;
  border:1px solid rgba(0,0,0,.07);
  border-radius:14px;
  background:rgba(0,0,0,.02);
}

.msg-listing-thumb{
  width:92px;
  height:70px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.08);
  object-fit:cover;
  background:#fff;
}

.msg-lst-head{ font-weight:900; margin:0; }
.msg-lst-meta{ opacity:.8; font-size:13px; margin-top:4px; display:flex; gap:10px; flex-wrap:wrap; }

.msg-thread-body{ padding:14px 16px 16px; }
.msg-bubbles{ display:grid; gap:10px; padding:10px 0 16px; }

.msg-bubble{
  max-width:78%;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid rgba(0,0,0,.08);
  background:#fff;
}

.msg-bubble.me{
  margin-left:auto;
  background:rgba(2,132,199,.08);
  border-color:rgba(2,132,199,.18);
}

.msg-bubble-meta{ margin-top:6px; opacity:.65; font-size:12px; display:flex; gap:8px; align-items:center; }

.msg-form{ display:grid; gap:10px; padding-top:12px; border-top:1px solid rgba(0,0,0,.06); }
.msg-form textarea{
  width:100%;
  min-height:110px;
  resize:vertical;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(0,0,0,.14);
  outline:none;
}
.msg-form textarea:focus{
  border-color:rgba(2,132,199,.6);
  box-shadow:0 0 0 4px rgba(2,132,199,.15);
}

.msg-actions{ display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; }


/* Popup-läge (iframe/modal): göm site-header och gör kortet mer kompakt */
body.msg-page.msg-popup .header{ display:none; }
body.msg-page.msg-popup .msg-wrap{ margin:0 auto; padding:12px; }
body.msg-page.msg-popup .msg-card{ border-radius:14px; box-shadow:0 10px 30px rgba(0,0,0,.10); }
body.msg-page.msg-popup .msg-card-hd{ position:sticky; top:0; background:inherit; }
body.msg-page.msg-popup .msg-popupbar{ display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 14px; border-bottom:1px solid rgba(0,0,0,.06); }
body.msg-page.msg-popup .msg-popupbar .btn{ padding:8px 10px; }
