/* =========================================================================
   BinBot Resident Portal • Master Stylesheet
   ========================================================================= */

:root {
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-main: #0B0F19;
  --bg-card: #131B2E;
  --bg-card-hover: #1A243D;
  --bg-elevated: #1E293B;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;

  --brand-primary: #2563EB;
  --brand-sky: #38BDF8;
  --brand-green: #10B981;
  --brand-amber: #F59E0B;
  --brand-red: #EF4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Toast */
.toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand-green);
  color: white;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.toast-popup.show {
  transform: translateY(0);
  opacity: 1;
}

/* Header */
.portal-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 900;
  backdrop-filter: blur(12px);
}

.header-content {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  height: 52px;
  width: auto;
}

.portal-badge {
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.15);
  color: var(--brand-sky);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

/* Layout */
.portal-layout {
  flex: 1;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 960px) {
  .portal-layout {
    grid-template-columns: 1fr;
  }
}

.portal-left-col, .portal-right-col {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Resident Profile Card */
.resident-card {
  background: linear-gradient(135deg, #131E38 0%, #0F172A 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.res-card-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.avatar-box {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 2px solid var(--brand-sky);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.res-info {
  flex: 1;
}

.res-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.res-address {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.res-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--brand-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-top: 0.25rem;
}

.res-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
}
.meta-row strong {
  color: var(--text-main);
}

.status-ok {
  color: var(--brand-green);
  font-weight: 700;
}

.res-card-actions {
  display: flex;
  gap: 0.75rem;
}

/* Bin Control Card */
.bin-control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.latch-status-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-green);
  background: rgba(16, 185, 129, 0.12);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.dot-secure {
  color: var(--brand-green);
}

/* Bin Action Tiles */
.bin-tiles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.bin-tile {
  border-radius: var(--radius-md);
  padding: 1.2rem;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.bin-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.tile-recycling { border-left: 4px solid var(--brand-green); }
.tile-general { border-left: 4px solid #94A3B8; }
.tile-food { border-left: 4px solid var(--brand-amber); }

.bin-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.bin-num-badge {
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.bin-type-icon {
  font-size: 1.4rem;
}

.bin-tile-name {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.bin-tile-rule {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.btn-unlock {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  font-family: var(--font-main);
  transition: opacity 0.2s ease;
}
.btn-unlock:hover { opacity: 0.9; }

.btn-unlock-green { background: #059669; color: white; }
.btn-unlock-slate { background: #475569; color: white; }
.btn-unlock-amber { background: #D97706; color: white; }

/* Unlock Countdown Banner */
.unlock-countdown-banner {
  background: linear-gradient(135deg, #064E3B 0%, #0F172A 100%);
  border: 2px solid var(--brand-green);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.6); }
  100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
}

.countdown-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--brand-green);
  color: #022C22;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.countdown-text h4 {
  font-size: 1.05rem;
  color: #6EE7B7;
  margin-bottom: 0.2rem;
}
.countdown-text p {
  font-size: 0.8rem;
  color: #D1FAE5;
}

/* Activity Feed Card */
.activity-feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.status-pill-live {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--brand-green);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.activity-item {
  background: var(--bg-elevated);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-color);
}
.activity-item strong {
  color: var(--brand-sky);
}
.activity-time {
  color: var(--text-dim);
  font-size: 0.72rem;
}

.activity-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  padding: 1rem;
}

/* Chat Card */
.chat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-bot-icon {
  width: 32px;
  height: 32px;
}

.chat-bot-name {
  font-weight: 800;
  font-size: 1rem;
}

.chat-bot-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.channel-pills {
  display: flex;
  gap: 0.5rem;
}

.ch-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border-color);
}
.ch-tag.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--brand-sky);
  border-color: rgba(56, 189, 248, 0.3);
}
.ch-wa {
  background: rgba(37, 211, 102, 0.15);
  color: #25D366;
  border-color: rgba(37, 211, 102, 0.3);
}

.chat-messages {
  min-height: 280px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
}

.msg-bubble {
  max-width: 85%;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
}

.msg-bot {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.msg-user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: white;
  border-bottom-right-radius: 2px;
}

.quick-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.chip-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-main);
  transition: all 0.2s ease;
}
.chip-btn:hover {
  color: var(--brand-sky);
  border-color: var(--brand-sky);
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
}
.chat-input:focus {
  border-color: var(--brand-sky);
}

/* Waste Search Card */
.waste-search-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.search-input-wrap {
  margin-bottom: 1rem;
}

.waste-search-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
}
.waste-search-input:focus {
  border-color: var(--brand-sky);
}

.waste-results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
}

.waste-item-row {
  background: var(--bg-elevated);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
}

.waste-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.tag-recycling { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.tag-food { background: rgba(245, 158, 11, 0.15); color: #F59E0B; }
.tag-general { background: rgba(148, 163, 184, 0.15); color: #94A3B8; }
.tag-hazardous { background: rgba(239, 68, 68, 0.15); color: #EF4444; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-head h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
}
.form-control:focus {
  border-color: var(--brand-sky);
}

.form-check-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1.25rem 0;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-label a {
  color: var(--brand-sky);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.2s ease;
}
.btn:hover { opacity: 0.9; }

.btn-primary {
  background: var(--brand-primary);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  border-color: var(--brand-sky);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--brand-red);
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

/* Footer */
.portal-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-top: auto;
}

.footer-content {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.footer-nav {
  display: flex;
  gap: 1.25rem;
}
.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
}
.footer-nav a:hover {
  color: var(--brand-sky);
}
