/* ============================================================
   DTunnelMod - Theme DT (painel novo / shadcn + tailwind)
   Variáveis HSL no padrão shadcn — usadas pelas classes
   tailwind (bg-card/95, border-border/60, bg-primary/10 ...).
   ============================================================ */

:root,
html[data-bs-theme="dark"] {
  --background: 220 12% 10%;
  --foreground: 220 14% 92%;
  --card: 220 12% 13%;
  --card-foreground: 220 14% 94%;
  --popover: 220 12% 13%;
  --popover-foreground: 220 14% 94%;
  --primary: 214 16% 68%;
  --primary-foreground: 220 18% 10%;
  --secondary: 220 10% 18%;
  --secondary-foreground: 220 14% 92%;
  --muted: 220 10% 18%;
  --muted-foreground: 220 8% 68%;
  --accent: 220 10% 17%;
  --accent-foreground: 220 14% 94%;
  --destructive: 0 70% 58%;
  --border: 220 10% 24%;
  --input: 220 10% 16%;
  --ring: 214 16% 68%;
  --sidebar: 220 13% 11%;
  --sidebar-foreground: 220 14% 92%;
  --sidebar-border: 220 9% 22%;
  --sidebar-accent: 220 10% 16%;
  --surface-glow: 220 10% 34%;

  --dt-green: #17c964;
  --dt-red: hsl(0 70% 58%);
}

html[data-bs-theme="light"] {
  --background: 220 16% 96%;
  --foreground: 222 18% 16%;
  --card: 220 14% 99%;
  --card-foreground: 222 18% 16%;
  --popover: 220 14% 99%;
  --popover-foreground: 222 18% 16%;
  --primary: 216 12% 42%;
  --primary-foreground: 210 40% 98%;
  --secondary: 220 12% 92%;
  --secondary-foreground: 222 18% 18%;
  --muted: 220 12% 92%;
  --muted-foreground: 220 10% 42%;
  --accent: 220 11% 90%;
  --accent-foreground: 222 18% 18%;
  --destructive: 0 68% 52%;
  --border: 220 12% 84%;
  --input: 220 14% 100%;
  --ring: 216 12% 42%;
  --sidebar: 220 14% 93%;
  --sidebar-foreground: 222 18% 16%;
  --sidebar-border: 220 12% 82%;
  --sidebar-accent: 220 12% 88%;
  --surface-glow: 220 8% 68%;

  --dt-green: #12a150;
  --dt-red: hsl(0 68% 52%);
}

html {
  background-color: hsl(var(--background));
}

html[data-bs-theme="light"] body {
  background-color: hsl(var(--background)) !important;
  color: hsl(var(--foreground)) !important;
}

body {
  font-family: Manrope, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background-color: hsl(var(--background));
  background-image:
    radial-gradient(circle at 50% -12%, hsl(var(--surface-glow) / .5) 0%, transparent 58%),
    radial-gradient(circle at 108% 4%, hsl(var(--primary) / .10) 0%, transparent 42%),
    radial-gradient(circle at -8% 96%, hsl(var(--primary) / .07) 0%, transparent 40%);
  background-attachment: fixed;
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
}

.font-display,
h1, h2, h3, h4, h5, h6 {
  font-family: "Space Grotesk", Manrope, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -.015em;
}

body .text-muted { color: hsl(var(--muted-foreground)) !important; }
body .text-gray-800 { color: hsl(var(--foreground)) !important; }

a { color: hsl(var(--foreground)); text-decoration: none; }
a:hover { color: hsl(var(--primary)); }

.link-none { color: unset !important; }

::selection { background: hsl(var(--primary) / .28); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / .5); background-clip: padding-box; }

/* ---------- Compat: componentes antigos ainda usados (modais, toasts) ---------- */

.modal-content {
  background-color: hsl(var(--card)) !important;
  border: 1px solid hsl(var(--border)) !important;
  border-radius: 1.25rem !important;
  color: hsl(var(--card-foreground));
}

.modal-header,
.modal-footer { border-color: hsl(var(--border)) !important; }

.btn {
  border-radius: .8rem;
  font-weight: 600;
  font-size: .875rem;
  padding: .55rem 1.1rem;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}

.btn-primary {
  background-color: hsl(var(--primary)) !important;
  border-color: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
}

.btn-dark,
.btn-custom-dark {
  background-color: hsl(var(--secondary)) !important;
  border: 1px solid hsl(var(--border)) !important;
  color: hsl(var(--secondary-foreground)) !important;
}

.btn-dark:hover,
.btn-custom-dark:hover {
  background-color: hsl(var(--accent)) !important;
  border-color: hsl(var(--primary) / .45) !important;
}

.btn-danger {
  background-color: hsl(var(--destructive)) !important;
  border-color: hsl(var(--destructive)) !important;
  color: #fff !important;
}

.btn-outline-danger {
  color: hsl(var(--destructive)) !important;
  border-color: hsl(var(--destructive) / .5) !important;
  background: transparent !important;
}

.form-control,
.form-select {
  background-color: hsl(var(--input)) !important;
  border: 1px solid hsl(var(--border)) !important;
  color: hsl(var(--foreground)) !important;
  border-radius: .8rem !important;
}

.form-control:focus,
.form-select:focus {
  border-color: hsl(var(--primary) / .5) !important;
  box-shadow: 0 0 0 3px hsl(var(--primary) / .15) !important;
  background-color: hsl(var(--input)) !important;
  color: hsl(var(--foreground)) !important;
}

.form-control::placeholder { color: hsl(var(--muted-foreground) / .7) !important; }

.input-group-text {
  background-color: hsl(var(--secondary)) !important;
  border: 1px solid hsl(var(--border)) !important;
  color: hsl(var(--muted-foreground)) !important;
}

.form-check-input:checked {
  background-color: var(--dt-green) !important;
  border-color: var(--dt-green) !important;
}

.toaster-message,
.toastr {
  background: hsl(var(--popover)) !important;
  color: hsl(var(--popover-foreground)) !important;
  border: 1px solid hsl(var(--border)) !important;
}

.sweet-backdrop { background-color: rgba(0, 0, 0, .55) !important; }

#impersonation-banner {
  background: #b8860b !important;
  color: #fff !important;
}

/* ---------- Placeholder (loaders) ---------- */

.placeholder {
  background-color: hsl(var(--muted-foreground) / .35) !important;
}

.text-bg-success { background-color: var(--dt-green) !important; }
.text-bg-danger { background-color: hsl(var(--destructive)) !important; }
.text-bg-warning { background-color: #ff9800 !important; }

/* ---------- Search box (pill do painel novo) ---------- */

.dt-search-box {
  position: relative;
  display: flex;
  align-items: center;
  height: 2.5rem;
  border-radius: .75rem;
  border: 1px solid hsl(var(--border) / .55);
  background: hsl(var(--background) / .35);
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.dt-search-box:hover {
  border-color: hsl(var(--border) / .85);
  background: hsl(var(--background) / .45);
}

.dt-search-box:focus-within {
  border-color: hsl(var(--primary) / .45);
  background: hsl(var(--background) / .55);
  box-shadow: 0 0 0 3px hsl(var(--primary) / .1);
}

.dt-search-box > .dt-search-icon {
  pointer-events: none;
  position: absolute;
  left: .875rem;
  display: flex;
  align-items: center;
  color: hsl(var(--muted-foreground) / .75);
  font-size: .9rem;
}

.dt-search-box:focus-within > .dt-search-icon { color: hsl(var(--foreground)); }

.dt-search-box .search-config,
.dt-search-box .search-config .input-group { flex: 1 1 0%; min-width: 0; height: 100%; }

.dt-search-box .search-config input {
  height: 100%;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: .75rem 0 0 .75rem;
  padding-left: 2.5rem;
}

.dt-search-box .search-config input:focus {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
}

.dt-search-box .search-config .input-group-text {
  border: 0 !important;
  border-radius: 0 .75rem .75rem 0;
  background: transparent !important;
  height: 100%;
}

.dt-search-box .dt-search-btn {
  border: 0 !important;
  border-radius: 0 .75rem .75rem 0;
  background: transparent !important;
  height: 100%;
}

/* ---------- Filtro select (pill) ---------- */

.dt-filter-select {
  height: 2.5rem !important;
  border-radius: .75rem !important;
  border: 1px solid hsl(var(--border) / .55) !important;
  background: hsl(var(--background) / .35) !important;
  color: hsl(var(--foreground)) !important;
  font-size: .875rem;
  font-weight: 500;
  padding: 0 .9rem !important;
  width: auto !important;
  box-shadow: none !important;
}

/* ---------- Badge contador (Settings list) ---------- */

.dt-count-badge {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: hsl(var(--secondary));
  padding: 0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: hsl(var(--secondary-foreground));
  box-shadow: 0 0 0 1px hsl(var(--border) / .7);
  font-variant-numeric: tabular-nums;
}

/* ---------- Pills de contagem ---------- */

.dt-stat-pill {
  display: inline-flex;
  height: 2.25rem;
  min-width: fit-content;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: 999px;
  background: hsl(var(--background) / .35);
  padding: 0 1rem;
  font-size: .875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  box-shadow: 0 0 0 1px hsl(var(--border) / .55);
}

.dt-stat-pill i { font-size: .85rem; }

/* ---------- Botões do card-header (tamanho do painel novo) ---------- */

.dt-btn {
  display: inline-flex;
  cursor: pointer;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
  border-radius: .75rem;
  border: 1px solid hsl(var(--border) / .6);
  background: hsl(var(--secondary) / .8);
  color: hsl(var(--secondary-foreground));
  font-size: .875rem;
  font-weight: 500;
  padding: .5rem 1rem;
  height: 2.5rem;
  box-shadow: inset 0 1px 0 hsl(var(--foreground) / .025);
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .1s ease;
  outline: none;
}

.dt-btn:hover {
  border-color: hsl(var(--border) / .8);
  background: hsl(var(--secondary));
}

.dt-btn:active { transform: translateY(1px); }

.dt-btn i { font-size: 1rem; }

.dt-btn--danger {
  background: hsl(var(--destructive) / .15);
  border-color: hsl(var(--destructive) / .35);
  color: hsl(var(--destructive));
}

.dt-btn--danger:hover {
  background: hsl(var(--destructive));
  color: #fff;
}

/* ---------- Card head (título + ações) ---------- */

.dt-card-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 0;
}

@media (min-width: 1280px) {
  .dt-card-head {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.25rem 1.25rem 0;
  }
}

.dt-card-head__actions {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: .5rem;
}

@media (min-width: 640px) {
  .dt-card-head__actions {
    display: flex;
    flex-wrap: wrap;
  }
  .dt-card-head__actions > * { width: auto; }
}

@media (min-width: 1280px) {
  .dt-card-head__actions {
    width: auto;
    flex: 1 1 0%;
    justify-content: flex-end;
  }
}

/* ---------- Sidebar / header (compat com markup antigo) ---------- */

.sidebar {
  z-index: 999;
  width: 264px;
  height: 100vh;
  padding: 1.25rem 1rem;
  background: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--sidebar-border) / .7);
  transition: margin-left .3s ease, transform .3s ease;
}

.sidebar-header {
  margin-bottom: .75rem;
  gap: .75rem;
}

.sidebar-header a { color: hsl(var(--sidebar-foreground)); }

.sidebar-header button {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid hsl(var(--sidebar-border) / .6);
  border-radius: .75rem;
  background: transparent;
  color: hsl(var(--sidebar-foreground));
}

.dt-brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  display: grid;
  place-content: center;
  border-radius: .75rem;
  background: hsl(var(--primary) / .2);
  color: hsl(var(--primary));
  font-size: .875rem;
  font-weight: 700;
}

.dt-brand-text p { margin: 0; }

.dt-nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  border-radius: .75rem;
  padding: .5rem .75rem;
  font-size: .875rem;
  font-weight: 500;
  color: hsl(var(--sidebar-foreground) / .62);
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.dt-nav-item i { font-size: 1.05rem; width: 1.25rem; text-align: center; }

.dt-nav-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.dt-nav-item.active {
  background: hsl(var(--primary) / .2);
  color: hsl(var(--foreground));
}

.dt-sidebar-sep {
  height: 1px;
  width: 100%;
  margin: .75rem 0;
  background: hsl(var(--sidebar-border));
}

.header {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  background: hsl(var(--background) / .8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid hsl(var(--border) / .6);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
}

.header-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: hsl(var(--secondary) / .7);
  color: hsl(var(--foreground));
  transition: background-color .15s ease;
}

.header-icon-btn:hover { background: hsl(var(--secondary)); }

.header-user {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: hsl(var(--secondary) / .7);
  color: hsl(var(--foreground));
  transition: background-color .15s ease;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.header-user:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.header-user img { border-radius: 999px; }

@media (min-width: 768px) {
  .header-user { width: auto; gap: .5rem; padding-right: .5rem; }
  .header-user .text-hidden { display: block; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 500; }
}

@media (max-width: 767px) {
  .header-user .text-hidden { display: none; }
}

/* ---------- Mobile sidebar ---------- */

@media (max-width: 991px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    min-height: 100vh;
    width: 264px;
    box-shadow: none;
  }

  .sidebar.active { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, .6); }
}

/* ---------- Paginação ---------- */

#pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  flex-wrap: wrap;
}

#pagination .btn {
  border-radius: .75rem;
}

/* ---------- Checkbox moderno (painel novo) ---------- */

.dt-check {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: .375rem;
  border: 1px solid hsl(var(--border) / .7);
  background-color: hsl(var(--input) / .75);
  background-image: none;
  cursor: pointer;
  outline: none;
  transition: all .2s ease;
  box-shadow: inset 0 0 0 1px hsl(var(--background) / .25), 0 2px 6px rgba(0, 0, 0, .18);
  flex-shrink: 0;
  margin: 0;
  vertical-align: middle;
}

.dt-check:hover {
  border-color: hsl(var(--primary) / .5);
  background-color: hsl(var(--input));
}

.dt-check:checked {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / .28);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 78%;
  background-position: center;
  background-repeat: no-repeat;
}

.dt-check:focus-visible {
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--primary) / .55);
}

/* ---------- Switch moderno (painel novo) ---------- */

.dt-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background-color: hsl(var(--secondary));
  border: 1px solid hsl(var(--border) / .9);
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background-color .2s ease-in-out, border-color .2s ease-in-out;
  margin: 0;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  vertical-align: middle;
}

.dt-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: .875rem;
  height: .875rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .2s ease-in-out;
}

.dt-switch:checked {
  background-color: var(--dt-green);
  border-color: hsl(var(--dt-green) / .9);
}

.dt-switch:checked::after { transform: translateX(1rem); }

.dt-switch:focus-visible {
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--primary) / .4);
}

/* ---------- Temas da comunidade ---------- */

.theme-card { border-radius: 1rem; overflow: hidden; }

.theme-card-preview {
  width: 100%;
  height: 260px;
  object-fit: cover;
  background-color: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border) / .5);
}

.theme-card-preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: linear-gradient(135deg, hsl(var(--muted)), hsl(var(--accent)));
  color: hsl(var(--muted-foreground));
}

@keyframes dt-reel-up {
  0% { transform: translateY(24px) scale(0.96); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.animate-reel-up { animation: dt-reel-up .45s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ---------- App cards (painel novo) ---------- */

.app-actions .background-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: .75rem;
  border: 1px solid hsl(var(--border) / .6);
  background: hsl(var(--muted) / .25);
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all .15s ease;
  flex-shrink: 0;
}

.app-actions .background-svg:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border) / .85);
}

.app-actions .background-svg:active { transform: scale(0.95); }

.app-actions .background-svg svg { width: .875rem; height: .875rem; fill: hsl(var(--muted-foreground)); }

.app-phone-zone .shadow { box-shadow: none !important; }

/* ---------- Not found ---------- */

.config-not-found,
.user-not-found {
  color: hsl(var(--muted-foreground));
}

main.px-4 {
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

@media (min-width: 640px) {
  main.px-4 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }
}

@media (min-width: 1024px) {
  main.px-4 {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }
}

.content {
  background-color: transparent !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
p,
h1,
h2,
h3,
h4,
h5,
h6,
ul,
ol,
dl,
dd,
blockquote,
figure,
pre {
  margin: 0 !important;
}

/* ---------- Seletor de idioma (i18n) ---------- */
.header-lang {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-lang-menu {
  position: absolute;
  top: calc(100% + .45rem);
  right: 0;
  min-width: 13rem;
  padding: .35rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border) / .85);
  border-radius: .85rem;
  box-shadow: 0 22px 50px -24px rgba(0, 0, 0, .8);
  z-index: 1000;
}

.header-lang-menu[hidden] { display: none; }

.header .header-lang-menu .header-lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  width: 100%;
  margin: 0;
  padding: .5rem .7rem;
  border: 0;
  border-radius: .55rem;
  background: transparent;
  color: inherit;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease;
}

.header .header-lang-menu .header-lang-item:hover { background: hsl(var(--accent)); }

.header .header-lang-menu .header-lang-item i {
  font-size: 1rem;
  margin: 0;
}

.header .header-lang-menu .header-lang-check {
  color: hsl(var(--primary));
  opacity: 0;
  transition: opacity .12s ease;
}

.header .header-lang-menu .header-lang-item.is-active { font-weight: 600; }
.header .header-lang-menu .header-lang-item.is-active .header-lang-check { opacity: 1; }
