/* ─────────────────────────────────────────────────────────────
   SynteraHub CRM — Design System
   ───────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --navy:    #050d1f;
  --deep:    #091428;
  --mid:     #0d2045;
  --blue:    #1a3a6e;
  --accent:  #00c2ff;
  --accent2: #0076e4;
  --glow:    rgba(0,194,255,0.18);
  --text:    #e8eef8;
  --muted:   #7a93b8;
  --border:  rgba(0,194,255,0.15);
  --white:   #ffffff;

  /* Status */
  --green:   #00e896;
  --yellow:  #f5c518;
  --red:     #ff4f4f;
  --orange:  #ff8c42;

  /* Sidebar */
  --sidebar-w: 220px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--navy);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Orbs animados (login e background) ──────────────────────── */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,194,255,0.12) 0%, transparent 70%);
  top: -200px; left: -200px;
  animation: orbFloat1 18s ease-in-out infinite;
}
.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,118,228,0.10) 0%, transparent 70%);
  bottom: -150px; right: -150px;
  animation: orbFloat2 22s ease-in-out infinite;
}
@keyframes orbFloat1 {
  0%,100% { transform: translate(0,0); }
  33%      { transform: translate(60px,-40px); }
  66%      { transform: translate(-30px,50px); }
}
@keyframes orbFloat2 {
  0%,100% { transform: translate(0,0); }
  33%      { transform: translate(-50px,40px); }
  66%      { transform: translate(40px,-30px); }
}

/* ── Tipografia ─────────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-family: 'Syne', sans-serif; font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.accent { color: var(--accent); }
.muted  { color: var(--muted); font-size: .85rem; }

/* ── Layout com sidebar ─────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.sidebar-logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.1;
}
.sidebar-logo-text span { color: var(--accent); }
.sidebar-logo-sub {
  font-size: .7rem;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  letter-spacing: .04em;
}

.sidebar-nav {
  flex: 1;
  list-style: none;
  padding: 0 .75rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.sidebar-nav li a,
.sidebar-nav li button {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .75rem;
  border-radius: 10px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  transition: background .2s, color .2s;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-nav li a:hover,
.sidebar-nav li button:hover {
  background: rgba(0,194,255,.07);
  color: var(--text);
  text-decoration: none;
}
.sidebar-nav li a.active {
  background: rgba(0,194,255,.12);
  color: var(--accent);
}
.sidebar-nav li a.active svg { stroke: var(--accent); }

.sidebar-nav .sep {
  height: 1px;
  background: var(--border);
  margin: .5rem 0;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.sidebar-user-name {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .5rem;
}
.sidebar-user-email {
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .75rem;
}

/* ── Main content ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  padding: 2rem;
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--mid);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: border-color .2s, transform .2s;
}
.card:hover {
  border-color: rgba(0,194,255,.4);
  transform: translateY(-2px);
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: .75rem;
}

/* Metric cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.metric-card { cursor: default; }
.metric-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: .25rem;
}
.metric-label {
  font-size: .8rem;
  color: var(--muted);
}

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--navy);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: rgba(255,79,79,.1); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-icon { padding: .4rem; border-radius: 6px; }

/* ── Inputs & Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-control {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: .6rem .85rem;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  transition: border-color .2s;
  outline: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--muted); }
.form-control option { background: var(--mid); color: var(--text); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* Inline grid for forms */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  padding: .65rem 1rem;
  text-align: left;
  font-family: 'Syne', sans-serif;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(0,194,255,.06);
  vertical-align: middle;
}
tbody tr { transition: background .15s; cursor: pointer; }
tbody tr:hover { background: rgba(0,194,255,.05); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-lead        { background: rgba(77,184,255,.15); color: #4db8ff; }
.badge-contato     { background: rgba(155,89,182,.15); color: #b57bee; }
.badge-proposta    { background: rgba(245,197,24,.15);  color: var(--yellow); }
.badge-negociacao  { background: rgba(255,140,66,.15);  color: var(--orange); }
.badge-ganho       { background: rgba(0,232,150,.15);   color: var(--green); }
.badge-perdido     { background: rgba(255,79,79,.15);   color: var(--red); }
.badge-manual          { background: rgba(0,194,255,.12); color: var(--accent); }
.badge-fale_conosco    { background: rgba(0,232,150,.12); color: var(--green); }
.badge-interesse_produto { background: rgba(245,197,24,.12); color: var(--yellow); }
.badge-convertido  { background: rgba(0,232,150,.12); color: var(--green); }
.badge-success     { background: rgba(0,232,150,.15); color: var(--green); }
.badge-error       { background: rgba(255,79,79,.15);  color: var(--red); }

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .5s ease;
}

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.25rem;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  animation: toastIn .3s ease;
  backdrop-filter: blur(12px);
}
.toast-success {
  background: rgba(0,20,10,.85);
  border: 1px solid var(--green);
  color: var(--green);
}
.toast-error {
  background: rgba(30,0,0,.85);
  border: 1px solid var(--red);
  color: var(--red);
}
.toast-info {
  background: rgba(0,10,30,.85);
  border: 1px solid var(--accent);
  color: var(--accent);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding-top: 1rem;
  font-size: .85rem;
  color: var(--muted);
}

/* ── Filters bar ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.filters-bar .form-control { width: auto; }
.search-input { min-width: 220px; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  padding: .6rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,13,31,.85);
  backdrop-filter: blur(6px);
  z-index: 500;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  padding: 2rem;
  position: relative;
  margin: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-header h2 { font-size: 1.2rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: .2rem;
  transition: color .2s;
}
.modal-close:hover { color: var(--text); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}
.login-box {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.login-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.75rem;
}
.login-subtitle {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1.75rem;
}
.login-form { text-align: left; }
.login-form .form-group { margin-bottom: .75rem; }
.login-btn { width: 100%; margin-top: .5rem; padding: .75rem; font-size: 1rem; }
.login-error {
  background: rgba(255,79,79,.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: .65rem .85rem;
  border-radius: 8px;
  font-size: .85rem;
  margin-top: .75rem;
  display: none;
}

/* ── Two-column layout (oportunidade detail) ────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
}

/* ── Timeline / Interações ──────────────────────────────────── */
.timeline { list-style: none; display: flex; flex-direction: column; gap: .75rem; }
.timeline-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.timeline-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(0,194,255,.1);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .2rem;
  flex-wrap: wrap;
}
.timeline-date { font-size: .75rem; color: var(--muted); }
.timeline-type { font-size: .72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.timeline-text { font-size: .875rem; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.timeline-delete {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .9rem; padding: .2rem;
  transition: color .2s; flex-shrink: 0;
}
.timeline-delete:hover { color: var(--red); }

/* ── Stage progression buttons ──────────────────────────────── */
.stage-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state svg { opacity: .3; margin-bottom: 1rem; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,194,255,.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,194,255,.4); }

/* ── Utility ────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.two-col-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 768px) {
  .two-col-panels { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
