/*
====================================================================
ETRUSCAFORM v3.2.0 CSS
====================================================================
1. Enrollment counter (X/15 iscritti)
2. Progress bar
3. Iscriviti (add-to-cart) button
4. Admin reset button
5. Sold out state
6. Toast notifications
====================================================================
*/

/* ============================================
   ENROLLMENT BLOCK (inside course card footer)
   ============================================ */

.ef-enrollment {
    margin-top: 1rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .ef-enrollment {
    border-top-color: #333;
}

/* ── Counter: "3/15 iscritti" ── */
.ef-enrollment__counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.ef-enrollment__count {
    font-family: 'Outfit', -apple-system, sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary, #39110e);
}

[data-theme="dark"] .ef-enrollment__count {
    color: #fff;
}

.ef-enrollment__current {
    color: var(--color-secondary, #d07c39);
    font-size: 1.3rem;
}

.ef-enrollment__separator {
    color: #999;
    margin: 0 0.15rem;
    font-weight: 400;
}

.ef-enrollment__max {
    font-size: 1rem;
    font-weight: 500;
    color: #888;
}

[data-theme="dark"] .ef-enrollment__max {
    color: rgba(255, 255, 255, 0.5);
}

.ef-enrollment__label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
    font-weight: 500;
}

[data-theme="dark"] .ef-enrollment__label {
    color: rgba(255, 255, 255, 0.45);
}

/* ── Progress bar ── */
.ef-enrollment__bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 0.8rem;
    position: relative;
}

[data-theme="dark"] .ef-enrollment__bar {
    background: rgba(255, 255, 255, 0.08);
}

.ef-enrollment__bar-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--color-secondary, #d07c39), #e8a04c);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

/* Color stages */
.ef-enrollment__bar-fill[data-pct="100"],
.ef-enrollment.is-full .ef-enrollment__bar-fill {
    background: linear-gradient(90deg, #c0392b, #e74c3c);
}

.ef-enrollment__bar-fill[data-pct-high],
.ef-enrollment.is-almost .ef-enrollment__bar-fill {
    background: linear-gradient(90deg, #e67e22, #f39c12);
}

/* ── Status line ── */
.ef-enrollment__status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.ef-enrollment__status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Open = green */
.ef-enrollment__status.is-open .ef-enrollment__status-dot {
    background: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.2);
}
.ef-enrollment__status.is-open .ef-enrollment__status-text {
    color: #27ae60;
}

/* Almost full = orange */
.ef-enrollment__status.is-almost .ef-enrollment__status-dot {
    background: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
    animation: ef-pulse 1.5s ease-in-out infinite;
}
.ef-enrollment__status.is-almost .ef-enrollment__status-text {
    color: #e67e22;
}

/* Full = red */
.ef-enrollment__status.is-full .ef-enrollment__status-dot {
    background: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}
.ef-enrollment__status.is-full .ef-enrollment__status-text {
    color: #e74c3c;
}

@keyframes ef-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Cart (Iscriviti) button ── */
.ef-enrollment__cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-family: 'Outfit', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-decoration: none;
    border: 2px solid var(--color-secondary, #d07c39);
    background: var(--color-secondary, #d07c39);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ef-enrollment__cart-btn:hover:not(.is-disabled) {
    background: var(--color-secondary-dark, #c06f33);
    border-color: var(--color-secondary-dark, #c06f33);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(208, 124, 57, 0.3);
    color: #fff;
    text-decoration: none;
}

.ef-enrollment__cart-btn:active:not(.is-disabled) {
    transform: translateY(0);
}

/* Light mode hover text → brown */
:root:not([data-theme="dark"]) .ef-enrollment__cart-btn:hover:not(.is-disabled) {
    color: var(--color-primary, #39110e);
}

/* Sold out state */
.ef-enrollment__cart-btn.is-disabled {
    background: #ccc;
    border-color: #ccc;
    color: #888;
    cursor: not-allowed;
    pointer-events: none;
}

[data-theme="dark"] .ef-enrollment__cart-btn.is-disabled {
    background: #333;
    border-color: #333;
    color: #666;
}

.ef-enrollment__cart-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Price from WooCommerce ── */
.ef-enrollment__woo-price {
    font-family: 'Outfit', -apple-system, sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--color-secondary, #d07c39);
    margin-bottom: 0.5rem;
}

.ef-enrollment__woo-price del {
    color: #aaa;
    font-size: 1rem;
    font-weight: 400;
}

.ef-enrollment__woo-price ins {
    text-decoration: none;
}

/* ── Admin-only: Reset Button ── */
.ef-enrollment__admin {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .ef-enrollment__admin {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.ef-enrollment__reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.55rem 1rem;
    font-family: 'Outfit', -apple-system, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #27ae60;
    background: rgba(39, 174, 96, 0.08);
    border: 1.5px solid rgba(39, 174, 96, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.ef-enrollment__reset-btn:hover {
    background: rgba(39, 174, 96, 0.15);
    border-color: #27ae60;
    transform: translateY(-1px);
}

.ef-enrollment__reset-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.ef-enrollment__reset-btn.is-loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: #27ae60;
    border-radius: 50%;
    animation: ef-spin 0.6s linear infinite;
    margin-left: 0.4rem;
}

@keyframes ef-spin {
    to { transform: rotate(360deg); }
}

/* ── Completions counter ── */
.ef-enrollment__completions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.4rem;
}

[data-theme="dark"] .ef-enrollment__completions {
    color: rgba(255, 255, 255, 0.4);
}

.ef-enrollment__completions svg {
    width: 13px;
    height: 13px;
    opacity: 0.6;
}

/* ── Toast notification ── */
.ef-enrollment__toast {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

.ef-enrollment__toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.ef-enrollment__toast--success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

[data-theme="dark"] .ef-enrollment__toast--success {
    background: rgba(39, 174, 96, 0.15);
    color: #27ae60;
    border-color: rgba(39, 174, 96, 0.3);
}

.ef-enrollment__toast--error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

[data-theme="dark"] .ef-enrollment__toast--error {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.3);
}

/* ── Course card body: relative for toast positioning ── */
.ef-course-card__body {
    position: relative;
}

/* ── Old footer: hide when enrollment is active ── */
.ef-course-card--has-enrollment .ef-course-card__footer {
    display: none;
}

/* ── "Nessun prodotto" message ── */
.ef-enrollment__no-product {
    font-size: 0.82rem;
    color: #aaa;
    font-style: italic;
    padding: 0.5rem 0;
}

[data-theme="dark"] .ef-enrollment__no-product {
    color: rgba(255, 255, 255, 0.35);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media screen and (max-width: 768px) {
    .ef-enrollment__count {
        font-size: 1rem;
    }

    .ef-enrollment__current {
        font-size: 1.15rem;
    }

    .ef-enrollment__cart-btn {
        padding: 0.65rem 1rem;
        font-size: 0.82rem;
    }

    .ef-enrollment__woo-price {
        font-size: 1.2rem;
    }
}
