/* ESTILOS DA APLICAÇÃO WEB (1:1 MOCKUP FINSOLVE SAAS 2026 - NEXO WEB) */
:root {
  --bg-dark: #0c101d;
  --bg-card: #151c2c;
  --bg-panel: #101726;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --accent-green: #10b981;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --card-border: rgba(255, 255, 255, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* COMPATIBILIDADE GLOBAL DE CLIQUE EM TODOS OS NAVEGADORES E DISPOSITIVOS (SAFARI, IOS, ANDROID, EMBEDDED WEBVIEWS) */
button, .btn, .nav-item, .cat-tab-btn, .saas-card-item, .casa-btn-pop, .searchable-item, .modal-close-x, .btn-icon, .tab-login-btn, [onclick], input, select, textarea {
  font-family: inherit;
  cursor: pointer !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ESTILIZAÇÃO COMPACTA E MODERNA DAS TABS DE LOGIN */
.tab-login-btn {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #94a3b8 !important;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer !important;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
}

.tab-login-btn:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.05);
}

.tab-login-btn.active {
  background: #6366f1 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#tab-login-super.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* OCULTAR DEFINITIVAMENTE O BOTÃO DE 2ª VIA NOS CARTÕES */
#pop-btn-segunda-via {
  display: none !important;
}

/* ECRÃS DA APLICAÇÃO - CORREÇÃO DE ACESSO DIRETO SEM ROLAR */
.screen {
  display: none !important;
}

.screen.active {
  display: flex !important;
}

#login-screen {
  min-height: 100vh;
  width: 100vw;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#main-screen {
  min-height: 100vh;
  width: 100vw;
}

/* OBSERVATIVE BADGE ON CARD (COMPACTO E SEM DESESTRUTURAR) */
.saas-card-obs {
  font-size: 11px;
  font-weight: 600;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.saas-card-obs span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* SEARCHABLE SELECT DROPDOWN COMPONENT */
.searchable-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.select-chevron-icon {
  position: absolute;
  right: 14px;
  color: var(--text-subtle);
  pointer-events: none;
  font-size: 12px;
  transition: transform 0.2s ease;
}

.searchable-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #101726;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  z-index: 999999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.searchable-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  transition: background 0.15s ease;
}

.searchable-item:last-child {
  border-bottom: none;
}

.searchable-item:hover, .searchable-item.selected {
  background: var(--primary-light);
}

.searchable-item-name {
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
}

.searchable-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* CHAT BUBBLES */
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-bubble.me {
  align-self: flex-end;
  background: #6366f1;
  color: #fff;
  border-bottom-right-radius: 2px;
}
.chat-bubble.other {
  align-self: flex-start;
  background: #151c2c;
  color: #f8fafc;
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 2px;
}
.chat-bubble-sender {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  opacity: 0.85;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.chat-bubble-time {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.7;
}

/* BOTÕES GERAIS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #10b981;
  color: #ffffff;
}
.btn-secondary:hover {
  background: #059669;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: color 0.2s;
}
.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* LAYOUT PRINCIPAL DA APLICAÇÃO (SIDEBAR FIXA + MAIN) */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* BARRA LATERAL NATIVA (SIDEBAR) */
.app-sidebar {
  width: var(--sidebar-width);
  background: #101726;
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 24px;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-brand-text h1 {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-brand-text span {
  font-size: 11px;
  color: var(--text-subtle);
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
  margin: 16px 0 8px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.2s ease;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-item.active {
  background: var(--primary-light);
  color: #818cf8;
  font-weight: 700;
}

.nav-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.nav-item.active .nav-badge {
  background: var(--primary);
  color: #fff;
}

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

.user-profile-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-mini {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1f293d;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #818cf8;
  font-size: 14px;
}

.user-details-mini h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
}

.user-details-mini p {
  font-size: 10.5px;
  color: var(--text-subtle);
}

/* CONTEÚDO PRINCIPAL (MAIN) */
.app-main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP HEADER ERP */
.main-top-header {
  height: 70px;
  background: #101726;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 900;
}

.header-search-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #151c2c;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px 16px;
  width: 100%;
  max-width: 440px;
}

.header-search-wrapper i {
  color: var(--text-subtle);
  font-size: 14px;
}

.header-search-wrapper input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 13.5px;
  width: 100%;
  outline: none;
}

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

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

/* DASHBOARD BODY */
.dashboard-body {
  padding: 28px;
  flex: 1;
}

.dashboard-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.dashboard-title-row h2 {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
}

.category-tabs-bar {
  display: flex;
  gap: 6px;
  background: #151c2c;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
}

.cat-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.cat-tab-btn.active {
  background: var(--primary);
  color: #fff;
}

/* GRID DE CARTÕES SAAS (1:1 FINSOLVE SAAS MOCKUP) */
.cards-grid-saas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.saas-card-item {
  background: #151c2c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.saas-card-item:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.saas-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.saas-card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.saas-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
}

.saas-card-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.saas-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.saas-badge-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.saas-badge-pill.in-progress {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.saas-badge-pill.paid {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.saas-badge-pill.overdue {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.saas-card-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #101726;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.saas-metric-box span {
  font-size: 10.5px;
  color: var(--text-subtle);
  display: block;
  font-weight: 600;
}

.saas-metric-box strong {
  font-size: 14px;
  color: #fff;
  font-weight: 700;
}

/* PROGRESS BAR */
.saas-progress-block {
  margin-bottom: 8px;
}

.saas-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.saas-progress-track {
  height: 8px;
  background: #101726;
  border-radius: 10px;
  overflow: hidden;
}

.saas-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #3b82f6 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
}

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

.saas-card-icons {
  display: flex;
  gap: 12px;
  color: var(--text-subtle);
  font-size: 14px;
}

.saas-card-icons i:hover {
  color: #fff;
}

/* GRADE DE CASAS EM POPUP MODAL (10 COLUNAS) */
.casas-grid-popup {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  padding: 10px 0;
}

.casa-btn-pop {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #1b2537;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.casa-btn-pop:hover:not(:disabled) {
  background: #25334d;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.casa-btn-pop.paga {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
  cursor: default;
}

.casa-btn-pop.selecionada {
  background: #6366f1;
  border-color: #818cf8;
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
  transform: scale(1.05);
}

/* MODAIS - PREVENÇÃO DE OVERLAY INVISÍVEL QUE BLOQUEIA CLIQUES EM ALGUNS NAVEGADORES */
.modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  pointer-events: none !important;
}

.modal.active {
  display: flex !important;
  pointer-events: auto !important;
}

.modal-content {
  background: #151c2c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalFadeIn 0.2s ease;
  pointer-events: auto !important;
}

.modal-content.modal-lg {
  max-width: 780px;
}

.modal-content.modal-xl {
  max-width: 960px;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header-flex h2 {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.modal-close-x {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.modal-close-x:hover {
  color: #fff;
}

.modal-body-scroll {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* FORMULÁRIOS & INPUTS */
.input-group {
  margin-bottom: 16px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input, .input-group select, .input-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: #101726;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus, .input-group select:focus {
  border-color: var(--primary);
}

/* TABELAS ENTERPRISE */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  background: #101726;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-main);
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ESTILOS PARA A 2ª VIA DO CARTÃO (IMPRESSÃO) */
.second-via-card-container {
  background: #fff;
  color: #0f172a;
  padding: 24px;
  border-radius: 12px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.second-via-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #6366f1;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.second-via-header .brand-title {
  font-weight: 800;
  font-size: 16px;
  color: #1e1b4b;
}

.second-via-header .card-code {
  font-weight: 800;
  font-size: 18px;
  color: #6366f1;
}

.second-via-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 12px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.second-via-grid-title {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.second-via-grid-61 {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.second-via-house-box {
  aspect-ratio: 1;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
}

.second-via-house-box.paga {
  background: #10b981;
  color: #fff;
  border-color: #059669;
}

.second-via-footer {
  font-size: 10px;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}

/* RESPONSIVIDADE MOBILE (TELEFONES & TABLETS) */
@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-main-content {
    margin-left: 0;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .main-top-header {
    padding: 0 16px;
  }

  .header-search-wrapper {
    max-width: 200px;
  }

  .dashboard-body {
    padding: 16px;
  }

  .casas-grid-popup {
    grid-template-columns: repeat(6, 1fr);
  }

  .btn-text-mobile {
    display: none;
  }
}

@media (max-width: 550px) {
  .casas-grid-popup {
    grid-template-columns: repeat(5, 1fr);
  }

  .cards-grid-saas {
    grid-template-columns: 1fr;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #modal-segunda-via, #modal-segunda-via * {
    visibility: visible;
  }
  #modal-segunda-via {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
}
