/* ==========================================================================
   dashboard.css — Dashboard IMOBDOC (reformulado, mais clean e intuitivo)
   ========================================================================== */

.dash-app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: var(--bg-alt);
}

/* ========================== SIDEBAR ====================================== */
.dash-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-3) var(--ease-out);
  z-index: 50;
}

/* === Brand: agora com logo da empresa === */
.dash-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 24px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}
.dash-brand-logo {
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.dash-brand-logo img {
  max-height: 80px;
  width: auto;
  display: block;
  transition: transform var(--dur-2);
}
.dash-brand-logo:hover img {
  transform: scale(1.05);
}
:root[data-theme="dark"] .dash-brand-logo img {
  filter: brightness(0) invert(1);
}
.dash-brand-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--brand-purple);
  text-transform: uppercase;
  font-weight: 600;
  padding: 4px 8px;
  background: rgba(79, 70, 229, 0.08);
  border-radius: 6px;
  flex-shrink: 0;
}
:root[data-theme="dark"] .dash-brand-tag {
  background: rgba(129, 140, 248, 0.14);
  color: var(--brand-purple-2);
}

.dash-section-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--text-mute);
  text-transform: uppercase;
  padding: 18px 12px 10px;
  font-weight: 500;
}

.dash-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--text-2);
  font-weight: 500;
  position: relative;
  transition: all var(--dur-1);
}
.dash-nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
  transform: translateX(2px);
}
.dash-nav a.active {
  background: linear-gradient(135deg, var(--brand-purple), var(--brand-violet));
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.5);
}
.dash-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.dash-nav .badge-mini {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--brand-cyan);
  color: var(--brand-ink);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.dash-nav a.active .badge-mini {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.dash-sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}
.dash-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--dur-1);
}
.dash-user:hover {
  background: var(--bg-soft);
}
.dash-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-purple), var(--brand-violet));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.dash-user .info {
  flex: 1;
  min-width: 0;
}
.dash-user .info strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text);
}
.dash-user .info span {
  font-size: 0.74rem;
  color: var(--text-3);
}
.dash-user button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  transition: all var(--dur-1);
}
.dash-user button:hover {
  background: var(--bg-elev);
  color: var(--brand-purple);
}
.dash-user button svg {
  width: 16px;
  height: 16px;
}

/* ========================== MAIN ========================================= */
.dash-main {
  padding: 0;
  overflow-x: hidden;
  min-width: 0;
}

.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 36px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(245, 244, 251, 0.85);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  gap: 16px;
}
:root[data-theme="dark"] .dash-topbar {
  background: rgba(10, 10, 31, 0.85);
}

.dash-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elev);
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.dash-mobile-toggle svg {
  width: 18px;
  height: 18px;
}

.dash-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  padding: 10px 14px;
  border-radius: 10px;
  width: 360px;
  font-size: 0.9rem;
  color: var(--text-3);
  border: 1px solid transparent;
  transition: border-color var(--dur-1);
  flex: 0 1 auto;
}
.dash-search:focus-within {
  border-color: var(--brand-purple);
  background: var(--bg-elev);
}
.dash-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  min-width: 0;
}
.dash-search svg {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}
.dash-search kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-3);
  flex-shrink: 0;
}

.dash-topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.dash-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-soft);
  background: var(--bg-elev);
  position: relative;
  color: var(--text-2);
  transition: all var(--dur-1);
}
.dash-icon-btn:hover {
  background: var(--bg-soft);
  border-color: var(--brand-purple);
  color: var(--brand-purple);
}
.dash-icon-btn svg {
  width: 16px;
  height: 16px;
}
.dash-icon-btn .icon-sun {
  display: none;
}
.dash-icon-btn .icon-moon {
  display: block;
}
:root[data-theme="dark"] .dash-icon-btn .icon-sun {
  display: block;
}
:root[data-theme="dark"] .dash-icon-btn .icon-moon {
  display: none;
}

.dash-icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px var(--bg-elev);
}

/* ====== DASH BODY ====== */
.dash-body {
  padding: 32px 36px 60px;
}

/* === Welcome Banner === */
.dash-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 30px;
  background: linear-gradient(135deg, var(--bg-elev) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  flex-wrap: wrap;
}
.dash-welcome::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.16), transparent 70%);
  filter: blur(40px);
}
.dash-welcome > div:first-child {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 240px;
}
.dash-welcome h1 {
  font-size: 1.8rem;
  letter-spacing: -0.025em;
  margin: 8px 0 8px;
}
.dash-welcome p {
  color: var(--text-3);
  font-size: 0.92rem;
}
.dash-welcome p strong {
  color: var(--brand-purple);
  font-weight: 600;
}
.dash-welcome-actions {
  position: relative;
  z-index: 1;
}

/* === KPI Grid === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: all var(--dur-2) var(--ease-out);
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.04), transparent 50%);
  opacity: 0;
  transition: opacity var(--dur-2);
}
.kpi-card:hover {
  border-color: var(--brand-purple);
  transform: translateY(-4px);
  box-shadow: 0 16px 36px -12px rgba(79, 70, 229, 0.22);
}
.kpi-card:hover::before {
  opacity: 1;
}
.kpi-card > * {
  position: relative;
  z-index: 1;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  transition: transform var(--dur-3) var(--ease-spring);
}
.kpi-card:hover .kpi-icon {
  transform: scale(1.1) rotate(-5deg);
}
.kpi-icon svg {
  width: 18px;
  height: 18px;
}
.kpi-icon-purple {
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.14),
    rgba(99, 102, 241, 0.08)
  );
  color: var(--brand-purple);
}
.kpi-icon-cyan {
  background: linear-gradient(
    135deg,
    rgba(56, 200, 232, 0.18),
    rgba(56, 200, 232, 0.06)
  );
  color: var(--brand-cyan);
}
.kpi-icon-success {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.16),
    rgba(16, 185, 129, 0.06)
  );
  color: var(--brand-success);
}
.kpi-icon-blue {
  background: linear-gradient(
    135deg,
    rgba(47, 59, 255, 0.14),
    rgba(47, 59, 255, 0.06)
  );
  color: var(--brand-blue);
}
:root[data-theme="dark"] .kpi-icon-purple {
  background: linear-gradient(
    135deg,
    rgba(129, 140, 248, 0.2),
    rgba(165, 180, 252, 0.08)
  );
}

.kpi-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}
.kpi-value {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--brand-ink);
  margin-top: 6px;
  line-height: 1;
  display: flex;
  align-items: baseline;
}
.kpi-value span {
  font-size: 1.2rem;
  margin-left: 2px;
  color: var(--text-3);
}
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  margin-top: 14px;
  color: var(--brand-success);
  font-weight: 500;
}

/* === Row Layouts === */
.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-row-flip {
  grid-template-columns: 2fr 1fr;
}

/* === Card Generic === */
.dash-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  transition: all var(--dur-2);
}
.dash-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.dash-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 14px;
  flex-wrap: wrap;
}
.dash-card-head h3 {
  font-size: 1.1rem;
  letter-spacing: -0.015em;
}
.dash-card-head p {
  font-size: 0.85rem;
  color: var(--text-3);
  margin-top: 4px;
}

.dash-card-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.dash-card-tabs button {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all var(--dur-1);
}
.dash-card-tabs button:hover {
  color: var(--text-2);
  background: var(--bg-soft);
}
.dash-card-tabs button.active {
  background: var(--brand-purple);
  color: #fff;
}

/* === Chart Legend === */
.chart-legend {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-3);
  font-weight: 500;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* === Chart Area === */
.dash-chart-area {
  width: 100%;
  height: 260px;
  display: block;
}

/* === Donut Chart === */
.status-donut {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
}
.status-donut svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.status-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.donut-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-ink);
  letter-spacing: -0.03em;
  line-height: 1;
}
.donut-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 6px;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  font-size: 0.88rem;
  color: var(--text);
  transition: padding var(--dur-1);
}
.status-list-item:hover {
  padding-left: 8px;
}
.status-list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-list-item span:nth-child(2) {
  flex: 1;
  color: var(--text-2);
}
.status-list-item strong {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--brand-ink);
}

/* === Process table === */
.process-table {
  width: 100%;
  border-collapse: collapse;
}
.process-table thead th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.process-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9rem;
  color: var(--text);
  vertical-align: middle;
}
.process-table tbody tr {
  transition: background var(--dur-1);
}
.process-table tbody tr:hover {
  background: var(--bg-soft);
  cursor: pointer;
}
.process-table tbody tr:last-child td {
  border-bottom: 0;
}

.process-table .process-name strong {
  display: block;
  color: var(--brand-ink);
  font-weight: 600;
  margin-bottom: 2px;
}
.process-table .process-name span {
  font-size: 0.78rem;
  color: var(--text-3);
}
.process-table .progress-bar {
  width: 100%;
  max-width: 100px;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.process-table .progress-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-blue));
  border-radius: 3px;
  transition: width 1s var(--ease-out);
}

/* === Status pills === */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status.success {
  background: rgba(16, 185, 129, 0.14);
  color: var(--brand-success);
}
.status.success::before {
  background: var(--brand-success);
}
.status.active {
  background: rgba(79, 70, 229, 0.14);
  color: var(--brand-purple);
}
.status.active::before {
  background: var(--brand-purple);
}
.status.pending {
  background: var(--bg-soft);
  color: var(--text-3);
}
.status.pending::before {
  background: var(--text-mute);
}
.status.warn {
  background: rgba(245, 158, 11, 0.14);
  color: var(--brand-warn);
}
.status.warn::before {
  background: var(--brand-warn);
}

:root[data-theme="dark"] .status.success {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}
:root[data-theme="dark"] .status.active {
  background: rgba(129, 140, 248, 0.18);
  color: var(--brand-purple-2);
}

/* === Action list === */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  transition: all var(--dur-2);
  cursor: pointer;
}
.action-item:hover {
  border-color: var(--brand-purple);
  transform: translateX(4px);
  background: var(--bg-elev);
}
.action-priority {
  width: 8px;
  align-self: stretch;
  border-radius: 4px;
  flex-shrink: 0;
}
.action-priority.high {
  background: #ef4444;
}
.action-priority.med {
  background: var(--brand-warn);
}
.action-priority.low {
  background: var(--brand-cyan);
}

.action-info {
  flex: 1;
  min-width: 0;
}
.action-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--brand-ink);
  letter-spacing: -0.01em;
}
.action-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 3px;
}
.action-arrow {
  color: var(--text-3);
  transition:
    transform var(--dur-2),
    color var(--dur-2);
  flex-shrink: 0;
}
.action-item:hover .action-arrow {
  color: var(--brand-purple);
  transform: translateX(4px);
}
.action-arrow svg {
  width: 16px;
  height: 16px;
}

/* === Backdrop mobile === */
.dash-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  transition: opacity var(--dur-2);
}
.dash-backdrop.active {
  display: block;
  opacity: 1;
}

/* ============================ RESPONSIVE ================================ */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-row,
  .dash-row-flip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .dash-app {
    grid-template-columns: 1fr;
  }
  .dash-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
  }
  .dash-sidebar.open {
    transform: translateX(0);
  }
  .dash-mobile-toggle {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .dash-topbar {
    padding: 12px 18px;
    gap: 10px;
  }
  .dash-search {
    width: auto;
    flex: 1;
    padding: 8px 12px;
  }
  .dash-search kbd {
    display: none;
  }
  .dash-search input {
    font-size: 0.84rem;
  }

  .dash-body {
    padding: 20px 18px 40px;
  }

  .dash-welcome {
    padding: 22px 22px;
    gap: 18px;
  }
  .dash-welcome h1 {
    font-size: 1.4rem;
  }
  .dash-welcome p {
    font-size: 0.86rem;
  }
  .dash-welcome-actions .btn {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .kpi-card {
    padding: 18px 18px;
  }
  .kpi-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 12px;
  }
  .kpi-value {
    font-size: 1.6rem;
  }
  .kpi-value span {
    font-size: 0.95rem;
  }
  .kpi-delta {
    font-size: 0.68rem;
    margin-top: 10px;
  }
  .kpi-label {
    font-size: 0.62rem;
  }

  .dash-card {
    padding: 20px 18px;
  }
  .dash-card-head {
    margin-bottom: 18px;
  }
  .dash-card-head h3 {
    font-size: 1rem;
  }
  .dash-card-head p {
    font-size: 0.78rem;
  }
  .dash-card-tabs button {
    padding: 5px 10px;
    font-size: 0.64rem;
  }

  .dash-chart-area {
    height: 220px;
  }
  .status-donut {
    width: 160px;
    height: 160px;
  }
  .donut-value {
    font-size: 1.6rem;
  }

  /* Tabela vira cards no mobile */
  .process-table thead {
    display: none;
  }
  .process-table,
  .process-table tbody,
  .process-table tr,
  .process-table td {
    display: block;
  }
  .process-table tr {
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    background: var(--bg-soft);
  }
  .process-table tr:hover {
    background: var(--bg-soft);
  }
  .process-table td {
    border: 0;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .process-table td::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-3);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-right: 12px;
  }
  .process-table .process-name {
    display: block;
  }
  .process-table .process-name::before {
    display: none;
  }

  .action-item {
    padding: 12px 14px;
    gap: 10px;
  }
  .action-title {
    font-size: 0.88rem;
  }
  .action-meta {
    font-size: 0.68rem;
  }
}

@media (max-width: 380px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
