/* =========================================================
   TOOL KIT — WIDGET AUTONOMO
   Pacco regalo fluttuante con tutti i tool disponibili,
   sempre sbloccati per tutti.

   COLORI: eredita le variabili reali del sito (sia lo schema
   chiaro di style.css sia lo schema scuro di css/variables.css),
   con fallback in cascata — nessun colore inventato a caso.
   ========================================================= */

.tk-fab,
.tk-panel,
.tk-panel * {
  box-sizing: border-box;
  font-family: var(--font, "Plus Jakarta Sans", Inter, system-ui, sans-serif);
}

:root, .tk-fab, .tk-overlay {
  --tk-gold: var(--gold, #d4af37);
  --tk-gold-light: var(--gold-light, var(--gold-soft, #f3d77a));
  --tk-gold-dark: var(--gold-dark, #8f6f1e);
  --tk-panel-bg: var(--bg-main, var(--dark, #0b0b0b));
  --tk-panel-bg-soft: var(--bg-card, var(--bg-soft, #141414));
  --tk-text: var(--text-main, #f7f3e8);
  --tk-text-soft: var(--text-soft, rgba(247, 243, 232, .62));
  --tk-border: var(--border, rgba(255, 255, 255, .1));
  --tk-radius: var(--radius-md, var(--radius, 22px));
}
.tk-fab {
  position: fixed;
  left: 25px;
  bottom: 25px;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--tk-gold-light), var(--tk-gold) 55%, var(--tk-gold-dark));
  box-shadow: 0 10px 26px rgba(0, 0, 0, .22);
  animation: tk-float 3.2s ease-in-out infinite;
  transition: transform .25s ease, box-shadow .25s ease;
}

.tk-fab:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .26);
}

.tk-fab svg {
  width: 30px;
  height: 30px;
  color: var(--tk-panel-bg);
}

.tk-fab-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  pointer-events: none;
}

.tk-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--tk-panel-bg);
  color: var(--tk-gold-light);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, .5);
  white-space: nowrap;
}

@keyframes tk-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(-4deg); }
}

/* OVERLAY + PANEL */

.tk-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(4, 4, 4, .72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.tk-overlay.tk-open {
  opacity: 1;
  pointer-events: auto;
}

.tk-panel {
  width: min(980px, 100%);
  max-height: min(88vh, 860px);
  background: var(--tk-panel-bg);
  color: var(--tk-text);
  border: 1px solid rgba(212, 175, 55, .25);
  border-radius: 28px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(24px) scale(.98);
  transition: transform .3s ease;
}

.tk-overlay.tk-open .tk-panel {
  transform: translateY(0) scale(1);
}

.tk-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(212, 175, 55, .08), transparent);
  flex-shrink: 0;
}

.tk-panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tk-panel-title h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--tk-text);
}

.tk-panel-title span {
  font-size: 12px;
  color: rgba(247, 243, 232, .55);
  font-weight: 600;
}

.tk-back {
  display: none;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--tk-gold-light);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 0;
}

.tk-back.tk-show { display: inline-flex; }

.tk-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .04);
  color: var(--tk-text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease;
}

.tk-close:hover { background: rgba(255, 255, 255, .1); }

.tk-panel-body {
  padding: 22px 26px 28px;
  overflow-y: auto;
}

/* GRID DEI TOOL */

.tk-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 720px) {
  .tk-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .tk-grid { grid-template-columns: 1fr; }
}

.tk-card {
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}

.tk-card:hover {
  border-color: rgba(212, 175, 55, .45);
  background: rgba(212, 175, 55, .05);
  transform: translateY(-2px);
}

.tk-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--tk-gold-light), var(--tk-gold) 55%, var(--tk-gold-dark));
  color: var(--tk-panel-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tk-icon-badge svg {
  width: 22px;
  height: 22px;
}

.tk-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--tk-text);
}

.tk-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(247, 243, 232, .58);
}

.tk-card-open {
  margin-top: auto;
  font-size: 12px;
  font-weight: 800;
  color: var(--tk-gold-light);
  letter-spacing: .02em;
}

/* VISTA SINGOLO TOOL */

.tk-tool label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: rgba(247, 243, 232, .65);
  margin: 14px 0 6px;
}

.tk-tool label:first-child { margin-top: 0; }

.tk-tool input[type="text"],
.tk-tool input[type="number"],
.tk-tool input[type="tel"],
.tk-tool select,
.tk-tool textarea {
  width: 100%;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  color: var(--tk-text);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s ease;
}

.tk-tool input:focus,
.tk-tool select:focus,
.tk-tool textarea:focus {
  border-color: rgba(212, 175, 55, .55);
}

.tk-tool textarea { resize: vertical; min-height: 100px; }

.tk-tool option {
  color: #111827;
  background: #ffffff;
}

.tk-row { display: grid; gap: 12px; }

@media (min-width: 560px) {
  .tk-row-2 { grid-template-columns: 1fr 1fr; }
  .tk-row-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.tk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 13.5px;
  background: linear-gradient(135deg, var(--tk-gold-light), var(--tk-gold));
  color: var(--tk-panel-bg);
  transition: transform .15s ease, opacity .15s ease;
}

.tk-btn:hover { transform: translateY(-1px); }
.tk-btn:active { transform: translateY(0); }
.tk-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.tk-btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .16);
  color: var(--tk-text);
}

.tk-out {
  margin-top: 14px;
  background: rgba(255, 255, 255, .03);
  border: 1px dashed rgba(212, 175, 55, .3);
  border-radius: 14px;
  padding: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(247, 243, 232, .85);
  white-space: pre-wrap;
  word-break: break-word;
}

.tk-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: rgba(247, 243, 232, .45);
  line-height: 1.5;
}

.tk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 560px) {
  .tk-stats { grid-template-columns: repeat(2, 1fr); }
}

.tk-stat {
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.tk-stat b {
  display: block;
  font-size: 20px;
  color: var(--tk-gold-light);
}

.tk-stat span {
  font-size: 10.5px;
  color: rgba(247, 243, 232, .5);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tk-canvas-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  padding: 16px;
}

.tk-canvas-wrap canvas,
.tk-canvas-wrap img { max-width: 100%; border-radius: 8px; }

.tk-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.tk-chip {
  background: rgba(212, 175, 55, .12);
  border: 1px solid rgba(212, 175, 55, .3);
  color: var(--tk-gold-light);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tk-fancy-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.tk-fancy-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 10px 14px;
}

.tk-fancy-item span { font-size: 15px; word-break: break-word; }

.tk-fancy-item button {
  flex-shrink: 0;
  background: rgba(212, 175, 55, .15);
  border: 1px solid rgba(212, 175, 55, .35);
  color: var(--tk-gold-light);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}

.tk-copied { color: #7ee787 !important; }

/* =========================================================
   AVVISO NUOVI VISITATORI
   ========================================================= */

.tk-hint {
  position: fixed;
  left: 22px;
  bottom: 102px;
  z-index: 999997;
  width: 250px;
  background: var(--tk-panel-bg);
  color: var(--tk-text);
  border: 1px solid rgba(212, 175, 55, .35);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(.96);
  transition: opacity .3s ease, transform .3s ease;
  font-family: var(--font, "Plus Jakarta Sans", Inter, system-ui, sans-serif);
}

.tk-hint.tk-hint-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tk-hint::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--tk-panel-bg);
  border-right: 1px solid rgba(212, 175, 55, .35);
  border-bottom: 1px solid rgba(212, 175, 55, .35);
  transform: rotate(45deg);
}

.tk-hint-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: rgba(247, 243, 232, .5);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.tk-hint-close:hover { color: var(--tk-text); }

.tk-hint p {
  margin: 0;
  padding-right: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--tk-text);
}

.tk-hint-key {
  display: block;
  margin-top: 8px;
  font-size: 11.5px;
  color: rgba(247, 243, 232, .5);
}

@media (max-width: 640px) {
  .tk-hint-key { display: none; }
}

.tk-hint-key kbd {
  display: inline-block;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
  color: var(--tk-gold-light);
}
