@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

/* 2) Assegna Poppins come font predefinito */
body,
input,
textarea,
button,
select {
  font-family: 'Poppins', sans-serif !important;
}

main {
  margin-top: 3rem !important;
}

main.guest-shortener-page {
  margin-top: 7rem !important;
}

/* 1. VARIABILI E STILI BASE */
:root {
  --text-main:      #FFFFFF;
  --text-secondary: #E0E0FF;
  --brand:          #FF5722; /* Arancione principale */
  --brand-hover:    #E05A00;
  --bg-gradient: linear-gradient(135deg, #1A004C 0%, #4B00FF 50%, #00A6FF 100%);
  --table-header:   rgba(75, 50, 255, 0.4);
  --table-bg:       rgba(60, 40, 210, 0.3);
  --table-bg-alt:   rgba(70, 55, 230, 0.35);
  --table-hover:    rgba(80, 65, 240, 0.45);
  --input-bg:       rgba(70, 40, 200, 0.35);
  --icon-color:     #FFFFFF;
  --icon-edit:      #64B5F6;
  --icon-stats:     #81C784;
  --icon-delete:    #E57373;
  --btn-primary:    #FF6B00;
  --btn-secondary:  rgba(75, 50, 255, 0.8);
}

* {
  outline-color: var(--brand) !important;
}

body {
  position: relative;
  min-height: 100vh;
  color: var(--text-main);
}
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  z-index: -1;
}

/* 2. LABEL E FORM ELEMENTS BASE */
label, .label, form label, div.label, span.label {
  color: var(--text-main) !important;
  text-transform: uppercase;
}

input[type="checkbox"]:checked::after {
  background-color: var(--brand) !important;
}

/* 3. NAVBAR E PULSANTI */
nav a[href*="login"],
nav a.button.primary {
  font-size: 1rem;
  background: var(--brand) !important;
  color: var(--text-main) !important;
  border-radius: 999px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
}

[href*="admin"],
a[href*="admin"],
button.admin-button,
a.button.admin {
  font-size: 1rem;
  background: var(--btn-secondary) !important;
  color: var(--text-main) !important;
  border-radius: 999px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
}

a.settings-button,
button.settings-button,
a.button.settings {
  background: var(--brand) !important;
  color: var(--text-main) !important;
  border-radius: 999px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
}

nav a[href*="login"]:hover,
nav a.button.primary:hover {
  background: var(--brand-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

button.primary.login.full {
  background: var(--brand) !important;
  color: var(--text-main) !important;
  border-radius: 999px !important;
  transition: all 0.2s ease !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  font-size: 1rem;
}

button.primary.login.full:hover {
  background: var(--brand-hover) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important;
}

/* 4. TABELLE */
#main-table-wrapper table tbody td.right-fade::after,
#main-table-wrapper table tbody tr:hover td.right-fade::after {
background: none;
}

.chakra-table,
table,
#main-table-wrapper table,
div[role="table"],
.table-container table {
  border-radius: 12px !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25) !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.chakra-table thead,
table thead,
div[role="rowgroup"]:first-child,
.table-header {
  background: var(--table-header) !important;
}

.chakra-table th,
table th,
div[role="columnheader"],
.table-header-cell {
  color: var(--text-main) !important;
  font-weight: 600 !important;
  background: transparent !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

.chakra-table tbody,
table tbody,
div[role="rowgroup"]:not(:first-child) {
  background: transparent !important;
}

.chakra-table tbody tr,
table tbody tr,
div[role="row"]:not([aria-rowindex="1"]) {
  background: var(--table-bg) !important;
  transition: all 0.2s ease !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px) !important;
}

.chakra-table tbody tr:nth-child(odd),
table tbody tr:nth-child(odd),
div[role="row"]:not([aria-rowindex="1"]):nth-child(odd) {
  background: var(--table-bg-alt) !important;
}

.chakra-table tbody tr:hover,
table tbody tr:hover,
div[role="row"]:hover {
  background: var(--table-hover) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.chakra-table td,
table td,
div[role="cell"] {
  color: var(--text-main) !important;
  font-weight: 400 !important;
  background: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.chakra-table td a:not(.button):not([role="button"]),
table td a:not(.button):not([role="button"]) {
  color: #FFB74D !important;
  font-weight: 500;
  transition: all 0.15s ease;
  text-decoration: none;
}

.chakra-table td a:hover,
table td a:hover {
  color: #FFC107 !important;
  text-decoration: underline;
}

button.stats-button,
button.edit-button,
.action-button {
  background: rgba(75, 50, 255, 0.3) !important;
  color: var(--text-main) !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

button.stats-button:hover,
button.edit-button:hover,
.action-button:hover {
  background: rgba(75, 50, 255, 0.5) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.chakra-table button svg,
table button svg,
.action-button svg {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)) !important;
  transition: all 0.2s ease !important;
}

button:hover svg {
  transform: scale(1.15) !important;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)) !important;
}

button.edit-button svg,
button[aria-label*="edit"] svg {
  fill: var(--icon-edit) !important;
  stroke: var(--icon-edit) !important;
}

button.stats-button svg,
button[aria-label*="stats"] svg {
  fill: var(--icon-stats) !important;
  stroke: var(--icon-stats) !important;
}

button.delete-button svg,
button[aria-label*="delete"] svg,
button[aria-label*="elimina"] svg {
  fill: var(--icon-delete) !important;
  stroke: var(--icon-delete) !important;
}

/* 5. FORM E INPUT */
input:not(.shorten-input):not([name="target"]),
select,
textarea {
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-1px) !important;
}

.pagination button,
button[aria-label*="pagina"],
.page-button {
  background: rgba(75, 50, 255, 0.3) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.pagination button:hover,
button[aria-label*="pagina"]:hover,
.page-button:hover {
  background: rgba(75, 50, 255, 0.5) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.chakra-table, table, div[role="table"], #main-table-wrapper > *,
.table-container, .table-wrapper, .table, .data-table {
  background-color: transparent !important;
}

[style*="background-color"], [style*="background:#"], [style*="background: #"] {
  background-color: transparent !important;
}

tbody, tr, td, th, thead, tfoot,
div[role="rowgroup"], div[role="row"], div[role="cell"], div[role="columnheader"] {
  background-color: inherit !important;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

button:active, a:active {
  transform: scale(0.97) !important;
}

/* 6. SHORTENER FORM */
#shortener-form .target-wrapper{
  display:flex !important;
  align-items:center !important;
}

#shortener-form input#target{
  flex:1 1 auto !important;
  padding:0 1.25rem !important;
  border-radius:48px 0 0 48px !important;
}

#shortener-form button.submit{
  position:static !important;
  inset:auto !important;
  flex:0 0 72px !important;
  width:72px !important;
  height:72px !important;
  margin:0 !important;
  padding:0 !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  background:var(--btn-primary) !important;
  color:#fff !important;
  border-radius:0 48px 48px 0 !important;
  box-shadow:0 4px 12px rgba(0,0,0,.25) !important;
  transition:.2s ease;
}

#shortener-form button.submit:hover{
  background:var(--brand-hover) !important;
  transform:translateY(-2px);
}

#shortener-form button.submit svg{
  width:1.4rem !important;
  height:auto !important;
  stroke-width:2;
}

main form#shortener-form{
  display:flex !important;
  flex-direction:column !important;
  gap:24px !important;
  padding:32px !important;
  padding-top:60px !important;
  border-radius:20px !important;
  background:rgba(123,123,123,.06) !important;
  /*backdrop-filter:blur(10px) !important;*/
  backdrop-filter: blur(5px) saturate(100%) brightness(80%);
}

#shortener-form .target-wrapper{
  display:flex !important;
  align-items:center !important;
  padding:0 !important;
  background:none !important;
  border:none !important;
}

#shortener-form input#target{
  flex:1 1 auto !important;
  height:51px !important;
  padding:0 24px !important;
  font-size:1rem !important;
  font-weight:700 !important;
  color:#222 !important;
  background:#ffffff !important;
  border:none !important;
  border-radius:12px 0 0 12px !important;
}

#shortener-form input#target::placeholder{
  color:#7c8ba1 !important;
  font-weight:700 !important;
}

#shortener-form button.submit{
  flex:0 0 auto !important;
  height:51px !important;
  padding:0 7px !important;
  min-width:140px !important;
  border:none !important;
  border-radius:0 12px 12px 0 !important;
  background:var(--brand) !important;
  font-size:1rem !important;
  font-weight:700 !important;
  text-transform:uppercase !important;
  color:#fff !important;
  box-shadow:0 6px 15px rgba(0,0,0,.25) !important;
  transition:transform .2s, box-shadow .2s, background .2s !important;
}

#shortener-form button.submit svg{display:none !important;}
#shortener-form button.submit::after{content:"Shorten";}

#shortener-form button.submit:hover,
#shortener-form button.submit:focus{
  background:#e05a00 !important;
  transform:translateY(-2px) !important;
  box-shadow:0 8px 18px rgba(0,0,0,.30) !important;
}

@media(max-width:600px){
  main form#shortener-form{
  padding:20px !important;
  padding-top:30px !important;
  }

  .shortener-logo-container {
  margin-bottom: -1.67rem !important;
  }

  #shortener-form input#target{height:47px !important;}
  #shortener-form button.submit{height:47px !important; min-width:120px !important;padding:0 20px !important;}
}

#shortener-form .target-wrapper button.submit,
#shortener-form .target-wrapper input#target {
  transition: background-color .2s ease, box-shadow .2s ease;
}

#shortener-form .target-wrapper button.submit:hover,
#shortener-form .target-wrapper button.submit:focus,
#shortener-form .target-wrapper input#target:hover,
#shortener-form .target-wrapper input#target:focus {
  transform: none !important;
}

#shortener-form .target-wrapper,
#shortener-form .target-wrapper:focus-within,
#shortener-form input#target,
#shortener-form input#target:focus,
#shortener-form input#target:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

#shortener-form input#target {
  border: none !important;
}

/* 7. MEDIA QUERIES MOBILE */
@media (max-width: 767.98px) {
  main form#shortener-form{
  padding: 16px !important;
  padding-top: 50px !important;
  }
  #shortener-form .target-wrapper {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.65rem !important;
  }

  #shortener-form .target-wrapper input#target,
  #shortener-form .target-wrapper button.submit {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border-radius: 12px !important;
  }

  label#advanced.toggle-switch {
  margin-top: 0rem !important;
  }
}

/* 8. TOGGLE SWITCH */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch .track {
  position: relative;
  width: 2.5em;
  height: 1.2em;
  background: #ccc;
  border-radius: 1em;
  margin-right: 0.5em;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch .track .handle {
  position: absolute;
  top: 0.1em;
  left: 0.1em;
  width: 1em;
  height: 1em;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .track {
  background: #FF5722;
}

.toggle-switch input:checked + .track .handle {
  transform: translateX(1.3em);
}

.toggle-switch .label-text {
  font-size: 0.9em;
  font-weight: 600;
  color: #fff;
}

.toggle-switch {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5em;
  margin-top: 1.5em;
  margin-left: 0;
}

.toggle-switch .label-text {
  font-size: 0.9em;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

label#advanced.toggle-switch {
  margin-top: -0.7rem;
}

.toggle-switch input:focus + .track {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

/* 9. ERRORI E MESSAGGI */
#shortener-form .target-wrapper {
  position: relative !important;
}

#shortener-form .target-wrapper p.error {
  position: absolute !important;
  top: calc(100% + 2.5rem) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: auto !important;
  margin: 0 !important;
  text-align: center !important;
  color: #DB0000 !important;
  font-weight: 600 !important;
  background: #FFF9F3;
  padding: .5rem .75rem;
  border-radius: .75rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
  transition: opacity .2s ease;
}

@keyframes fadeOutError {
  to {
    opacity: 0;
    visibility: hidden;
    height: 0;
    margin: 0;
    padding: 0;
  }
}

#shortener-form p.error {
  animation: fadeOutError 1s ease-out 3s forwards;
}

#shortener-form:has(#advanced-options.hidden p.error) label#advanced::after {
  content: "◄ Fix errors in link customization";
  right: -0.5em;
  background: #FFF9f3;
  color: #DB0000;
  font-size: 0.75rem;
  padding: 0.0em 0.4em;
  border-radius: 4px;
  white-space: nowrap;
  animation: fadeOutError 1s ease-out 3s forwards;
}

/* 10. LOGO E POSIZIONAMENTO */
.shortener-logo-container {
  position: relative;
  text-align: center;
  z-index: 2;
  margin-bottom: -27px;
}

.shortener-logo {
  width: 266px;
  height: auto;
  display: inline-block;
}

main #shorturl h1.link {
  font-size: 2.5rem;
  cursor: pointer;
  border-bottom-color: var(--brand);
  transition: opacity 0.3s ease-in-out;
  --keyframe-slidey-offset: -10px;
  animation: fadein 0.2s ease-in-out, slidey 0.2s ease-in-out;
}

main #shorturl h1 {
  margin: 0;
  border-bottom: 4px solid transparent;
  border-bottom-color: transparent;
  font-weight: 300;
  font-size: 2rem;
}

main #shorturl h1 span {
  border-bottom: 2px solid #ff6b00;
}

/* 11. QR CODE STYLES */
.mini-qr-container{
  position:relative;
  display:inline-block;
  vertical-align:middle;
  margin-left:1rem;
  padding:.5rem;
  text-align:center;
  background:rgba(255,255,255,.9);
  border-radius:6px;
  box-shadow:0 4px 8px rgba(0,0,0,.08);
}

.mini-qr-container canvas,
.mini-qr-container img{
  width:80px;
  height:80px;
  border:1px solid #eee;
  border-radius:4px;
}

.mini-qr-download{
  position:absolute;
  bottom:-14px; right:-14px;
  width:28px; height:28px;
  border-radius:50%;
  background:#ff5722;
  box-shadow:0 2px 6px rgba(0,0,0,.25);
  cursor:pointer;
  text-indent:-9999px;
  overflow:hidden;
}

.mini-qr-download::before{
  content:"";
  position:absolute; inset:0;
  background:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 16l4-5h-3V4h-2v7H8l4 5zm-6 2v2h12v-2H6z"/></svg>')
    center/16px no-repeat;
}

.mini-qr-download:hover{
  transform:scale(1.12);
  transition:transform .15s ease-out;
}

.dialog.qrcode .content-wrapper{
  position:relative;
  padding:.75rem;
  background:rgba(255,255,255,.92);
  border-radius:8px;
  box-shadow:0 4px 12px rgba(0,0,0,.15);
}

.dialog.qrcode .download-qr-btn{
  position:absolute;
  right:12px; bottom:12px;
  width:32px; height:32px;
  border-radius:50%;
  background:#ff5722;
  box-shadow:0 2px 6px rgba(0,0,0,.25);
  cursor:pointer;
  text-indent:-9999px;
  overflow:hidden;
}

.dialog.qrcode .download-qr-btn::before{
  content:"";
  position:absolute; inset:0;
  background:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 16l4-5h-3V4h-2v7H8l4 5zm-6 2v2h12v-2H6z"/></svg>')
    center/18px no-repeat;
}

.dialog.qrcode .download-qr-btn:hover,
.dialog.qrcode .download-qr-btn:focus{
  transform:scale(1.12);
  transition:transform .15s ease-out;
}

/* 12. HTMX SPINNER */
#shortener-form button.submit svg {
  display: none !important;
}

#shortener-form.htmx-request button.submit svg.spinner {
  display: inline-block !important;
}

#shortener-form button.submit::after {
  content: "Shorten" !important;
}

#shortener-form.htmx-request button.submit::after {
  content: "" !important;
}

#shortener-form button.submit svg.spinner,
#shortener-form button.submit svg.spinner * {
  filter: none !important;
  box-shadow: none !important;
}

#shortener-form button.submit svg.spinner circle,
#shortener-form button.submit svg.spinner path {
  stroke: #fff !important;
  fill:   #fff !important;
  stroke-opacity: 1 !important;
  fill-opacity:   1 !important;
}

#shortener-form button.submit svg.spinner {
  width: 2em !important;
  height: 2em !important;
}

#shortener-form button.submit svg.spinner circle,
#shortener-form button.submit svg.spinner path {
  stroke-width: 2px !important;
}

#shortener-form.htmx-request button.submit {
  pointer-events: none !important;
  cursor: not-allowed !important;
  opacity: 0.9;
}

/* 13. FOOTER STYLES */
footer p {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5em;
  margin: 1em 0;
  font-size: 0.95rem;
  font-weight: bold;
  color: #CCCCCC;
}

footer p span {
  display: none;
}

footer p a:not(:last-child)::after {
  content: "|";
  margin: 0 0.5em;
  color: #CCCCCC;
}

footer p a {
  color: #FFFFFF;
  text-decoration: none;
  flex: 0 1 auto;
  white-space: nowrap;
  transition: color 0.2s ease-in-out;
}

footer p a:hover,
footer p a:focus {
  color: #FF5A00;
  text-decoration: underline;
}

@media (max-width: 480px) {
  footer p {
    gap: 0.3em;
    font-size: 0.8rem;
  }
  footer p a:not(:last-child)::after {
    margin: 0 0.3em;
  }
}

/* 14. COPY BUTTON */
.clipboard button {
  background-color: rgba(255, 255, 255, 0.15) !important;
  color: var(--brand) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.clipboard button:hover {
  background-color: rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15) !important;
}

.clipboard button:hover svg,
.clipboard button:focus svg,
.clipboard button:active svg {
  filter: none !important;
  transform: none !important;
}

.clipboard svg {
  stroke: #00E676 !important;
}

/* 15. VARIE E TEST MODS */
.content {
  color: #787878 !important;
}

.logo-links > li:nth-child(1) > a:nth-child(1) {
  display: none;
}

a.logo {
  displaY: none !important;
}

#domain,
#domain option {
  text-transform: uppercase !important;
}

label.checkbox {
  font-weight: 700;
}

p.error {
  position: absolute;
  color: #DB0000;
  background: #FFFFFF;
  transform: translateY(+50%);
  border-radius: 0.25rem;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

/* 16. MEDIA QUERIES FINALI */
@media (max-width: 480px) {
  main {
    padding-left: 0.3rem;
    padding-right: 0.3rem;
  }
  main form#shortener-form{
    padding-left:7px !important;
    padding-right:7px !important;
  }
  main #shorturl {
    flex-wrap: wrap;
    justify-content: center;
  }
  .shortener-logo-container {
  margin-bottom: -1.67rem !important;
  }
  .mini-qr-container {
    margin-top: 1rem;
  }
}

/* 17. DOMINIO SELECTOR */
#domain {
font-weight: bold;
}

/* 18. USER FORM FIX */
#create-user-form {
  --text-main: #787878;
}
#add-domain-form {
  --text-main: #787878;
}
