/*
======================= START OF LICENSE NOTICE =======================
Copyright (C) 2026 Alessandro Battistini. All Rights Reserved
NO WARRANTY. THE PRODUCT IS PROVIDED BY DEVELOPER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DEVELOPER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE PRODUCT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
======================== END OF LICENSE NOTICE ========================
This file is an integral part of the framework AB_WEBMAP, please do not edit, use, modify or change without permission of the developer
*/
/* ==========================================================================
   ab_button.css
   Usage:
     <button class="ab-button">Default</button>
     <button class="ab-button ab-button-fill">Fill</button>
     <button class="ab-button ab-button-outline">Outline</button>
     <button class="ab-button ab-button-tonal">Tonal</button>
     <button class="ab-button ab-button-round ab-button-large">Round large</button>
     <button class="ab-button ab-button-fill ab-color-green">Green</button>
   ========================================================================== */

/* ---- Theme tokens -------------------------------------------------------- */
/* Puoi sovrascrivere queste variabili in :root, oppure dentro un wrapper
   (.theme-dark, .theme-cofi, ecc.) */
:root {
  /* Sizing */
  --ab-button-width: 44px;
  --ab-button-height: 34px;
  --ab-button-padding-x: 0px;
  --ab-button-padding-y: 0px;
  --ab-button-margin-x: 0px
  --ab-button-margin-y: 0px;
  --ab-button-font-size: 14px;
  --ab-button-font-weight: 600;
  --ab-button-radius: 12px; /* default "soft" */
  --ab-button-border-width: var(--ab-standard-border-width, 1px);

  /* Colors */
  --ab-button-color: var(--ab-bg-color-control);
  --ab-button-text: var(--ab-font-color-control);
  --ab-button-bg: var(--ab-bg-color-control);
  --ab-button-border-color: var(--ab-standard-border-color);

  /* Filled */
  --ab-button-fill-bg: var(--ab-button-color);
  --ab-button-fill-text: var(--ab-button-text);

  /* Tonal */
  --ab-button-tonal-bg: color-mix(in srgb, currentColor 16%, transparent);

  /* Feedback / states */
  --ab-button-hover-bg: color-mix(in srgb, currentColor 10%, transparent);
  --ab-button-pressed-overlay: rgba(0, 0, 0, 0.08);
  --ab-button-focus-ring: color-mix(in srgb, currentColor 25%, transparent);
  --ab-button-disabled-opacity: 0.35;

  /* Motion */
  --ab-button-transition: 150ms;
}

/* Fallback se color-mix non è supportato */
@supports not (background: color-mix(in srgb, #000 10%, transparent)) {
  :root {
    --ab-button-tonal-bg: rgba(0, 122, 255, 0.16);
    --ab-button-hover-bg: rgba(0, 122, 255, 0.1);
    --ab-button-focus-ring: rgba(0, 122, 255, 0.25);
  }
}

/* ---- Base button --------------------------------------------------------- */
.ab-button {
  -webkit-appearance: none;
  appearance: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  height: var(--ab-button-height);
  width: var(--ab-button-width);
  padding: 0 var(--ab-button-padding-x);

  border-radius: var(--ab-button-radius);
  border: var(--ab-button-border-width) solid var(--ab-button-border-color);

  background: var(--ab-button-bg);
  color: var(--ab-button-text);

  font-size: var(--ab-button-font-size);
  font-weight: var(--ab-button-font-weight);
  line-height: 1;

  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;

  position: relative;

  border-width: var(--ab-button-border-width);

  padding-left: var(--ab-button-padding-x);
  padding-right: var(--ab-button-padding-x);
  padding-top: var(--ab-button-padding-y);
  padding-bottom: var(--ab-button-padding-y);
  margin-left: var(--ab-button-margin-x);
  margin-right: var(--ab-button-margin-x);
  margin-top: var(--ab-button-margin-y);
  margin-bottom: var(--ab-button-margin-y); 

  transition:
    background-color var(--ab-button-transition) ease,
    color var(--ab-button-transition) ease,
    border-color var(--ab-button-transition) ease,
    box-shadow var(--ab-button-transition) ease,
    opacity var(--ab-button-transition) ease,
    transform var(--ab-button-transition) ease;
}

/* Hover (desktop) */
.ab-button.ab-link:hover {
  /* background: var(--ab-button-hover-bg); */
  box-shadow: inset 0 0 0 2px var(--ab-font-color-control);
}

/* Pressed */
.ab-button:active {
  /* transform: translateY(0.5px); */
  transform: scale(0.97);
}


/* Overlay pressed (mobile-like) */
.ab-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  pointer-events: none;
  transition: background-color var(--ab-button-transition) ease;
}
.ab-button:active::after {
  background: var(--ab-button-pressed-overlay);
}

/* Focus */
.ab-button:focus {
  outline: none;
}
.ab-button:focus-visible {
  box-shadow: 0 0 0 3px var(--ab-button-focus-ring);
}

/* Disabled */
.ab-button:disabled,
.ab-button.ab-disabled {
  opacity: var(--ab-button-disabled-opacity);
  pointer-events: none;
  cursor: default;
}

/* Active (stato selezionato) */
.ab-button.ab-active {
  background: var(--ab-button-hover-bg);
}

/* ---- Varianti visuali ---------------------------------------------------- */

/* Outline (default già simile, ma utile come modificatore esplicito) */
.ab-button.ab-button-outline {
  background: transparent;
  border-color: currentColor;
  color: currentColor;
}

/* Fill */
.ab-button.ab-button-fill {
  background: var(--ab-button-fill-bg);
  border-color: var(--ab-button-fill-bg);
  color: var(--ab-button-fill-text);
}
.ab-button.ab-button-fill:hover {
  /* leggermente più scuro, se color-mix c’è */
  background: color-mix(in srgb, var(--ab-button-fill-bg) 92%, #000);
}
@supports not (background: color-mix(in srgb, #000 10%, transparent)) {
  .ab-button.ab-button-fill:hover {
    filter: brightness(0.96);
  }
}

/* Tonal */
.ab-button.ab-button-tonal {
  background: var(--ab-button-tonal-bg);
  border-color: transparent;
  color: currentColor;
}
.ab-button.ab-button-tonal:hover {
  background: color-mix(in srgb, currentColor 22%, transparent);
}
@supports not (background: color-mix(in srgb, #000 10%, transparent)) {
  .ab-button.ab-button-tonal:hover {
    filter: brightness(0.98);
  }
}

/* Raised (ombra leggera) */
.ab-button.ab-button-raised {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.ab-button.ab-button-raised:active {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ---- Dimensioni ---------------------------------------------------------- */

.ab-button.ab-button-small {
  --ab-button-height: 32px;
  --ab-button-padding-x: 12px;
  --ab-button-font-size: 13px;
  --ab-button-radius: 10px;
}

.ab-button.ab-button-large {
  --ab-button-height: 48px;
  --ab-button-padding-x: 20px;
  --ab-button-font-size: 15px;
  --ab-button-radius: 14px;
}

/* ---- Forma / layout ------------------------------------------------------ */

/* Round (pill) */
.ab-button.ab-button-round {
  --ab-button-radius: 999px;
}

/* Square (angoli più netti) */
.ab-button.ab-button-square {
  --ab-button-radius: 8px;
}

/* Block (full width) */
.ab-button.ab-button-block {
  width: 100%;
}

/* Icon only (quadrato) */
.ab-button.ab-button-icon {
  width: var(--ab-button-height);
  padding: 0;
  gap: 0;
}
.ab-button.ab-button-icon > .ab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}



/* ---- Gruppi tipo segmented (opzionale ma utile) ---------------- */
.ab-buttons {
  display: inline-flex;
  align-items: stretch;
}
.ab-buttons > .ab-button {
  border-radius: 0;
}
.ab-buttons > .ab-button:first-child {
  border-top-left-radius: var(--ab-button-radius);
  border-bottom-left-radius: var(--ab-button-radius);
}
.ab-buttons > .ab-button:last-child {
  border-top-right-radius: var(--ab-button-radius);
  border-bottom-right-radius: var(--ab-button-radius);
}
/* evita doppio bordo */
.ab-buttons > .ab-button + .ab-button {
  margin-left: calc(var(--ab-button-border-width) * -1);
}

/* ---- Colori (utility) ---------------------------------------------------- */
/* Le classi colore impostano currentColor (quindi funzionano con outline/tonal),
   e aggiornano anche il fill tramite --ab-button-fill-bg */
.ab-color-blue {
  color: #007aff;
  --ab-button-fill-bg: #007aff;
}
.ab-color-green {
  color: #34c759;
  --ab-button-fill-bg: #34c759;
}
.ab-color-red {
  color: #ff3b30;
  --ab-button-fill-bg: #ff3b30;
}
.ab-color-orange {
  color: #ff9500;
  --ab-button-fill-bg: #ff9500;
}
.ab-color-purple {
  color: #af52de;
  --ab-button-fill-bg: #af52de;
}
.ab-color-teal {
  color: #30b0c7;
  --ab-button-fill-bg: #30b0c7;
}
.ab-color-gray {
  color: #8e8e93;
  --ab-button-fill-bg: #8e8e93;
}

/* Quando uso fill, il testo resta bianco di default (modificabile) */
.ab-button.ab-button-fill.ab-color-gray {
  --ab-button-fill-text: #fff;
}
