/* ==========================================================================
   DXS IMOB — SHADCN ADMIN DESIGN SYSTEM (Data Quality & Operational Workspace)
   Inspirado em: Shadcn/ui, Tailwind CSS, Linear, Supabase Studio.
   ========================================================================== */

:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #0284c7; /* Sky 600 */
  --primary-hover: #0369a1;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9; /* Slate 100 */
  --secondary-foreground: #0f172a;
  --muted: #f8fafc; /* Slate 50 */
  --muted-foreground: #64748b; /* Slate 500 */
  --accent: #f1f5f9;
  --accent-foreground: #0f172a;
  --destructive: #ef4444; /* Red 500 */
  --destructive-foreground: #ffffff;
  --border: #e2e8f0; /* Slate 200 */
  --input: #e2e8f0;
  --ring: #0284c7;
  --radius: 8px;
  --sidebar-width: 260px;
  --sidebar-bg: #f8fafc;
  --sidebar-border: #e2e8f0;
  --sidebar-foreground: #334155;
  --success: #10b981;
  --warning: #f59e0b;
}

[data-theme="dark"] {
  --background: #09090b;
  --foreground: #f8fafc;
  --card: #111113;
  --card-foreground: #f8fafc;
  --popover: #111113;
  --popover-foreground: #f8fafc;
  --primary: #38bdf8; /* Sky 400 */
  --primary-hover: #0284c7;
  --primary-foreground: #09090b;
  --secondary: #1e293b;
  --secondary-foreground: #f8fafc;
  --muted: #18181b;
  --muted-foreground: #94a3b8;
  --accent: #1e293b;
  --accent-foreground: #f8fafc;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --border: #27272a;
  --input: #27272a;
  --ring: #38bdf8;
  --sidebar-bg: #0c0a09;
  --sidebar-border: #1c1917;
  --sidebar-foreground: #cbd5e1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
}

/* APP SHELL LAYOUT */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* FIXED MODERN SIDEBAR (SHADCN STYLE) */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: width 0.2s ease;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--foreground);
  font-weight: 700;
  font-size: 0.95rem;
}

.sidebar-brand-badge {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
  border: 1px solid rgba(2, 132, 199, 0.25);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.agency-selector {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.agency-selector-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.agency-selector-button:hover {
  background: var(--secondary);
}

.agency-switcher-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 12px;
  right: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 8px;
  z-index: 999;
  max-height: 340px;
  overflow-y: auto;
}

.switcher-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  padding: 6px 8px 4px 8px;
}

.switcher-option-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--foreground);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 2px;
}

.switcher-option-item:hover {
  background: var(--secondary);
}

.switcher-option-item.selected {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.tenant-welcome-banner {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.tenant-banner-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tenant-banner-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tenant-badge {
  background: #0284c7;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tenant-banner-title strong {
  font-size: 1.05rem;
  color: var(--foreground);
}

.tenant-key-tag {
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted-foreground);
}

.tenant-banner-content p {
  font-size: 0.84rem;
  color: var(--muted-foreground);
  margin: 0;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-foreground);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-item-button:hover {
  background-color: var(--secondary);
  color: var(--foreground);
}

.nav-item-button.active {
  background-color: var(--card);
  color: var(--primary);
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon {
  font-size: 1.05rem;
  display: inline-flex;
}

.nav-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--muted-foreground);
}

.nav-badge.badge-alert {
  background: rgba(239, 68, 68, 0.15);
  color: var(--destructive);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
}

.dot-pulse {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* MAIN CONTENT AREA */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP NAVBAR */
.app-header {
  height: 60px;
  border-bottom: 1px solid var(--border);
  background-color: var(--background);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.header-breadcrumbs span.active {
  color: var(--foreground);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-command-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--secondary);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--muted-foreground);
  cursor: pointer;
  min-width: 220px;
}

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--foreground);
  cursor: pointer;
  font-size: 0.85rem;
}

.theme-toggle-btn:hover {
  background: var(--secondary);
}

.user-logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--muted-foreground);
  cursor: pointer;
  font-weight: 500;
}

.user-logout-btn:hover {
  color: var(--destructive);
  border-color: var(--destructive);
}

/* PAGE VIEW CONTAINER */
.page-view {
  padding: 24px 32px 64px 32px;
  display: none;
  flex-direction: column;
  gap: 24px;
}

.page-view.active {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
  margin-bottom: 4px;
}

.page-description {
  font-size: 0.88rem;
  color: var(--muted-foreground);
}

/* SHADCN CARDS GRID */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.shadcn-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.card-icon {
  font-size: 1.1rem;
}

.card-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--foreground);
  margin-bottom: 6px;
}

.card-subtext {
  font-size: 0.76rem;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-subtext.text-danger { color: var(--destructive); }
.card-subtext.text-warning { color: var(--warning); }
.card-subtext.text-success { color: var(--success); }

/* DATA TABLES (TANSTACK STYLE) */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.table-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.table-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-input {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.82rem;
  min-width: 200px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.filter-select {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.82rem;
  cursor: pointer;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.data-table th {
  padding: 10px 16px;
  font-weight: 600;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  background: var(--muted);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
}

.data-table tr:hover td {
  background-color: var(--muted);
}

/* STATUS BADGES */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge.critical {
  background: rgba(239, 68, 68, 0.12);
  color: var(--destructive);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.ready {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* FILA DO CORRETOR — FOCUS MODE (1 TAREFA POR VEZ) */
.focus-task-container {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.task-progress-bar-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.task-progress-track {
  width: 100%;
  height: 6px;
  background: var(--secondary);
  border-radius: 999px;
  overflow: hidden;
}

.task-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.task-card-main {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.task-property-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--secondary);
  color: var(--foreground);
  margin-bottom: 12px;
}

.task-question-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 8px;
  line-height: 1.35;
}

.task-question-context {
  font-size: 0.88rem;
  color: var(--muted-foreground);
  margin-bottom: 24px;
}

.quick-answers-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.quick-answer-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.quick-answer-btn:hover {
  border-color: var(--primary);
  background: rgba(2, 132, 199, 0.04);
}

.quick-answer-btn.selected {
  border-color: var(--primary);
  background: rgba(2, 132, 199, 0.08);
  font-weight: 600;
}

.key-hint {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted-foreground);
}

.task-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.btn-confirm-next {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.btn-confirm-next:hover {
  background: var(--primary-hover);
}

.btn-mark-deal-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-mark-deal-secondary:hover {
  color: var(--destructive);
  border-color: var(--destructive);
}

/* SPLIT VIEW (LADO A LADO) */
.split-view-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .split-view-container {
    grid-template-columns: 1fr;
  }
}

.split-column {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.split-column-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.split-column-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.json-preview-box {
  background: #09090b;
  color: #38bdf8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
  border: 1px solid #27272a;
}

/* RESPONSIVIDADE */
@media (max-width: 820px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.mobile-open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}
