/* RTGEO — Layout Principal, Abas e Componentes Globais */

/* App Container */
.app-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  z-index: 1;
}

/* Header & Tab Bar */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 12px;
  background: var(--surface-translucent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  gap: 8px;
  box-sizing: border-box;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(39, 76, 138, 0.25);
  letter-spacing: -0.5px;
}

.brand-text h1 {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
  line-height: 1.1;
  margin: 0;
}

.brand-text p {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(226, 232, 240, 0.6);
  padding: 2px;
  border-radius: var(--radius-full);
  flex-shrink: 1;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.tab-btn svg {
  width: 14px;
  height: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Seletor de Praça (Itumbiara ⇄ Uberaba) */
.city-selector-pills {
  display: flex;
  align-items: center;
  background: #edf2f7;
  padding: 2px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  gap: 2px;
}

.city-pill-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.city-pill-btn:hover {
  color: var(--text-main);
}

.city-pill-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.city-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  transition: all 0.2s ease;
}

.city-pill-btn.active .city-pill-dot {
  background: #26a25c;
  box-shadow: 0 0 6px rgba(38, 162, 92, 0.6);
}

/* Tab Views Container */
.views-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-view {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tab-view.active {
  display: block;
}

/* Generic UI Elements */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-btn:hover {
  background: var(--bg-app);
  border-color: var(--border-focus);
}

.pill-btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pill-btn.primary:hover {
  background: var(--primary-bright);
}

.pill-btn.success {
  background: var(--oportunidade);
  color: white;
  border-color: var(--oportunidade);
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popup);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

/* Responsive adjustments */
@media (max-width: 860px) {
  .main-header {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .brand-text p {
    display: none;
  }
  .tab-btn span {
    display: none;
  }
  .tab-btn {
    padding: 7px 10px;
  }
  .header-user-email {
    display: none;
  }
}

/* ==========================================================================
   SISTEMA DE AUTENTICAÇÃO GLOBAL (RTAUTH)
   ========================================================================== */

/* Contêiner Geral da Tela de Autenticação */
.auth-screen-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-app);
  overflow-y: auto;
  box-sizing: border-box;
}

.auth-screen-container.hidden {
  display: none !important;
}

/* Card Principal de Login */
.auth-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(39, 76, 138, 0.05);
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
  text-align: center;
  box-sizing: border-box;
  animation: authCardFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-brand-area {
  margin-bottom: 24px;
}

.auth-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 22px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 20px rgba(39, 76, 138, 0.3);
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}

.auth-brand-area h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 4px 0;
  letter-spacing: -0.4px;
}

.auth-brand-area p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* Botão Google OAuth Oficial */
.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.auth-google-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.auth-google-btn:active {
  transform: translateY(0);
  background: #f3f4f6;
}

.auth-google-btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

.auth-google-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.auth-google-help {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
}

/* Divisor Visual */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider-text {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Formulário de Email e Senha */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.auth-input {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-main);
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.auth-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(39, 76, 138, 0.15);
}

.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 16px;
  margin-top: 6px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(39, 76, 138, 0.25);
}

.auth-submit-btn:hover {
  background: var(--primary-bright);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(39, 76, 138, 0.35);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Mensagem de Erro */
.auth-error-msg {
  display: none;
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  line-height: 1.4;
  margin-top: 4px;
}

.auth-success-msg {
  display: none;
  padding: 10px 12px;
  background: #ecfdf3;
  border: 1px solid #b7e5c9;
  border-radius: var(--radius-sm);
  color: #17694e;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  line-height: 1.4;
  margin-top: 4px;
}

/* Ações auxiliares da autenticação */
.auth-password-help {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.auth-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.auth-link-btn {
  min-height: 40px;
  padding: 5px 0;
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

.auth-link-btn:hover {
  color: var(--primary-bright);
}

.auth-link-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-secondary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  margin-top: 10px;
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-secondary-btn:hover {
  background: var(--bg-app);
  border-color: var(--primary);
  color: var(--primary);
}

.auth-secondary-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

/* Estado pós-cadastro: confirmação do endereço antes da autorização */
.auth-verification-card {
  max-width: 440px;
}

.auth-verification-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  color: var(--primary);
  background: rgba(39, 76, 138, 0.1);
  border: 1px solid rgba(39, 76, 138, 0.16);
  border-radius: 18px;
}

.auth-verification-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.auth-verification-card h2 {
  margin: 0;
  color: var(--primary);
  font-size: 21px;
  font-weight: 800;
}

.auth-verification-lead {
  margin: 18px 0 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-verification-email {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 800;
}

.auth-verification-copy {
  margin: 15px 0 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

/* Modal de criação de senha após login com Google */
.auth-password-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 31, 58, 0.56);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-sizing: border-box;
}

.auth-password-modal[hidden] {
  display: none !important;
}

.auth-password-dialog {
  position: relative;
  width: min(100%, 430px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.42);
  box-sizing: border-box;
  animation: authCardFadeIn 0.22s ease-out;
}

.auth-password-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.auth-password-close:hover {
  background: var(--bg-app);
  color: var(--primary);
}

.auth-password-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  color: var(--primary);
  background: rgba(39, 76, 138, 0.1);
  border: 1px solid rgba(39, 76, 138, 0.16);
  border-radius: 16px;
}

.auth-password-icon svg {
  width: 27px;
  height: 27px;
}

.auth-password-kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}

.auth-password-dialog h2 {
  margin: 0 34px 8px 0;
  color: var(--primary);
  font-size: 21px;
  font-weight: 800;
}

.auth-password-dialog > p:not(.auth-password-footnote) {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-password-footnote {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

body.auth-password-modal-open {
  overflow: hidden;
}

/* Rodapé do Auth Card */
.auth-footer {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-toggle-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color 0.15s;
}

.auth-toggle-btn:hover {
  color: var(--primary-bright);
}

/* Splash de Carregamento */
.auth-splash {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.auth-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(39, 76, 138, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: authSpin 0.8s linear infinite;
}

@keyframes authSpin {
  to { transform: rotate(360deg); }
}

.auth-splash p {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

/* Card de Acesso Restrito */
.auth-unauthorized-box {
  background: #fff;
  border: 1px solid #fee2e2;
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 20px 40px -15px rgba(239, 68, 68, 0.15);
  animation: authCardFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-unauth-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.auth-unauthorized-box h2 {
  font-size: 19px;
  font-weight: 800;
  color: var(--danger);
  margin: 0 0 8px 0;
}

.auth-unauthorized-box p {
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.5;
  margin: 0 0 16px 0;
}

.auth-unauth-info-card {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 20px;
}

.auth-unauth-info-card strong {
  color: var(--primary);
}

/* ==========================================================================
   CRACÁ E SESSÃO DO USUÁRIO NO HEADER PRINCIPAL
   ========================================================================== */
.header-user-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.header-user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.header-user-email {
  font-weight: 600;
  color: var(--text-main);
  max-width: 105px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-role-badge {
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.header-role-badge.master {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.header-role-badge.manager {
  background: #e8f0ff;
  color: var(--primary);
  border: 1px solid #bfd2ed;
}

.header-role-badge.corretor {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.header-role-badge.pending {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.btn-header-logout {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-family: inherit;
  font-weight: 600;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-header-logout:hover {
  background: #fee2e2;
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-header-password {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: #e8f0ff;
  color: var(--primary);
  border: 1px solid #bfd2ed;
  font-family: inherit;
  font-weight: 700;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-header-password:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

