/**
 * Urgent Shipping Fee – Front-end styles v4.
 * Colors and font formatting use CSS custom properties set from admin settings.
 */

/* ------------------------------------------------------------------ */
/*  Card                                                               */
/* ------------------------------------------------------------------ */

.usf-urgent-row td {
    padding: 0 !important;
    border: none !important;
}

.usf-urgent-option {
    /* Color defaults – overridden by inline custom properties from admin */
    --usf-border: #e8a838;
    --usf-bg: #fffcf5;
    --usf-border-active: #27ae60;
    --usf-bg-active: #f0faf4;
    --usf-price-color: #27ae60;
    --usf-price-bg: #eafaf1;
    --usf-icon: #e8a838;
    --usf-countdown: #d35400;
    --usf-checkbox: #27ae60;
    --usf-title-active: #27ae60;
    --usf-progress: #e8a838;

    /* Font defaults – overridden by inline custom properties from admin */
    --usf-title-size: 15px;
    --usf-title-weight: 700;
    --usf-title-style: normal;
    --usf-subtitle-size: 13px;
    --usf-subtitle-weight: 400;
    --usf-subtitle-style: normal;
    --usf-price-size: 15px;
    --usf-price-weight: 700;
    --usf-price-style: normal;
    --usf-countdown-size: 11px;
    --usf-countdown-weight: 700;
    --usf-countdown-style: normal;
    --usf-digits-size: 18px;
    --usf-digits-weight: 700;
    --usf-digits-style: normal;
    --usf-microcopy-size: 11px;
    --usf-microcopy-weight: 400;
    --usf-microcopy-style: italic;
    --usf-badge-size: 10px;
    --usf-badge-weight: 700;
    --usf-badge-style: normal;
    --usf-badge-bg: #ff9800;
    --usf-badge-text: #ffffff;
    --usf-badge-bg-active: #4CAF50;
    --usf-badge-text-active: #ffffff;

    position: relative;
    border: 2px solid var(--usf-border);
    border-radius: 12px;
    padding: 18px 20px 14px;
    margin: 20px 0;
    background: var(--usf-bg);
    transition: box-shadow 0.35s ease, border-color 0.35s ease, background 0.35s ease;
    overflow: hidden;
    text-align: center;
}

.usf-urgent-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 0, 0, 0.02) 40%,
        rgba(0, 0, 0, 0.04) 50%,
        rgba(0, 0, 0, 0.02) 60%,
        transparent 100%
    );
    animation: usf-shimmer 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes usf-shimmer {
    0%   { left: -100%; }
    50%  { left: 150%; }
    100% { left: 150%; }
}

.usf-urgent-option:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.usf-urgent-option.usf-active {
    border-color: var(--usf-border-active);
    background: var(--usf-bg-active);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.08), 0 4px 20px rgba(39, 174, 96, 0.08);
}

.usf-urgent-option.usf-active::before {
    animation: none;
    display: none;
}

/* ------------------------------------------------------------------ */
/*  Text swap: show default, hide active (and vice versa)              */
/* ------------------------------------------------------------------ */

.usf-text-active {
    display: none !important;
}

.usf-active .usf-text-default {
    display: none !important;
}

.usf-active .usf-text-active {
    display: inline !important;
}

p.usf-text-active {
    display: none !important;
}

.usf-active p.usf-text-default {
    display: none !important;
}

.usf-active p.usf-text-active {
    display: block !important;
}

/* ------------------------------------------------------------------ */
/*  Progress bar                                                       */
/* ------------------------------------------------------------------ */

.usf-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--usf-progress);
    border-radius: 3px 0 0 0;
    transition: width 1s linear;
}

.usf-active .usf-progress-bar {
    background: var(--usf-border-active);
}

.usf-progress-bar.usf-urgent-soon {
    animation: usf-bar-pulse 1.2s ease-in-out infinite;
}

@keyframes usf-bar-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* ------------------------------------------------------------------ */
/*  Label layout – centered                                            */
/* ------------------------------------------------------------------ */

.usf-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--usf-title-size);
    line-height: 1.4;
    margin: 0;
    -webkit-user-select: none;
    user-select: none;
    text-align: left;
}

.usf-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Custom checkbox */
.usf-checkbox-visual {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: #fff;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.usf-checkbox-visual svg {
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.usf-label input:checked ~ .usf-checkbox-visual {
    background: var(--usf-checkbox);
    border-color: var(--usf-checkbox);
}

.usf-label input:checked ~ .usf-checkbox-visual svg {
    opacity: 1;
    transform: scale(1);
}

.usf-label input:focus-visible ~ .usf-checkbox-visual {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* ------------------------------------------------------------------ */
/*  Label content                                                      */
/* ------------------------------------------------------------------ */

.usf-label-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.usf-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.usf-icon {
    display: inline-flex;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}

.usf-title {
    font-size: var(--usf-title-size);
    font-weight: var(--usf-title-weight);
    font-style: var(--usf-title-style);
    color: #2c3e50;
}

.usf-active .usf-text-active.usf-title {
    color: var(--usf-title-active);
}

.usf-subtitle {
    font-size: var(--usf-subtitle-size);
    font-weight: var(--usf-subtitle-weight);
    font-style: var(--usf-subtitle-style);
    color: #888;
    line-height: 1.45;
}

/* ------------------------------------------------------------------ */
/*  Price + badge group                                                */
/* ------------------------------------------------------------------ */

.usf-price-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.usf-price {
    font-size: var(--usf-price-size);
    font-weight: var(--usf-price-weight);
    font-style: var(--usf-price-style);
    color: var(--usf-price-color);
    white-space: nowrap;
    background: var(--usf-price-bg);
    padding: 5px 12px;
    border-radius: 8px;
    line-height: 1.3;
}

/* ------------------------------------------------------------------ */
/*  Status badge (Recomandat / Aplicat)                                */
/* ------------------------------------------------------------------ */

.usf-badge-label {
    display: inline-block;
    font-size: var(--usf-badge-size, 10px);
    font-weight: var(--usf-badge-weight, 700);
    font-style: var(--usf-badge-style, normal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--usf-badge-text);
    background: var(--usf-badge-bg);
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 1.5;
    min-width: 70px;
    text-align: center;
    transition: background 0.3s ease, color 0.3s ease;
}

.usf-active .usf-badge-label-active {
    background: var(--usf-badge-bg-active);
    color: var(--usf-badge-text-active);
}

/* ------------------------------------------------------------------ */
/*  Countdown – compact, centered                                      */
/* ------------------------------------------------------------------ */

.usf-countdown-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 12px 0 2px;
    padding: 8px 0 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.usf-countdown-label {
    font-size: var(--usf-countdown-size);
    font-weight: var(--usf-countdown-weight);
    font-style: var(--usf-countdown-style);
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.usf-countdown-timer {
    display: flex;
    align-items: center;
    gap: 3px;
}

.usf-countdown-digit-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 28px;
}

.usf-countdown-number {
    font-size: var(--usf-digits-size);
    font-weight: var(--usf-digits-weight);
    font-style: var(--usf-digits-style);
    color: var(--usf-countdown);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    transition: color 0.3s ease;
}

.usf-countdown-unit {
    font-size: 8px;
    font-weight: 700;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 1px;
}

.usf-countdown-sep {
    font-size: 16px;
    font-weight: 300;
    color: #ddd;
    margin: 0 1px;
    align-self: flex-start;
    line-height: 1.2;
}

.usf-countdown-number.usf-flash {
    animation: usf-digit-flash 0.6s ease;
}

@keyframes usf-digit-flash {
    0%   { transform: scale(1.12); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

.usf-countdown-timer.usf-pulse .usf-countdown-number {
    animation: usf-number-pulse 1.2s ease-in-out infinite;
}

@keyframes usf-number-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

.usf-active .usf-countdown-number {
    color: var(--usf-border-active);
}

/* ------------------------------------------------------------------ */
/*  Microcopy                                                          */
/* ------------------------------------------------------------------ */

.usf-microcopy {
    margin: 8px 0 0;
    font-size: var(--usf-microcopy-size);
    font-weight: var(--usf-microcopy-weight);
    font-style: var(--usf-microcopy-style);
    color: #aaa;
    line-height: 1.5;
    text-align: center;
}

.usf-active .usf-microcopy.usf-text-active {
    color: var(--usf-border-active);
}

/* ------------------------------------------------------------------ */
/*  Toast notification                                                 */
/* ------------------------------------------------------------------ */

.usf-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    transform: translateY(20px);
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.usf-toast-add {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.usf-toast-remove {
    background: linear-gradient(135deg, #636e72, #7f8c8d);
}

.usf-toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.usf-toast-icon {
    font-size: 18px;
    line-height: 1;
}

/* ------------------------------------------------------------------ */
/*  Mobile                                                             */
/* ------------------------------------------------------------------ */

@media (max-width: 600px) {
    .usf-urgent-option {
        padding: 14px 12px 12px;
        border-radius: 10px;
        margin: 14px 0;
    }

    .usf-label {
        gap: 8px;
    }

    .usf-checkbox-visual {
        width: 26px;
        height: 26px;
        min-width: 26px;
    }

    .usf-price {
        font-size: 14px;
        padding: 4px 10px;
    }

    .usf-countdown-number {
        font-size: 16px;
    }

    .usf-countdown-sep {
        font-size: 14px;
    }

    .usf-toast {
        right: 12px;
        left: 12px;
        bottom: 12px;
        border-radius: 10px;
        justify-content: center;
    }
}
