/* =============================================================
   WC Promo Checkout — Frontend Styles
   ============================================================= */

/* Variabili di default (sostituite da PHP inline style) */
:root {
  --wcpc-accent:        #2c6e49;
  --wcpc-accent-dark:   #1e4d33;
  --wcpc-radius:        8px;
  --wcpc-transition:    0.25s ease;
  --wcpc-border:        #e0e0e0;
  --wcpc-bg:            #f9f9f9;
  --wcpc-text:          #333;
  --wcpc-text-muted:    #666;
  --wcpc-success-bg:    #eaf7ee;
  --wcpc-success-text:  #1e6637;
  --wcpc-error-bg:      #fdecea;
  --wcpc-error-text:    #b91c1c;
  --wcpc-tag-bg:        #edf7f1;
  --wcpc-tag-border:    #a7d9bb;
  --wcpc-shadow:        0 2px 12px rgba(0,0,0,.06);
}

/* ---- Wrapper principale ------------------------------------ */
.wcpc-wrap {
  margin: 16px 0;
  padding: 18px 20px;
  background: var(--wcpc-bg);
  border: 1px solid var(--wcpc-border);
  border-radius: var(--wcpc-radius);
  box-shadow: var(--wcpc-shadow);
  font-family: inherit;
  box-sizing: border-box;
}

/* Animazione fade-in al caricamento */
.wcpc--animated {
  animation: wcpcFadeIn 0.4s ease both;
}
@keyframes wcpcFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ---- Header ----------------------------------------------- */
.wcpc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.wcpc-icon {
  display: inline-flex;
  align-items: center;
  color: var(--wcpc-accent);
  flex-shrink: 0;
}

.wcpc-icon svg {
  width: 18px;
  height: 18px;
}

.wcpc-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--wcpc-text);
  letter-spacing: 0.01em;
}

/* ---- Coupon applicati (tags) ------------------------------ */
.wcpc-applied-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.wcpc-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 12px;
  background: var(--wcpc-tag-bg);
  border: 1px solid var(--wcpc-tag-border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--wcpc-success-text);
  animation: wcpcTagIn 0.3s ease both;
}

@keyframes wcpcTagIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1);    }
}

.wcpc-tag--removing {
  animation: wcpcTagOut 0.25s ease forwards;
}

@keyframes wcpcTagOut {
  to { opacity: 0; transform: scale(0.75); }
}

.wcpc-tag-code {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.wcpc-tag-discount {
  font-size: 0.78rem;
  opacity: 0.85;
}

.wcpc-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--wcpc-success-text);
  opacity: 0.6;
  padding: 0;
  border-radius: 50%;
  transition: opacity var(--wcpc-transition), background var(--wcpc-transition);
}

.wcpc-tag-remove:hover {
  opacity: 1;
  background: rgba(0,0,0,.08);
}

.wcpc-tag-remove svg {
  width: 12px;
  height: 12px;
}

/* ---- Riga input + pulsante -------------------------------- */
.wcpc-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.wcpc-input-wrap {
  position: relative;
  flex: 1;
}

.wcpc-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--wcpc-text);
  background: #fff;
  border: 1px solid var(--wcpc-border);
  border-radius: var(--wcpc-radius);
  outline: none;
  transition: border-color var(--wcpc-transition), box-shadow var(--wcpc-transition);
  box-sizing: border-box;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wcpc-input::placeholder {
  text-transform: none;
  letter-spacing: 0;
  color: #aaa;
}

.wcpc-input:focus {
  border-color: var(--wcpc-accent);
  box-shadow: 0 0 0 3px rgba(44,110,73,.15);
}

/* Linea decorativa sotto l'input (animata al focus) */
.wcpc-input-line {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--wcpc-accent);
  border-radius: 0 0 2px 2px;
  transition: width var(--wcpc-transition), left var(--wcpc-transition);
}

.wcpc-input:focus + .wcpc-input-line {
  width: 100%;
  left: 0;
}

/* ---- Pulsante applica ------------------------------------- */
.wcpc-btn {
  position: relative;
  flex-shrink: 0;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: none;
  border-radius: var(--wcpc-radius);
  cursor: pointer;
  transition: background var(--wcpc-transition), transform 0.1s, box-shadow var(--wcpc-transition);
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 90px;
}

.wcpc-btn--apply {
  background: var(--wcpc-accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(44,110,73,.3);
}

.wcpc-btn--apply:hover {
  background: var(--wcpc-accent-dark);
  box-shadow: 0 4px 10px rgba(44,110,73,.35);
  transform: translateY(-1px);
}

.wcpc-btn--apply:active {
  transform: translateY(0);
  box-shadow: none;
}

.wcpc-btn:focus-visible {
  outline: 2px solid var(--wcpc-accent);
  outline-offset: 2px;
}

/* Stato loading */
.wcpc-btn--loading .wcpc-btn-text {
  opacity: 0.3;
}

.wcpc-btn--loading .wcpc-btn-spinner {
  display: inline-block;
}

.wcpc-btn-spinner {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wcpcSpin 0.7s linear infinite;
}

@keyframes wcpcSpin {
  to { transform: rotate(360deg); }
}

/* ---- Feedback messages ------------------------------------ */
.wcpc-feedback {
  margin-top: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: calc(var(--wcpc-radius) - 2px);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.wcpc-feedback.wcpc-feedback--visible {
  max-height: 80px;
  padding: 9px 14px;
  opacity: 1;
}

.wcpc-feedback--success {
  background: var(--wcpc-success-bg);
  color: var(--wcpc-success-text);
}

.wcpc-feedback--error {
  background: var(--wcpc-error-bg);
  color: var(--wcpc-error-text);
}

.wcpc-feedback--info {
  background: #eef4ff;
  color: #1e40af;
}

/* ---- Riga coupon dentro la tabella ordine WooCommerce ------ */
tr#wcpc-coupon-tr {
    background: transparent !important;
}

tr#wcpc-coupon-tr td.wcpc-coupon-td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

tr#wcpc-coupon-tr .wcpc-wrap {
    margin: 8px 0 12px;
}


@media ( max-width: 480px ) {
  .wcpc-input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .wcpc-btn {
    width: 100%;
  }
}
