/* =========================
   Global
========================= */

:root {
  --brand: #2f6bff;
  --brand-dark: #1f52d6;
  --bg: #f6f8fb;
  --text: #1f2937;
  --radius: 16px;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--brand);
}

a:hover {
  color: var(--brand-dark);
}

.main-container {
  min-height: 80vh;
}

.container {
  max-width: 980px;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* =========================
   Generic cards & buttons
========================= */

.card {
  border: none;
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.btn {
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

/* =========================
   Brand / auth
========================= */

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.card-auth {
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}

.auth-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: rgba(0, 0, 0, 0.6);
}

.btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  border-radius: 14px;
}

.btn-brand:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

/* =========================
   Forms
========================= */

.form-control,
.form-select {
  border-radius: 12px;
  padding: 12px 14px;
}

.form-label {
  font-weight: 600;
}

/* =========================
   Hero
========================= */

.hero {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: white;
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.2);
}

.hero h1 {
  font-size: 1.9rem;
  margin-bottom: 0.5rem;
}

.hero p {
  margin-bottom: 0.75rem;
}

/* =========================
   Category badge
========================= */

.badge-category {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s ease;
}

.badge-category:hover {
  background-color: #dbeafe;
}

/* =========================
   Homepage ad cards
========================= */

.ad-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  object-position: top;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

/* =========================
   My ads cards
========================= */

.ad-card {
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.ad-image-wrapper {
  position: relative;
  overflow: hidden;
}

.ad-image {
  width: 100%;
  height: 155px;
  object-fit: cover;
  display: block;
}

.ad-title {
  font-size: 0.95rem;
  line-height: 1.3;
  min-height: 2.4rem;
  margin-bottom: 0.25rem;
}

.ad-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ad-card:hover .ad-actions {
  opacity: 1;
}

.ad-actions a,
.ad-actions button {
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.ad-actions form {
  margin: 0;
}

.ad-actions a:hover,
.ad-actions button:hover {
  transform: scale(1.08);
}

/* =========================
   Ad page thumbnails
========================= */

.ad-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

.ad-thumb:hover {
  border-color: #2563eb;
}

.ad-thumb-small {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

/* =========================
   Chat
========================= */

.chat-box {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
  max-height: 400px;
  overflow-y: auto;
}

.chat-message {
  display: flex;
  margin-bottom: 8px;
}

.chat-message-me {
  justify-content: flex-end;
}

.chat-message-other {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  background-color: #f3f4f6;
}

.chat-message-me .chat-bubble {
  background-color: #dbeafe;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  margin-bottom: 4px;
  color: #6b7280;
}

.chat-sender {
  font-weight: 600;
}

.chat-text {
  font-size: 0.9rem;
}

.bubble-me {
  background-color: #0d6efd;
  color: #ffffff;
  border-bottom-right-radius: 0.2rem;
  position: relative;
}

.bubble-me::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: #0d6efd;
  border-bottom-right-radius: 10px;
  transform: translateY(1px) rotate(-45deg);
}

.bubble-them {
  background-color: #e5e5ea;
  color: #000;
  border-bottom-left-radius: 0.2rem;
  position: relative;
}

.bubble-them::after {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: #e5e5ea;
  border-bottom-left-radius: 10px;
  transform: translateY(1px) rotate(45deg);
}

.sender-label {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.7;
}

.bubble-me .sender-label {
  color: #ffffff !important;
  text-align: right;
}

.bubble-them .sender-label {
  color: #555;
}

.message-row {
  display: flex;
  margin-bottom: 0.5rem;
  animation: messageFadeIn 0.25s ease-out;
}

.message-time {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  opacity: 0.75;
  text-align: right;
}

@keyframes messageFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================
   Utility
========================= */

.text-truncate {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   Mobile
========================= */

@media (max-width: 576px) {
  .main-container {
    padding: 0 10px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .hero {
    padding: 18px 14px;
  }

  .card {
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  }

  .navbar-brand {
    font-weight: 800;
  }

  .navbar .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .ad-image {
    height: 135px;
  }

  .chat-input-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
  }
}