/* ============================================================
   Évora Pipe CRM — Estilos Globais
   ============================================================ */

/* ── Variáveis ── */
:root {
  --primary:       #2563EB;
  --primary-dark:  #1D4ED8;
  --primary-light: #EFF6FF;
  --white:         #FFFFFF;
  --bg:            #F8FAFC;
  --text:          #111827;
  --text-muted:    #4B5563;
  --success:       #22C55E;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --border:        #E5E7EB;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        10px;
  --shadow:        0 1px 6px rgba(0,0,0,.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --transition:    .2s ease;
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--bg);
  color: var(--primary);
}

.sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-link i { font-size: 17px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-logout:hover { color: var(--danger); }

/* ── Overlay mobile ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 998;
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.topbar-title {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  flex: 2;
  max-width: 280px;
}

.topbar-search i { color: var(--text-muted); }
.topbar-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  width: 100%;
  font-family: 'Inter', sans-serif;
}

.topbar-logout {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
}
.topbar-logout:hover { color: var(--danger); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 28px;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ============================================================
   CARDS / STAT CARDS
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #EFF6FF; color: var(--primary); }
.stat-icon.green  { background: #F0FDF4; color: var(--success); }
.stat-icon.yellow { background: #FFFBEB; color: var(--warning); }
.stat-icon.red    { background: #FEF2F2; color: var(--danger); }
.stat-icon.purple { background: #F5F3FF; color: #7C3AED; }
.stat-icon.teal   { background: #F0FDFA; color: #0D9488; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  padding: 8px 16px;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: var(--white);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: var(--white);
}

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table {
  margin-bottom: 0;
  font-size: 13px;
}

.table thead th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 11px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

/* ============================================================
   BADGES — STATUS / STAGE
   ============================================================ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
}

.badge-stage-new      { background:#EFF6FF; color:#2563EB; }
.badge-stage-contact  { background:#F0F9FF; color:#0284C7; }
.badge-stage-qualify  { background:#F5F3FF; color:#7C3AED; }
.badge-stage-proposal { background:#FFFBEB; color:#D97706; }
.badge-stage-nego     { background:#FFF7ED; color:#EA580C; }
.badge-stage-won      { background:#F0FDF4; color:#16A34A; }
.badge-stage-lost     { background:#FEF2F2; color:#DC2626; }

.badge-pending   { background:#FFFBEB; color:#D97706; }
.badge-done      { background:#F0FDF4; color:#16A34A; }
.badge-cancelled { background:#F3F4F6; color:#6B7280; }

/* ============================================================
   KANBAN PIPELINE
   ============================================================ */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}

.kanban-col {
  flex: 0 0 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 480px;
}

.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--white);
}

.kanban-col-count {
  background: var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.kanban-cards {
  padding: 10px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.kanban-card:active { cursor: grabbing; }
.kanban-card:hover  { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }

.kanban-card-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 5px;
  color: var(--text);
}

.kanban-card-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.kanban-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kanban-col.drag-over .kanban-cards {
  background: var(--primary-light);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Col header accent colors */
.kanban-col[data-stage="novo_lead"]        .kanban-col-header { border-left: 3px solid #2563EB; }
.kanban-col[data-stage="primeiro_contato"] .kanban-col-header { border-left: 3px solid #0284C7; }
.kanban-col[data-stage="qualificacao"]     .kanban-col-header { border-left: 3px solid #7C3AED; }
.kanban-col[data-stage="proposta_enviada"] .kanban-col-header { border-left: 3px solid #D97706; }
.kanban-col[data-stage="negociacao"]       .kanban-col-header { border-left: 3px solid #EA580C; }
.kanban-col[data-stage="fechado_ganho"]    .kanban-col-header { border-left: 3px solid #16A34A; }
.kanban-col[data-stage="fechado_perdido"]  .kanban-col-header { border-left: 3px solid #DC2626; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

.modal-title { font-weight: 700; font-size: 16px; }

.modal-body  { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  border-radius: 8px;
  font-size: 13px;
  border: none;
  padding: 12px 16px;
}

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 20px 0 8px;
}

/* ============================================================
   HISTORY TIMELINE
   ============================================================ */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -25px;
  top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--border);
}

.timeline-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.timeline-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .35;
}

.empty-state p { font-size: 14px; margin: 0; }

/* ============================================================
   AUTH PAGES (login / register)
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  justify-content: center;
}

.auth-logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: 20px;
}

.auth-logo-text {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .topbar {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
    margin-top: var(--topbar-h);
  }

  .kanban-board { gap: 10px; }
  .kanban-col   { flex: 0 0 200px; }
}

@media (max-width: 576px) {
  .main-content { padding: 16px 12px; }
  .page-title   { font-size: 18px; }
  .stat-value   { font-size: 22px; }
  .auth-card    { padding: 28px 20px; }
  .topbar-search { display: none; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.text-primary-custom { color: var(--primary) !important; }
.text-muted-custom   { color: var(--text-muted) !important; }
.rounded-custom      { border-radius: var(--radius) !important; }

.table-actions .btn { padding: 4px 9px; font-size: 12px; }

/* Animações discretas */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeInUp .25s ease both; }