/* =====================================================
   ENGAJAR CONTATOS — Mobile-First CSS
   Paleta inspirada no site rjsites.com.br/engajaai/
   ===================================================== */

:root {
  --bg: #0f1117;
  --bg2: #181c27;
  --bg3: #1e2335;
  --card: #1a1f2e;
  --border: #2a3050;
  --accent: #4ade80;
  --accent2: #22c55e;
  --accent-glow: rgba(74, 222, 128, 0.25);
  --text: #e2e8f0;
  --muted: #64748b;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.fw-900 { font-weight: 900 !important; }
.text-accent { color: var(--accent) !important; }
.ls-wide { letter-spacing: .08em; }


/* =====================================================
   AUTH SCREEN
   ===================================================== */

#authScreen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(74,222,128,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(34,197,94,.08) 0%, transparent 60%),
    var(--bg);
}

/* Mobile hero bar */
.auth-hero-bar {
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 20px 18px;
  text-align: center;
}

.auth-hero-logo {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 4px;
}

.auth-hero-sub {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  margin: 0;
}

/* Wrapper */
.auth-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 0 24px;
}

.auth-container {
  width: 100%;
  max-width: 920px;
  display: flex;
  flex-direction: column;
}

/* Auth panels */
.auth-panel {
  width: 100%;
  padding: 0;
}

.auth-panel-login {
  order: 1;
}
.auth-panel-register {
  order: 2;
  display: none; /* hidden on mobile by default */
}

/* On mobile: toggle via JS */
.auth-panel-register.mobile-active {
  display: block;
}
.auth-panel-login:has(~ .auth-panel-register.mobile-active) {
  display: none;
}

/* Fallback for has() */
.auth-panel-login.mobile-hidden {
  display: none;
}

.auth-panel-inner {
  padding: 24px 20px 20px;
}

/* Desktop layout */
@media (min-width: 768px) {
  .auth-wrapper {
    padding: 40px 24px 32px;
    justify-content: center;
  }

  .auth-container {
    flex-direction: row;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 24px 80px rgba(0,0,0,.5);
  }

  .auth-panel {
    flex: 1;
    display: block !important;
  }

  .auth-panel-login {
    background: linear-gradient(145deg, #1a2a1a 0%, #12201a 50%, var(--bg2) 100%);
    border-right: 1px solid var(--border);
    position: relative;
    overflow: hidden;
  }

  .auth-panel-login::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 220px; height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74,222,128,.15) 0%, transparent 70%);
    pointer-events: none;
  }

  .auth-panel-register {
    background: var(--bg2);
    display: block;
  }

  .auth-panel-inner {
    padding: 48px 40px;
  }

  .auth-switch-link { display: none !important; }
  .auth-divider { display: none !important; }
}

/* Brand */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.auth-brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.auth-brand-name {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--text);
}

/* Badge */
.auth-badge {
  display: inline-block;
  background: var(--accent-glow);
  border: 1px solid rgba(74,222,128,.4);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}

.auth-badge-green {
  background: rgba(34,197,94,.1);
  border-color: rgba(34,197,94,.3);
  color: var(--accent2);
}

/* Heading */
.auth-heading { margin-bottom: 24px; }

.auth-title {
  font-size: 1.6rem;
  font-weight: 900;
  margin: 6px 0 6px;
  color: var(--text);
  line-height: 1.2;
}

@media (min-width: 768px) {
  .auth-title { font-size: 2rem; }
}

.auth-desc {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
  margin: 0;
}

/* Input group */
.input-group-custom {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .95rem;
  z-index: 2;
  pointer-events: none;
}

.fc-icon {
  padding-left: 40px !important;
}

/* Divider mobile */
.auth-divider {
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  padding: 16px 20px 8px;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 12%; }
.auth-divider::after { right: 12%; }

/* Auth footer */
.auth-footer-note {
  margin-top: 20px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

.auth-tagline {
  margin-top: 20px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  text-align: center;
}


/* =====================================================
   BUTTONS
   ===================================================== */

.btn-accent {
  background: var(--accent);
  color: #0f1117 !important;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: all .2s;
  font-size: .92rem;
  white-space: nowrap;
}

.btn-accent:hover, .btn-accent:focus {
  background: var(--accent2);
  color: #0f1117 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-accent-outline {
  background: transparent;
  color: var(--accent) !important;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: all .2s;
}

.btn-accent-outline:hover {
  background: var(--accent);
  color: #0f1117 !important;
  box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  transition: all .15s;
}

.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.btn-ghost-sm {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: .88rem;
  transition: color .15s;
}

.btn-ghost-sm:hover { color: var(--text); }


/* =====================================================
   FORM CONTROLS
   ===================================================== */

.fc-custom {
  background: var(--bg3) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  font-size: .95rem;
  padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}

.fc-custom:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(74,222,128,.15) !important;
  outline: none !important;
  background: var(--bg3) !important;
}

.fc-custom::placeholder { color: var(--muted) !important; }

/* Select arrow color */
select.fc-custom {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 14px !important;
  padding-right: 36px !important;
}

/* Textarea */
textarea.fc-custom { resize: vertical; min-height: 96px; }

/* Form label */
.form-label {
  color: var(--text);
  font-size: .88rem;
  margin-bottom: 6px;
}


/* =====================================================
   NAVBAR
   ===================================================== */

.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: .95rem !important;
  color: var(--text) !important;
}


/* =====================================================
   APP CONTENT
   ===================================================== */

.app-content {
  max-width: 1400px;
  margin: 0 auto;
  padding-bottom: 80px; /* space for mobile FAB */
}

@media (min-width: 576px) {
  .app-content { padding-bottom: 24px; }
}


/* =====================================================
   STATS BAR
   ===================================================== */

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  height: 100%;
}

.stat-card .stat-num {
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
}

@media (min-width: 768px) {
  .stat-card .stat-num { font-size: 2rem; }
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}


/* =====================================================
   AMIGO CARD
   ===================================================== */

.amigo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all .2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (min-width: 768px) {
  .amigo-card { padding: 20px; }
}

.amigo-card:hover,
.amigo-card:active {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(74,222,128,.1);
}

.amigo-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #06b6d4);
  opacity: 0;
  transition: opacity .2s;
}

.amigo-card:hover::before { opacity: 1; }

.amigo-avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #06b6d4 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; font-weight: 900; color: #0f1117;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .amigo-avatar { width: 48px; height: 48px; font-size: 1.4rem; }
}

.proximidade-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.dias-badge {
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.dias-ok      { background: rgba(74,222,128,.15); color: var(--accent); }
.dias-alerta  { background: rgba(251,191,36,.15);  color: var(--warning); }
.dias-critico { background: rgba(248,113,113,.15); color: var(--danger); }

.historia-preview {
  color: var(--muted);
  font-size: .82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}


/* =====================================================
   SECTION HEADER
   ===================================================== */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}


/* =====================================================
   TABLE
   ===================================================== */

.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-app {
  color: var(--text);
  margin: 0;
  font-size: .9rem;
}

.table-app thead th {
  background: var(--bg3);
  border-color: var(--border);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.table-app tbody tr {
  border-color: var(--border);
  transition: background .15s;
}

.table-app tbody tr:hover { background: var(--bg3); }

.table-app tbody td {
  padding: 12px 16px;
  border-color: var(--border);
  vertical-align: middle;
}


/* =====================================================
   EMPTY STATE
   ===================================================== */

.empty-state-card {
  text-align: center;
  padding: 40px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  margin-top: 8px;
}

.empty-icon { font-size: 3.5rem; line-height: 1; margin-bottom: 12px; }

@media (min-width: 768px) {
  .empty-icon { font-size: 4rem; }
  .empty-state-card { padding: 60px 40px; }
}


/* =====================================================
   FAB (Floating Action Button) — mobile only
   ===================================================== */

.fab-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f1117;
  border: none;
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(74,222,128,.4);
  z-index: 200;
  transition: transform .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}

.fab-btn:active {
  transform: scale(.93);
  box-shadow: 0 2px 10px rgba(74,222,128,.3);
}


/* =====================================================
   MODAL
   ===================================================== */

.modal-custom {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
}

/* Full-bottom-sheet on small screens */
@media (max-width: 575px) {
  .modal-dialog {
    margin: 0;
    max-width: 100% !important;
    align-items: flex-end;
    min-height: 100%;
  }
  .modal-dialog-centered {
    align-items: flex-end;
  }
  .modal-content,
  .modal-custom {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  /* Add a drag indicator visual */
  .modal-custom::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto -6px;
  }
}

.modal-custom .btn-close {
  filter: invert(1) opacity(.5);
  flex-shrink: 0;
}

.modal-header {
  padding: 16px 20px 12px;
  align-items: flex-start;
}

.modal-body { padding: 16px 20px; }
.modal-footer { padding: 12px 20px 20px; }


/* =====================================================
   PROXIMITY BUTTONS
   ===================================================== */

.prox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (min-width: 480px) {
  .prox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

.btn-prox {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .85rem;
  padding: 8px 14px;
  transition: all .15s;
  text-align: center;
  white-space: nowrap;
}

.btn-check:checked + .btn-prox {
  background: rgba(74,222,128,.15);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-prox:hover {
  border-color: var(--muted);
  color: var(--text);
}


/* =====================================================
   BADGE PROXIMIDADE (modal detalhes)
   ===================================================== */

.badge-prox {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
}


/* =====================================================
   HISTÓRIA BOX
   ===================================================== */

.historia-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .9rem;
  line-height: 1.6;
}


/* =====================================================
   MENSAGEM ITEM
   ===================================================== */

.mensagem-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color .2s;
}

.mensagem-item.enviada {
  border-color: rgba(74,222,128,.4);
  background: rgba(74,222,128,.05);
}

.mensagem-texto {
  font-size: .92rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.mensagem-meta {
  font-size: .73rem;
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}


/* =====================================================
   LOADING IA
   ===================================================== */

.loading-ia {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.dot-pulse::after {
  content: '.';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 100% { content: '.'; }
  33%       { content: '..'; }
  66%       { content: '...'; }
}


/* =====================================================
   TOAST
   ===================================================== */

#toastMsg {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  min-width: 220px;
  max-width: calc(100vw - 32px);
}


/* =====================================================
   SCROLLBAR
   ===================================================== */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }


/* =====================================================
   ACCESSIBILITY — touch targets
   ===================================================== */

.btn, button, [role="button"] {
  min-height: 40px;
}

input, select, textarea {
  font-size: 16px !important; /* prevent iOS zoom on focus */
}

/* =====================================================
   UTILITY
   ===================================================== */

.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
