/* ---- Visual fix v2: tools-header with no background ---- */
.tools-header{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  position: sticky;
  top: 0;
  z-index: 900; /* keep menus/modals above */
}

.dark-mode .tools-header{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}


/* ---- Visual fix: logo header should be "invisible" (only logo visible) ---- */
.header{
  position: static !important;       /* ensure not sticky */
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Dark mode: keep header fully transparent as well */
.dark-mode .header{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Keep the sticky bar just for the tools rectangle/title area */
.tools-header{
  position: sticky;
  top: 0;
  z-index: 900; /* below dropdowns(1000)/modals(1055) */
  background: rgba(255,255,255,0.88);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.35);
}

/* Dark mode background for the sticky tools header for better contrast */
.dark-mode .tools-header{
  background: rgba(20,20,20,0.75);
  border-bottom: 1px solid rgba(255,255,255,0.12);
}


/* ---- Sticky refactor (requested) ---- */
/* Ensure site header is normal (not sticky) on tools page */
.header{
  position: static !important;
}

/* Make the rectangle "Manage Workspaces and Cards" sticky */
.tools-header{
  position: sticky;
  top: 0;
  z-index: 900; /* below dropdowns (1000) and modals (1055) */
  background: rgba(255,255,255,0.88);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.35);
}


/* Sticky header for tools page */
.header{
  position: sticky;
  top: 0;
  z-index: 2000;
  background: rgba(255,255,255,0.85);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.35);
}

/* Header and Navigation */
.header, .nav-tabs, .tab-content {
  margin-left: 80px;
  margin-right: 80px;
}

.nav-tabs {
  flex-wrap: nowrap;
  border: 0;
  overflow-y: hidden;
  font-family: 'Poppins', sans-serif;
}

.nav-tabs::-webkit-scrollbar {
  height: 8px;
  border-radius: 20px;
}

.nav-tabs::-webkit-scrollbar-thumb {
  background-color: rgba(10, 15, 21, .3);
  border-radius: 20px;
}

.tab-item .nav-link,
.tab-item .nav-link.active {
  position: relative;
  background: transparent;
  color: #0A0F15;
  font-weight: 700;
  border: 0;
}

.tab-item .nav-link.active {
  color: #006aff;
}

.tab-item .nav-link.active::after {
  content: "";
  position: absolute;
  background-color: #006aff;
  width: 100%;
  height: 4px;
  left: 0;
  bottom: 2px;
  border-radius: 20px;
}

/* Card Grid */
.card-grid {
  margin-top: 50px;
}

.card img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 10%;
  display: inline-block;
  vertical-align: middle;
  margin: 0;
}

.card-title {
  margin: 0;
  align-content: left;
}

.card-img-top {
  width: 100%;
  height: auto;
}

/* Modal "Select Card" Styles */
#selectCardModal .card .card-img-top {
  display: block;
  max-height: 50px;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  object-fit: contain;
  padding: 5px;
}

#selectCardSearch {
  font-size: 1rem;
}

/* Extra Styles */
.modal-content {
  border-radius: 12px;
}

.card {
  border-radius: 12px;
}

.btn {
  border-radius: 8px;
}

#selectedCardPreview {
  font-family: 'Poppins', sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #fff;
  max-width: 100%;
}

#selectedCardPreview img {
  width: 40px !important;
  height: 40px !important;
  object-fit: contain !important;
  border-radius: 5px;
  flex-shrink: 0;
  margin: 0;
  display: block;
}

#selectedCardPreview span {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Tags List in Manage Tags Modal */
#tagsList {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.tag-item {
  background-color: #e8f0fe;
  border: 1px solid #006aff;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.tag-item:hover {
  background-color: #d0e2fd;
  transform: translateY(-2px);
}

.tag-item .tag-name {
  margin-right: 5px;
  font-size: 0.9rem;
  color: #0A0F15;
}

.tag-item .tag-delete {
  cursor: pointer;
  color: #dc3545;
  font-size: 1rem;
  transition: color 0.3s ease;
}

.tag-item .tag-delete:hover {
  color: #a71d2a;
}

/* Background */
#particles-js {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, #ffffff 0%, #e0f7ff 100%);
  z-index: -1;
  pointer-events: none;
}

/* Buttons Styles */
.btn-primary {
  background-color: #006aff !important;
  border: none;
  color: #fff;
  font-size: 0.9rem; /* Tamanho original do btn-primary */
  font-weight: 500;
  padding: 0.5rem 1rem; /* Padding original do btn-primary */
  transition: background 0.3s ease, transform 0.3s ease;
}

.btn-primary:hover {
  background-color: #005ae0 !important;
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: #4c9dff !important;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background 0.3s ease, transform 0.3s ease;
}

.btn-secondary:hover {
  background-color: #3a8ce0 !important;
  transform: translateY(-2px);
}

/* Botão Info (PEQUENO - para uso em modais e elementos secundários) */
.btn-info {
  background-color: #0d6efd !important;
  border: none;
  color: #fff;
  font-size: 0.7rem; /* Tamanho original do btn-info para info buttons */
  font-weight: 500;
  padding: 0.5rem 1rem; /* Padding original do btn-info para info buttons */
  transition: background 0.3s ease, transform 0.3s ease;
}

.btn-info:hover {
  background: linear-gradient(45deg, #6ac6ff, #005ae0);
  color: #fff;
  transform: scale(1.2); /* Efeito hover original do btn-info */
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Nova CLASSE para os botões de ação principais (Criar Nova Guia, Criar Novo Cartão, Gerenciar Etiquetas) */
.btn-action-main {
  background-color: #0d6efd !important; /* Cor de fundo que era do btn-info original para o "Gerenciar Etiquetas" */
  border: none;
  color: #fff;
  font-size: 0.9rem; /* Tamanho maior, como os botões "Criar" originais */
  font-weight: 500;
  padding: 0.5rem 1rem; /* Padding maior, como os botões "Criar" originais */
  transition: background 0.3s ease, transform 0.3s ease;
}

.btn-action-main:hover {
  background: linear-gradient(45deg, #6ac6ff, #005ae0); /* Efeito hover igual ao que "Gerenciar Etiquetas" tinha */
  color: #fff;
  transform: translateY(-2px); /* Efeito de lift, consistente com outros botões grandes */
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.btn-success {
  background-color: #0abf53 !important;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background 0.3s ease, transform 0.3s.ease;
}

.btn-success:hover {
  background-color: #0ea44b !important;
  transform: translateY(-2px);
}

.btn-warning {
  background-color: #01110c43 !important;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background 0.3s ease, transform 0.3s ease;
}

.btn-warning:hover {
  background-color: #00000027 !important;
  transform: translateY(-2px);
}

.btn-danger {
  background-color: #ff4d4f !important;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background 0.3s ease, transform 0.3s ease;
}

.btn-danger:hover {
  background-color: #e44446 !important;
  transform: translateY(-2px);
}

.card-body a.btn,
.card-body button.btn {
  margin-right: 0.5rem;
}

.tools-header {
  background-color: #ffffffcc;
  backdrop-filter: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.swap-animation {
  transition: all 0.3s ease;
}

/* Night Mode Overrides */
body.night-mode .header,
body.night-mode .tools-header {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
}

body.night-mode .header a,
body.night-mode .nav a {
  color: #ffffff !important;
}

body.night-mode .nav-tabs .nav-link {
  color: #ffffff !important;
}

body.night-mode .nav-tabs .nav-link.active {
  color: #0d6efd !important;
}

body.night-mode .tab-content {
  background-color: transparent !important;
}

body.night-mode .card-grid .card,
body.night-mode .card {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
  border-color: #444444 !important;
}

body.night-mode .btn-primary {
  background-color: #0d6efd !important;
  border: none;
  color: #ffffff !important;
}

body.night-mode .btn-secondary {
  background-color: #444444 !important;
  border: none;
  color: #ffffff !important;
}

/* Night mode para o btn-info (o pequeno) */
body.night-mode .btn-info {
  background-color: #0d6efd !important;
  border: none;
  color: #ffffff !important;
}

/* Night mode para a NOVA CLASSE de botões de ação principais */
body.night-mode .btn-action-main {
  background-color: #0d6efd !important;
  border: none;
  color: #ffffff !important;
}

body.night-mode .btn-success {
  background-color: #0abf53 !important;
  border: none;
  color: #ffffff !important;
}

body.night-mode .btn-warning {
  background-color: #333333 !important;
  border: none;
  color: #ffffff !important;
}

body.night-mode .btn-danger {
  background-color: #ff4d4f !important;
  border: none;
  color: #ffffff !important;
}

body.night-mode .modal-content {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
  border-color: #444444 !important;
}

body.night-mode #particles-js {
  background: transparent !important;
}

body.night-mode .tag-item {
  background-color: #2c2c2c !important;
  border: 1px solid #444444 !important;
}

body.night-mode .tag-item .tag-name {
  color: #ffffff !important;
}

body.night-mode {
  background: #121212 !important;
  color: #ffffff !important;
}

body.night-mode #particles-js {
  background: transparent !important;
}

body.night-mode .header,
body.night-mode .tools-header {
  background-color: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

body.night-mode .container.my-4 {
  background-color: transparent !important;
}

.card.position-relative {
  position: relative;
}
.card-info {
  position: absolute;
  top: 10px;
  right: 4px;
  z-index: 10;
  border-radius: 50% !important;
}

.tooltip-inner {
  background-color: #005ae0;
  color: #fff;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border: 2px solid #0041b3;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  text-align: left;
  font-family: 'Poppins', sans-serif;
  max-width: 250px;
}

.tooltip.bs-tooltip-top .tooltip-arrow::before {
  border-top-color: #005ae0;
}

/* ==== Dark Mode: Selected Card Preview (fix de contraste) ==== */
body.night-mode #selectedCardPreview {
  background: #1e1e1e !important;   /* fundo escuro para respeitar o tema */
  color: #ffffff !important;         /* texto visível */
  border-color: #444444 !important;  /* borda consistente com o dark */
}

body.night-mode #selectedCardPreview span {
  color: #ffffff !important;         /* garante que o texto dentro do span não herda branco sobre branco */
}

body.night-mode #selectedCardPreview img {
  /* sem filtros; apenas garante que a imagem mantém o aspeto original */
  filter: none !important;
}

/* ===== Melhorias UI: selector de Tags ===== */
.tag-select {
  min-height: 280px;      /* janela maior */
  max-height: 380px;
  padding: 8px;
  border-radius: 12px;
  overflow-y: auto;       /* scroll interno */
}

#searchTagsInput {
  border-radius: 10px;
}

#selectedTagsPreview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #e8f0fe;
  color: #0A0F15;
  border: 1px solid #006aff;
  border-radius: 999px;
  font-size: .85rem;
  line-height: 1;
  transition: transform .15s ease, background .2s.ease;
}
.tag-chip:hover { transform: translateY(-1px); background:#d0e2fd; }
.tag-chip .chip-x {
  cursor: pointer;
  font-size: .9rem;
  color: #dc3545;
}
.tag-chip .chip-x:hover { color:#a71d2a; }

/* Dark mode */
body.night-mode .tag-select { background:#1e1e1e; border-color:#444; color:#fff; }
body.night-mode .tag-chip { background:#2c2c2c; border-color:#444; color:#fff; }
body.night-mode #searchTagsInput { background:#1e1e1e; border-color:#444; color:#fff; }

/* ==== FINAL OVERRIDE: remove ANY visible background on top bars ==== */
.header{
  position: static !important;
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.tools-header{
  position: sticky;
  top: 0;
  z-index: 900; /* keep menus above */
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.dark-mode .header,
.dark-mode .tools-header{
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* === FINAL ADJUSTMENTS (REQUESTED) === */
/* Smaller global search bar (Search by title or tags) */
.tools-header .input-group {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

/* Smaller, more compact input */
#globalCardSearch {
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
}

/* Make Manage Tabs and Cards box match other boxes (light & night mode) */
body:not(.night-mode) .tools-header {
  background-color: #ffffff !important;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body.night-mode .tools-header {
  background-color: #1e1e1e !important;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.55);
}

/* === Global card count under search (alinhado com a barra) === */
#globalCardSearchCount {
  display: block;
  font-size: 0.9rem;
  max-width: 420px;          /* igual ao .tools-header .input-group */
  margin: 4px auto 0 auto;   /* centra o bloco, mas alinha pelo lado esquerdo */
  text-align: left;
  padding-left: 0.10rem;      /* alinha com o texto dentro do input */
  color: #4b5563;
}

/* Night mode: visível e no mesmo sítio */
body.night-mode #globalCardSearchCount,
.dark-mode #globalCardSearchCount {
  color: #e5e7eb !important;
}


/* --- AI Card Generator --- */
.ai-card-box{
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 14px;
  background: rgba(0,0,0,0.02);
}
body.dark-mode .ai-card-box{
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}
#aiCardStatus{
  min-height: 18px;
}
.card-draggable .card-icon-top{
  /* Same placement/size as the card image thumbnail (top-left, 30x30) */
  width: 30px;
  height: 30px;
  border-radius: 10%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

/* --- AI Finder (mini chat "onde está?") --- */
.ai-finder{
  position: fixed;
  right: 18px;
  top: 20px;
  width: 360px;
  max-width: calc(100vw - 36px);
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  z-index: 9999;
}
body.dark-mode .ai-finder{
  border-color: rgba(255,255,255,0.14);
  background: rgba(17,25,40,0.92);
}
.ai-finder-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0,0,0,0.04);
}
body.dark-mode .ai-finder-header{
  background: rgba(255,255,255,0.06);
}
.ai-finder-title{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.ai-finder-toggle{
  border: 0;
  background: transparent;
  padding: 4px 6px;
  border-radius: 10px;
}
.ai-finder-toggle:hover{
  background: rgba(0,0,0,0.06);
}
body.dark-mode .ai-finder-toggle:hover{
  background: rgba(255,255,255,0.08);
}
.ai-finder-body{
  padding: 10px 12px 12px 12px;
}
.ai-finder-messages{
  max-height: 230px;
  overflow: auto;
  padding-right: 4px;
}
.ai-finder-msg{
  display: flex;
  margin: 8px 0;
}
.ai-finder-msg-user{
  justify-content: flex-end;
}
.ai-finder-msg-assistant{
  justify-content: flex-start;
}
.ai-finder-bubble{
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.25;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.98);
}
body.dark-mode .ai-finder-bubble{
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}
.ai-finder-msg-user .ai-finder-bubble{
  border: 1px solid rgba(0,105,255,0.25);
}
.ai-finder-input{
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ai-finder-input .form-control{
  border-radius: 12px;
}
.ai-finder-input .btn{
  border-radius: 12px;
}
.ai-finder-small{
  margin-top: 8px;
  font-size: 0.85rem;
}
.ai-finder-results{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-finder-result{
  text-align: left;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.03);
  border-radius: 12px;
  padding: 10px;
}
body.dark-mode .ai-finder-result{
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}
.ai-finder-result-title{
  font-weight: 700;
}
.ai-finder-result-sub{
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 2px;
}
.ai-finder-result-reason{
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 6px;
}

/* --- Highlight when AI finds a card --- */
.ai-highlight{
  animation: aiPulse 2.4s ease-out;
}
@keyframes aiPulse{
  0%{ transform: scale(1); }
  10%{ transform: scale(1.01); }
  35%{ transform: scale(1.01); }
  100%{ transform: scale(1); }
}
.ai-highlight .card{
  box-shadow: 0 0 0 3px rgba(0, 105, 255, 0.28), 0 18px 42px rgba(0,0,0,0.16);
}

.circle-btn{
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 9999px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.circle-btn i{
  line-height: 1;
}

/* ==== FIX: AI Finder readable in NIGHT MODE (site uses body.night-mode) ==== */
body.night-mode .ai-finder{
  border-color: rgba(255,255,255,0.14);
  background: rgba(17,25,40,0.92);
  color: #e5e7eb;
}

body.night-mode .ai-finder-header{
  background: rgba(255,255,255,0.06);
}

body.night-mode .ai-finder-title,
body.night-mode .ai-finder-title span,
body.night-mode .ai-finder-title i{
  color: #e5e7eb;
}

body.night-mode .ai-finder-bubble{
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #e5e7eb;
}

body.night-mode .ai-finder-result{
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #e5e7eb;
}

/* Bootstrap "text-muted" fica fraco no dark, força legível */
body.night-mode .ai-finder .text-muted{
  color: rgba(229,231,235,0.75) !important;
}

/* Input legível no night mode */
body.night-mode #aiFinderQuery{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.14);
  color: #e5e7eb;
}
body.night-mode #aiFinderQuery::placeholder{
  color: rgba(229,231,235,0.65);
}

/* --- AI Finder as a floating bubble + centered overlay (requested) --- */
.ai-finder-fab{
  position: fixed;
  right: 20px;
  bottom: 92px; /* sits above settings button */
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.ai-finder-fab:hover{
  transform: translateY(-1px);
  box-shadow: 0 18px 46px rgba(0,0,0,0.20);
}

body.dark-mode .ai-finder-fab,
body.night-mode .ai-finder-fab{
  border-color: rgba(255,255,255,0.14);
  background: rgba(17,25,40,0.92);
  color: #e5e7eb;
}

.ai-finder-overlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 20000;
}

.ai-finder-overlay.open{
  opacity: 1;
  pointer-events: auto;
}

.ai-finder-shell{
  width: min(560px, calc(100vw - 36px));
  transform: scale(0.92);
  transition: transform 160ms ease;
}

.ai-finder-overlay.open .ai-finder-shell{
  transform: scale(1);
}

/* override the old fixed placement when inside the overlay */
.ai-finder-overlay .ai-finder{
  position: relative;
  right: auto;
  top: auto;
  width: 100%;
  max-width: 100%;
  z-index: auto;
}

.ai-finder-overlay .ai-finder-messages{
  max-height: min(52vh, 420px);
}