/* Mobile-first responsive styles for Jodoh */
:root{
  --primary:#3498db;
  --success:#2ecc71;
  --bg:#f4f7f6;
  --card:#ffffff;
  --muted:#888;
}
*{box-sizing:border-box}
html,body{height:100%;}
body{
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background:var(--bg);
  margin:0;
  padding:12px;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  min-height:100vh;
}
.container{width:100%; max-width:420px;}
.card{
  background:var(--card);
  padding:16px;
  border-radius:12px;
  box-shadow:0 6px 18px rgba(0,0,0,0.06);
  margin:8px 0 24px 0;
}
.card h3{margin:0 0 16px 0;color:#2c3e50;font-size:22px;}
.card p{margin:8px 0;line-height:1.6;color:#34495e}
.card p strong{color:#2c3e50}
.nickname{font-weight:700;color:#2c3e50;background:#ecf0f1;padding:6px 10px;border-radius:6px;display:inline-block}
.trait-item{margin:8px 0;display:block;padding-left:4px}
button{background:var(--primary);color:#fff;border:none;padding:12px 20px;border-radius:8px;cursor:pointer;font-weight:600;font-size:15px;transition:all 0.2s;box-shadow:0 2px 6px rgba(52,152,219,0.2)}
button:hover{background:#2980b9;transform:translateY(-1px);box-shadow:0 4px 12px rgba(52,152,219,0.3)}
button.small{padding:6px 8px;font-size:14px}
button.full-width{width:100%;margin-bottom:10px}
.match-card{border:1px solid #eee;padding:10px;margin-top:10px;border-radius:8px;background:#fff9e6}
#waiting-area p#status{color:var(--muted);}
.reset-link{font-size:12px;color:#e74c3c;display:inline-block;margin-top:8px}
.loading{color:var(--muted);}

/* Nav: desktop header and mobile footer */
.top-nav{display:none;background:#fff;padding:14px 0;border-bottom:1px solid #eee;position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 2px 8px rgba(0,0,0,0.04)}
.top-nav-inner{max-width:1200px;margin:0 auto;padding:0 20px;display:flex;gap:24px}
.top-nav a{color:#555;text-decoration:none;font-weight:500;transition:color 0.2s;padding:6px 12px;border-radius:6px}
.top-nav a:hover{color:var(--primary);background:#f8f9fa}
.top-nav a.active{font-weight:700;color:var(--primary);background:#e3f2fd}
.bottom-nav{display:none;position:fixed;left:0;right:0;bottom:0;height:56px;background:#fff;border-top:1px solid #eee;justify-content:space-around;align-items:center}
.bottom-nav a{flex:1;text-align:center;padding:8px;color:#333;text-decoration:none;display:flex;flex-direction:column;align-items:center;justify-content:center}
.bottom-nav a svg{width:22px;height:22px;margin-bottom:4px;fill:currentColor}
.bottom-nav a span{font-size:12px;display:block}
.bottom-nav a.active{color:var(--primary);font-weight:700}

/* Badge for unread messages */
.nav-item { position: relative; }
.badge {
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 10px;
  position: absolute;
  top: 5px;
  right: 25%;
  min-width: 16px;
  text-align: center;
  line-height: 1;
  border: 2px solid #fff;
}
.top-nav a { position: relative; }
.top-nav .badge {
  top: -5px;
  right: -5px;
}

/* Traits List Container */
.traits-list-container {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 15px;
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.traits-display-container {
  margin-bottom: 10px;
}
#waiting-area {
  margin-bottom: 30px;
}
#conversations {
  padding-bottom: 40px;
}

/* Chat */
.chat-modal{display:none; position:fixed; right:12px; bottom:12px; width:360px; max-height:70vh; background:#fff; border:1px solid #ddd; border-radius:12px; box-shadow:0 10px 30px rgba(0,0,0,0.08); overflow:hidden; display:flex; flex-direction:column; z-index:9999}
.chat-modal.open{display:flex}
.chat-header{padding:12px;background:var(--primary);color:#fff;display:flex;justify-content:space-between;align-items:center}
.chat-header .title{font-weight:600}
.messages{padding:10px;overflow:auto;flex:1;background:#f7f9fb}
.chat-form{display:flex;padding:10px;border-top:1px solid #eee;background:#fff}
.chat-form input{flex:1;padding:10px;border:1px solid #ddd;border-radius:8px;margin-right:8px}
.chat-form button{background:var(--success);padding:10px 12px;border-radius:8px}

.msg{margin-bottom:8px;font-size:14px}
.msg.self{ text-align:right }
.msg .bubble{display:inline-block;padding:8px;border-radius:10px;max-width:78%;}
.msg.self .bubble{background:#dcf8c6}
.msg.other .bubble{background:#fff;border:1px solid #eee}
.del-btn{cursor:pointer;font-size:12px;margin:0 6px;opacity:0.5;vertical-align:middle}
.del-btn:hover{opacity:1}

/* Mobile: bottom-sheet style (avoid covering entire screen) */
@media (max-width:768px){
  body{padding:8px;padding-bottom:120px} /* ensure space for footer nav on larger phones */
  .card{padding:12px;border-radius:10px;margin-bottom:40px}
  /* Keep chat modal compact on mobile: bottom sheet with modest height */
  .chat-modal{left:12px;right:12px;bottom:12px;top:auto;width:auto;max-width:calc(100% - 24px);max-height:50vh;border-radius:12px}
  .chat-modal .messages{max-height:calc(50vh - 120px);}
  .chat-header{padding:14px}
  .messages{padding:14px;padding-bottom:80px}
  .chat-form{position:sticky;bottom:56px;padding:10px;background:#fff;border-top:1px solid #eee;z-index:9000}
  /* show bottom nav on mobile */
  .bottom-nav{display:flex;z-index:10000}
  .bottom-nav a{display:flex;flex-direction:column;align-items:center;font-size:13px}
}

/* Desktop: show top nav, hide bottom nav */
@media (min-width:769px){
  .top-nav{display:block}
  .bottom-nav{display:none}
  body{padding-top:80px}
  .container{max-width:1200px;width:100%;padding:0 20px}
  .card{padding:40px;border-radius:16px;box-shadow:0 4px 20px rgba(0,0,0,0.08)}
  .card h3{font-size:28px;margin-bottom:24px}
}

/* Backdrop for modal */
.chat-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.2);z-index:9998}
.chat-backdrop.open{display:block}

/* Slight elevation when open */
.chat-modal.open{box-shadow:0 16px 40px rgba(0,0,0,0.16);}

/* Conversation List Styles */
.conv-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}
.conv-item:hover {
  background: #f9f9f9;
}
.conv-item:last-child {
  border-bottom: none;
}
.conv-avatar {
  width: 48px;
  height: 48px;
  background: #e0e0e0;
  color: #555;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
  margin-right: 12px;
  flex-shrink: 0;
}
.conv-info {
  flex: 1;
  min-width: 0; /* allows text truncation */
}
.conv-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.conv-name {
  font-weight: 600;
  color: #2c3e50;
  font-size: 16px;
}
.conv-time {
  font-size: 12px;
  color: #95a5a6;
}
.conv-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.conv-preview {
  color: #7f8c8d;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}
.conv-badge {
  background: var(--success);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  font-weight: bold;
}
.conv-del-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  border: 1px solid #eee;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  padding: 0;
}
.conv-item-wrapper:hover .conv-del-btn {
  opacity: 1;
}
/* Always show on mobile */
@media (max-width: 768px) {
  .conv-del-btn {
    opacity: 1;
    background: transparent;
    border: none;
    box-shadow: none;
    right: 5px;
  }
}

/* Desktop tweaks */
@media (min-width:601px){
  body{padding:40px}
  .trait-item{margin:12px 0;font-size:15px}
  .match-card{padding:16px;margin-top:14px}
}
