/**
 * IBP Login Modal - Stili
 * Colori Naturalife: Verde primario #7eb742, Verde scuro #6aa030
 */

/* ================================================
   Overlay e Container
   ================================================ */
.ibp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ibp-modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* ================================================
   Modal Box
   ================================================ */
.ibp-modal-box {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ibp-modal-overlay.active .ibp-modal-box {
    transform: scale(1);
    opacity: 1;
}

/* ================================================
   Header Modal
   ================================================ */
.ibp-modal-header {
    padding: 28px 32px 20px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

.ibp-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.ibp-modal-header p {
    margin: 8px 0 0;
    font-size: 14px;
    color: #777;
}

/* Close button */
.ibp-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    font-size: 18px;
    color: #666;
    line-height: 1;
}

.ibp-modal-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

/* ================================================
   Form Sections
   ================================================ */
.ibp-modal-content {
    padding: 28px 32px 32px;
}

.ibp-form-section {
    display: none;
}

.ibp-form-section.active {
    display: block;
}

/* ================================================
   Form Elements
   ================================================ */
.ibp-form-group {
    margin-bottom: 20px;
}

.ibp-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.ibp-form-group input[type="text"],
.ibp-form-group input[type="email"],
.ibp-form-group input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    color: #333;
    background: #fafafa;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.ibp-form-group input:focus {
    outline: none;
    border-color: #7eb742;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(126, 183, 66, 0.15);
}

.ibp-form-group input::placeholder {
    color: #aaa;
}

/* Remember me checkbox */
.ibp-checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ibp-checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #7eb742;
    cursor: pointer;
}

.ibp-checkbox-group label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}

/* ================================================
   Buttons
   ================================================ */
.ibp-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ibp-btn-primary {
    background: #7eb742;
    color: #fff;
}

.ibp-btn-primary:hover {
    background: #6aa030;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(126, 183, 66, 0.3);
}

.ibp-btn-primary:active {
    transform: translateY(0);
}

.ibp-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading spinner */
.ibp-btn .ibp-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ibp-spin 0.8s linear infinite;
    display: none;
}

.ibp-btn.loading .ibp-spinner {
    display: block;
}

.ibp-btn.loading .ibp-btn-text {
    opacity: 0;
}

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

/* ================================================
   Links and Navigation
   ================================================ */
.ibp-form-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: #666;
}

.ibp-form-footer a,
.ibp-form-link {
    color: #7eb742;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.ibp-form-footer a:hover,
.ibp-form-link:hover {
    color: #6aa030;
    text-decoration: underline;
}

.ibp-forgot-password {
    display: block;
    margin-top: 12px;
    font-size: 13px;
}

/* ================================================
   Messages
   ================================================ */
.ibp-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.ibp-message.show {
    display: block;
}

.ibp-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.ibp-message.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* ================================================
   Divider
   ================================================ */
.ibp-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: #999;
    font-size: 13px;
}

.ibp-divider::before,
.ibp-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.ibp-divider span {
    padding: 0 16px;
}

/* ================================================
   Header Icon
   ================================================ */
.ibp-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease, color 0.2s ease;
    vertical-align: middle;
}

.ibp-header-icon:hover {
    opacity: 0.7;
    color: #7eb742;
}

.ibp-header-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

/* Fixed icon fallback (se non troviamo header) */
.ibp-fixed-icon-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9998;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    padding: 8px;
}

.ibp-fixed-icon-container .ibp-header-icon {
    width: 36px;
    height: 36px;
    color: #333;
}

.ibp-fixed-icon-container .ibp-header-icon:hover {
    color: #7eb742;
}

/* Legacy support per icone esistenti */
.ibp-login-trigger,
.ibp-account-link {
    cursor: pointer;
}

.ibp-login-trigger:hover,
.ibp-account-link:hover {
    opacity: 0.8;
}

/* ================================================
   Mobile Header Icon (Naturalife)
   ================================================ */
.mobile-header .ibp-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 8px;
}

.mobile-header .ibp-header-icon svg {
    width: 22px;
    height: 22px;
}

/* ================================================
   Responsive
   ================================================ */
@media screen and (max-width: 480px) {
    .ibp-modal-box {
        width: 95%;
        max-width: none;
        margin: 10px;
        border-radius: 10px;
    }

    .ibp-modal-header {
        padding: 24px 20px 16px;
    }

    .ibp-modal-header h3 {
        font-size: 20px;
    }

    .ibp-modal-content {
        padding: 20px;
    }

    .ibp-form-group input[type="text"],
    .ibp-form-group input[type="email"],
    .ibp-form-group input[type="password"] {
        padding: 12px 14px;
        font-size: 16px; /* Previene zoom su iOS */
    }

    .ibp-btn {
        padding: 12px 20px;
    }

    /* Fixed icon su mobile */
    .ibp-fixed-icon-container {
        top: 10px;
        right: 10px;
        padding: 6px;
    }

    .ibp-fixed-icon-container .ibp-header-icon {
        width: 32px;
        height: 32px;
    }

    .ibp-fixed-icon-container .ibp-header-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* ================================================
   Accessibilità
   ================================================ */
.ibp-form-group input:focus-visible,
.ibp-btn:focus-visible,
.ibp-modal-close:focus-visible {
    outline: 2px solid #7eb742;
    outline-offset: 2px;
}

/* Screen reader only */
.ibp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
