/* ============================================================
   CRM RE/MAX Liberty II — Estilos Globais
   Cores oficiais RE/MAX: Azul #003087 | Vermelho #E02020
   ============================================================ */

:root {
  --remax-blue:   #003087;
  --remax-red:    #E02020;
  --remax-white:  #FFFFFF;
  --sidebar-bg:   #002070;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --body-bg:      #F4F6FA;
  --card-bg:      #FFFFFF;
  --text-main:    #1A1A2E;
  --text-muted:   #6B7280;
  --border:       #E5E7EB;
  --success:      #16A34A;
  --warning:      #D97706;
  --danger:       #DC2626;
  --info:         #0284C7;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --radius:       10px;
  --radius-sm:    6px;
}

/* ─── Reset / Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  background: var(--body-bg);
  color: var(--text-main);
  min-height: 100vh;
}

a { color: var(--remax-blue); text-decoration: none; }
a:hover { color: var(--remax-red); }

/* ─── Layout Principal ──────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────  */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-align: center;
}
.sidebar-logo img {
  height: 48px;
  filter: brightness(0) invert(1);
}
.sidebar-logo .brand-name {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,.7);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar-logo .brand-sub {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,.45);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-section {
  padding: 16px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.35);
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.78);
  font-size: 13.5px;
  font-weight: 450;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.sidebar-nav li a:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-left-color: rgba(255,255,255,.3);
}
.sidebar-nav li a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: var(--remax-red);
  font-weight: 600;
}
.sidebar-nav li a .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  color: rgba(255,255,255,.5);
}
.sidebar-footer .user-name { color: rgba(255,255,255,.85); font-weight: 500; }

/* ─── Topbar ─────────────────────────────────────────────  */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ─── Main Content ───────────────────────────────────────  */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-body {
  flex: 1;
  padding: 24px;
}

/* ─── Cards ──────────────────────────────────────────────  */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FAFBFC;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}
.card-body { padding: 20px; }

/* ─── KPI Cards ──────────────────────────────────────────  */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-card.kpi-blue::before   { background: var(--remax-blue); }
.kpi-card.kpi-red::before    { background: var(--remax-red); }
.kpi-card.kpi-green::before  { background: var(--success); }
.kpi-card.kpi-orange::before { background: var(--warning); }
.kpi-card.kpi-purple::before { background: #7C3AED; }

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  opacity: .12;
}

/* ─── Tabelas ────────────────────────────────────────────  */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card-bg);
}
table.data-table thead th {
  background: var(--remax-blue);
  color: #fff;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  border: none;
}
table.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
table.data-table tbody tr:hover { background: #F0F4FF; }
table.data-table tbody tr:last-child { border-bottom: none; }
table.data-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  color: var(--text-main);
}
table.data-table tbody tr:nth-child(even) td { background: #FAFBFC; }
table.data-table tbody tr:nth-child(even):hover td { background: #F0F4FF; }

.td-pv { font-family: 'Courier New', monospace; font-weight: 600; color: var(--remax-blue); }
.td-euro { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ─── Badges de Estado ───────────────────────────────────  */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.badge-pipeline  { background: #EEF2FF; color: #4338CA; }
.badge-faturado  { background: #FEF9C3; color: #92400E; }
.badge-recebido  { background: #DCFCE7; color: #166534; }
.badge-fechado   { background: #F1F5F9; color: #475569; }
.badge-danger    { background: #FEE2E2; color: #991B1B; }
.badge-info      { background: #E0F2FE; color: #075985; }
.badge-pp        { background: #EEF2FF; color: #4338CA; }
.badge-aprov     { background: #DCFCE7; color: #166534; }
.badge-rec       { background: #FEF9C3; color: #92400E; }
.badge-pag       { background: #D1FAE5; color: #065F46; }
.badge-cond      { background: #FEE2E2; color: #991B1B; }

/* ─── Formulários ────────────────────────────────────────  */
.form-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}
.form-section-header {
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--remax-blue) 0%, #0041a8 100%);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-body { padding: 20px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text-main);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--remax-blue);
  box-shadow: 0 0 0 3px rgba(0,48,135,.1);
}
.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: 11px; color: var(--text-muted); }

/* ─── Botões ─────────────────────────────────────────────  */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

.btn-primary {
  background: var(--remax-blue);
  color: #fff;
}
.btn-primary:hover { background: #00227a; color: #fff; box-shadow: 0 2px 8px rgba(0,48,135,.35); }

.btn-danger {
  background: var(--remax-red);
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #15803d; color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--remax-blue);
  border: 1.5px solid var(--remax-blue);
}
.btn-outline:hover { background: var(--remax-blue); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--text-main); }

.btn-warning {
  background: #F59E0B;
  color: #fff;
}
.btn-warning:hover { background: #D97706; color: #fff; }

/* ─── Filtros bar ────────────────────────────────────────  */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-bar .form-group { min-width: 160px; }

/* ─── Alertas ────────────────────────────────────────────  */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13.5px;
  border-left: 4px solid;
}
.alert-success { background: #F0FDF4; border-color: var(--success); color: #166534; }
.alert-danger  { background: #FEF2F2; border-color: var(--danger);  color: #991B1B; }
.alert-warning { background: #FFFBEB; border-color: var(--warning); color: #92400E; }
.alert-info    { background: #EFF6FF; border-color: var(--info);    color: #1E40AF; }

/* ─── Paginação ──────────────────────────────────────────  */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--remax-blue);
  background: var(--card-bg);
}
.pagination a:hover { background: var(--remax-blue); color: #fff; border-color: var(--remax-blue); }
.pagination span.active { background: var(--remax-blue); color: #fff; border-color: var(--remax-blue); }
.pagination span.disabled { color: var(--text-muted); cursor: default; }

/* ─── Login ──────────────────────────────────────────────  */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #001860 0%, var(--remax-blue) 50%, #0041a8 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.login-logo { height: 60px; margin-bottom: 8px; }
.login-brand { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--remax-blue); margin-bottom: 24px; }

/* ─── Breadcrumb ─────────────────────────────────────────  */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--remax-blue); }
.breadcrumb .sep { color: var(--border); }

/* ─── Comissão preview box ───────────────────────────────  */
.comissao-preview {
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  border: 1.5px solid #C7D2FE;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 12px;
}
.comissao-preview .title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #4338CA;
  margin-bottom: 12px;
}
.comissao-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(99,102,241,.15);
}
.comissao-row:last-child { border-bottom: none; }
.comissao-row .label { color: var(--text-muted); }
.comissao-row .value { font-weight: 600; color: var(--remax-blue); }
.comissao-row.total { margin-top: 6px; padding-top: 8px; }
.comissao-row.total .value { color: var(--remax-red); font-size: 15px; }

/* ─── Detalhe processo ───────────────────────────────────  */
.processo-header {
  background: linear-gradient(135deg, var(--remax-blue) 0%, #0041a8 100%);
  color: #fff;
  padding: 24px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.processo-pv { font-size: 28px; font-weight: 800; letter-spacing: 1px; }
.processo-meta { font-size: 13px; opacity: .75; margin-top: 4px; }

.detalhe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.campo-detalhe { display: flex; flex-direction: column; gap: 3px; }
.campo-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.campo-value { font-size: 14px; color: var(--text-main); font-weight: 500; }
.campo-value.euro { color: var(--remax-blue); font-variant-numeric: tabular-nums; }

/* ─── Responsive ─────────────────────────────────────────  */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ─── Utilitários ────────────────────────────────────────  */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.fw-bold     { font-weight: 700; }
.fw-600      { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-100 { width: 100%; }
