* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f4f6fb;
  color: #1c2333;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  background: #3556c9;
  color: #fff;
  font-size: 14px;
}
button:hover { background: #2a45a8; }

input, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccd2e0;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
}

.error { color: #d43a3a; font-size: 13px; min-height: 18px; }
.info { color: #2a7d2a; font-size: 13px; min-height: 18px; }
.link-btn { background: transparent; color: #3556c9; text-decoration: underline; padding: 4px; }

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #1c2333;
  color: #fff;
  padding: 12px 24px;
}
#topbar .logo { font-weight: 700; font-size: 18px; color: #fff; text-decoration: none; }
#topbar .logo:hover { color: #cdd8ff; }
#topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
#topbar button { background: #3556c9; }
#topbar button:hover { background: #4a6ae0; }
#topbar button.active { background: #1c3aa0; outline: 2px solid #7f97ff; }
#topbar button span { margin-left: 4px; }

select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccd2e0;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
  background: #fff;
}

#settings-view label { font-weight: 600; display: block; margin: 14px 0 6px; }
#settings-view .card { margin-bottom: 16px; }
.full-line { width: 100%; margin-top: 8px; }
.full-line.danger { background: #d43a3a; }
.full-line.danger:hover { background: #b52f2f; }

.account-header { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #3556c9;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-pseudo { font-weight: 700; font-size: 17px; }
.account-email { font-size: 13px; color: #667; margin-top: 2px; word-break: break-all; }
.account-status { margin-top: 14px; font-size: 14px; }
.account-status.ok { color: #2a7d2a; }
.account-status.warn { color: #c98a00; }

main { max-width: none; margin: 0; padding: 0 16px; }

.auth-card {
  max-width: 420px;
  margin: 24px auto;
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 6px 24px rgba(28, 35, 51, 0.12);
  text-align: center;
}
.auth-card h1 { margin-bottom: 8px; }
.auth-card p { color: #667; margin-bottom: 20px; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab { flex: 1; background: #e8ecf5; color: #1c2333; }
.tab.active { background: #3556c9; color: #fff; }

#map-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
#map-toolbar input { width: 220px; margin-bottom: 0; }
#sort-info { font-size: 13px; color: #667; }

#picker-map {
  height: 300px;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(28, 35, 51, 0.08);
  margin-bottom: 10px;
  z-index: 0;
}

.hint { font-size: 13px; color: #667; margin-bottom: 6px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 3px 10px rgba(28, 35, 51, 0.08);
}
.card img { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; margin-bottom: 10px; }
.card .price { font-weight: 700; color: #3556c9; margin: 6px 0; }
.card .meta { font-size: 12px; color: #889; }

.conversations { margin-bottom: 16px; }
.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: #fff;
  color: #1c2333;
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(28, 35, 51, 0.07);
  transition: box-shadow 0.12s, transform 0.12s;
}
.conv-item:hover {
  box-shadow: 0 5px 14px rgba(28, 35, 51, 0.14);
  transform: translateY(-1px);
}
.conv-item.active { background: #3556c9; color: #fff; }
.conv-item.active .conv-preview { color: #d5e0ff; }
.conv-item.active .conv-listing { color: #cdd8ff; }
.conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e8ecf5;
  color: #3556c9;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.conv-item.active .conv-avatar { background: #fff; }
.conv-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.conv-listing { font-size: 12px; color: #667; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.conv-preview { font-size: 13px; color: #667; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#listing-chat { border-top: 2px solid #e8ecf5; margin-top: 16px; padding-top: 16px; }
.messages {
  height: 320px;
  overflow-y: auto;
  border: 1px solid #e3e7f0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-window { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 3px 10px rgba(28,35,51,.08); }
.conversation {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 4px 16px;
  max-height: 420px;
  overflow-y: auto;
}
.msg {
  max-width: 75%;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  background: #eef1f8;
  color: #1c2333;
  align-self: flex-start;
}
.msg .author { font-size: 11px; color: #7787a5; display: block; margin-bottom: 2px; }
.msg-time {
  display: inline-block;
  font-size: 10px;
  color: #9aa5bd;
  margin-left: 8px;
  white-space: nowrap;
  vertical-align: bottom;
}
.msg.mine .msg-time { color: #c3d1ff; }
.msg.mine {
  align-self: flex-end;
  background: #3556c9;
  color: #fff;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}
.msg.mine .author { color: #d5e0ff; }
.msg:first-child { margin-top: 4px; }

.conversation-input { display: flex; gap: 8px; }
.conversation-input input { flex: 1; margin-bottom: 0; }

#message-form { display: flex; gap: 8px; }
#message-form input { margin-bottom: 0; flex: 1; }

.listing-card { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
.listing-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(28, 35, 51, 0.16); }

.detail-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.detail-body { display: flex; gap: 16px; align-items: flex-start; }
.detail-body img { width: 200px; height: 150px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.danger-text { color: #d43a3a; }
@media (max-width: 560px) { .detail-body { flex-direction: column; } }

.conv-select { max-width: 240px; margin-bottom: 8px; }

.send-error { margin: 0 0 8px; font-size: 13px; }

.prestation-row { display: flex; gap: 8px; align-items: center; }
.prestation-row input { margin-bottom: 0; }
.price-list { list-style: none; margin: 6px 0; }
.price-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 2px 0; }
.price-list .price-val { font-weight: 700; color: #3556c9; white-space: nowrap; }

.badge {
  background: #d43a3a;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 6px;
  margin-left: 4px;
  font-weight: 700;
}
.layout {
  max-width: 1280px;
  margin: 16px auto 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.layout > main { flex: 1; min-width: 0; }
.ad-side {
  flex-shrink: 0;
  width: 300px;
  position: sticky;
  top: 12px;
}
.ad-slot:empty { display: none; }
.ad-slot:not(:empty) { margin: 12px auto; }
.ad-side:not(:empty) { margin: 16px 0; }
@media (max-width: 1100px) { .ad-side { display: none; } }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  #topbar {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }
  #topbar .logo { font-size: 16px; }
  #topnav { width: 100%; justify-content: space-between; }
  #topnav button {
    padding: 8px 10px;
    font-size: 13px;
    flex: 1;
    justify-content: center;
    text-align: center;
  }
  #topnav button span[data-i18n] { font-size: 12px; }

  main { margin: 0; padding: 0 10px; }
  .layout { margin: 8px auto 16px; }

  .auth-card { margin: 16px auto; padding: 20px 16px; }

  #map-toolbar { gap: 6px; }
  #map-toolbar input { width: 100%; }
  #map-toolbar button { padding: 10px 12px; }

  #picker-map { height: 240px; }

  .grid { grid-template-columns: 1fr; gap: 12px; }
  .card img, .card > img { height: 180px; }

  .detail-body img { width: 100%; height: 200px; }

  .conversation { max-height: 55vh; }
  .msg { max-width: 85%; }

  .conv-item { padding: 10px 12px; }
  .conv-avatar { width: 36px; height: 36px; font-size: 15px; }

  input, textarea, select, button { font-size: 16px; }
  button { min-height: 44px; }
  input, select { min-height: 44px; }

  .prestation-row { flex-wrap: wrap; }
  .prestation-row .prestation-name { flex: 1 1 100%; }
  .prestation-row .prestation-price { flex: 1; }
  .prestation-row .remove-prestation { min-height: 40px; }

  .ad-slot { padding: 0 10px; margin: 8px auto; }
}
