/* ============================================================
   B.I. Dinâmicas Comerciais — Main Stylesheet
   ============================================================ */

:root {
  --bi-sidebar-width: 260px;
  --bi-sidebar-collapsed: 64px;
  --bi-topbar-height: 56px;
  --bi-primary: #2B5950;        /* Valença Digital — Verde (PANTONE 553 C) */
  --bi-primary-light: #3a7065;  /* Verde claro */
  --bi-accent: #CC874A;         /* Valença Digital — Dourado (PANTONE 7412 C) */
  --bi-success: #27ae60;
  --bi-danger: #e74c3c;
  --bi-warning: #f39c12;
  --bi-bg: #f2f5f3;             /* Fundo com leve tom verde */
  --bi-surface: #ffffff;
  --bi-border: #dde6e2;
  --bi-text: #191919;           /* Valença Digital — Escuro (PANTONE 1645 C) */
  --bi-text-muted: #6b8078;
  --bi-sidebar-bg: #1e3f39;     /* Verde escuro sidebar */
  --bi-sidebar-text: #b8cdc8;
  --bi-sidebar-active: #CC874A; /* Dourado para item activo */
  --bi-transition: 0.2s ease;
  --bi-radius: 10px;
  --bi-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --bi-shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bi-bg);
  color: var(--bi-text);
  margin: 0;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.bi-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--bi-sidebar-width);
  height: 100vh;
  background: var(--bi-sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width var(--bi-transition);
  z-index: 1040;
  overflow: hidden;
}

.bi-sidebar.collapsed { width: var(--bi-sidebar-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--bi-topbar-height);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  overflow: hidden;
}

.brand-icon {
  font-size: 1.4rem;
  color: var(--bi-accent);
  flex-shrink: 0;
}

.brand-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--bi-sidebar-text);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background var(--bi-transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
  padding: 0.4rem 1rem 0.2rem;
  list-style: none;
}
.nav-section-label small {
  color: rgba(255,255,255,0.35);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  color: var(--bi-sidebar-text);
  border-radius: 0;
  text-decoration: none;
  font-size: 0.875rem;
  transition: all var(--bi-transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: var(--bi-sidebar-active);
  color: #fff;
  border-left: 3px solid var(--bi-accent);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.15);
}
.avatar-placeholder {
  width: 32px; height: 32px;
  background: var(--bi-accent);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ── Main Content ────────────────────────────────────────── */
.bi-main {
  margin-left: var(--bi-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--bi-transition);
}
.bi-main.sidebar-collapsed { margin-left: var(--bi-sidebar-collapsed); }

/* ── Topbar ──────────────────────────────────────────────── */
.bi-topbar {
  height: var(--bi-topbar-height);
  background: var(--bi-surface);
  border-bottom: 1px solid var(--bi-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--bi-shadow);
}

/* ── Content ─────────────────────────────────────────────── */
.bi-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--bi-primary);
  margin: 0;
}
.page-title small {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--bi-text-muted);
  display: block;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-card {
  background: var(--bi-surface);
  border-radius: var(--bi-radius);
  padding: 1.25rem;
  box-shadow: var(--bi-shadow);
  border: 1px solid var(--bi-border);
  position: relative;
  overflow: hidden;
  transition: transform var(--bi-transition), box-shadow var(--bi-transition);
  height: 100%;           
  display: flex;          
  flex-direction: column; 
  justify-content: space-between; 
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--bi-shadow-md);
}
.kpi-card .kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
}
.kpi-card .kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--bi-primary);
  margin-top: auto;       /* push value down to align across cards */
}
.kpi-card .kpi-label {
  font-size: 0.8rem;
  color: var(--bi-text-muted);
  margin-top: 0.25rem;
  min-height: 2.4em;      /* always reserve space for 2 lines */
  display: flex;
  align-items: flex-start;
}
.kpi-card .kpi-trend {
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* KPI colour variants */
.kpi-primary .kpi-icon { background: #d6e8e4; color: #1e3f39; }
.kpi-success .kpi-icon { background: #d1fae5; color: #065f46; }
.kpi-warning .kpi-icon { background: #fef3c7; color: #92400e; }
.kpi-danger  .kpi-icon { background: #fee2e2; color: #991b1b; }
.kpi-info    .kpi-icon { background: #d6e8e4; color: #2B5950; }
.kpi-accent  .kpi-icon { background: #f5e4d0; color: #8a5525; }

/* ── Cards ───────────────────────────────────────────────── */
.bi-card {
  background: var(--bi-surface);
  border-radius: var(--bi-radius);
  box-shadow: var(--bi-shadow);
  border: 1px solid var(--bi-border);
  overflow: hidden;
}
.bi-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bi-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bi-surface);
}
.bi-card-header h6, .bi-card-header h5 { margin: 0; font-weight: 600; color: var(--bi-primary); }
.bi-card-body { padding: 1.25rem; }

/* ── Tables ──────────────────────────────────────────────── */
.bi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.bi-table th {
  background: #f0f5f3;
  color: var(--bi-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--bi-border);
  white-space: nowrap;
}
.bi-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bi-border);
  vertical-align: middle;
}
.bi-table tbody tr:hover { background: #f0f5f3; }
.bi-table tbody tr:last-child td { border-bottom: none; }

/* ── Status Badges ───────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active    { background: #d1fae5; color: #065f46; }
.status-vacant    { background: #fee2e2; color: #991b1b; }
.status-for_lease { background: #d6e8e4; color: #1e3f39; }
.status-for_sale  { background: #fef3c7; color: #92400e; }
.status-for_transfer { background: #ede9fe; color: #5b21b6; }
.status-reserved  { background: #eef4f2; color: #2B5950; }
.status-inactive  { background: #f1f5f9; color: #64748b; }
.status-draft     { background: #f1f5f9; color: #64748b; }
.status-approved  { background: #d1fae5; color: #065f46; }
.status-rejected  { background: #fee2e2; color: #991b1b; }
.status-pending   { background: #fef3c7; color: #92400e; }
.status-published { background: #d1fae5; color: #065f46; }

/* ── Search Panel ────────────────────────────────────────── */
.search-panel {
  background: var(--bi-surface);
  border-radius: var(--bi-radius);
  border: 1px solid var(--bi-border);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--bi-shadow);
}

/* ── Map ─────────────────────────────────────────────────── */
#map { border-radius: var(--bi-radius); overflow: hidden; }

/* ── Breadcrumb ──────────────────────────────────────────── */
.breadcrumb { margin: 0; font-size: 0.8rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--bi-text-muted); }

/* ── Auth Pages ──────────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bi-primary) 0%, #1e3f39 100%);
  padding: 2rem;
}
.auth-card {
  background: var(--bi-surface);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo .logo-icon {
  font-size: 3rem;
  color: var(--bi-accent);
}
.auth-logo h1 { font-size: 1.25rem; font-weight: 700; color: var(--bi-primary); margin: 0; }
.auth-logo p { font-size: 0.8rem; color: var(--bi-text-muted); margin: 0; }

/* ── Dashboard Recent List ───────────────────────────────── */
.recent-list .recent-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--bi-border);
  text-decoration: none;
  color: inherit;
}
.recent-list .recent-item:last-child { border-bottom: none; }
.recent-list .recent-item:hover { background: #f0f5f3; margin: 0 -1.25rem; padding: 0.6rem 1.25rem; }
.recent-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Workflow ────────────────────────────────────────────── */
.workflow-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 1.5rem;
}
.workflow-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f1f5f9;
  color: var(--bi-text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.workflow-step.active {
  background: var(--bi-primary);
  color: #fff;
}
.workflow-step.done {
  background: #d1fae5;
  color: #065f46;
}
.workflow-step:first-child { border-radius: var(--bi-radius) 0 0 var(--bi-radius); }
.workflow-step:last-child  { border-radius: 0 var(--bi-radius) var(--bi-radius) 0; }
.workflow-arrow { color: var(--bi-border); font-size: 0.7rem; }

/* ── Notifications ───────────────────────────────────────── */
.notif-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--bi-border);
  cursor: pointer;
  transition: background var(--bi-transition);
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eef4f2; border-left: 3px solid var(--bi-primary-light); }
.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bi-primary-light);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .bi-sidebar { transform: translateX(-100%); }
  .bi-sidebar.mobile-open { transform: translateX(0); }
  .bi-main { margin-left: 0 !important; }
  .bi-content { padding: 1rem; }
}

/* ── Utility ─────────────────────────────────────────────── */
.text-primary-bi { color: var(--bi-primary) !important; }
.bg-primary-bi   { background: var(--bi-primary) !important; }
.fw-600 { font-weight: 600; }
.gap-xs { gap: 0.35rem; }
.cursor-pointer { cursor: pointer; }

/* Hide browser date picker calendar icon */
input[type="date"]::-webkit-calendar-picker-indicator {
    display: none;
}

/* Override Bootstrap primary with brand green */
.btn-primary {
  background-color: #2B5950 !important;
  border-color: #2B5950 !important;
}
.btn-primary:hover {
  background-color: #1e3f39 !important;
  border-color: #1e3f39 !important;
}
.btn-outline-primary {
  color: #2B5950 !important;
  border-color: #2B5950 !important;
}
.btn-outline-primary:hover {
  background-color: #2B5950 !important;
  color: white !important;
}
.text-primary { color: #2B5950 !important; }
.bg-primary { background-color: #2B5950 !important; }
.border-primary { border-color: #2B5950 !important; }
a { color: #2B5950; }
a:hover { color: #1e3f39; }